Page 9 of 9 FirstFirst ... 789
Results 201 to 220 of 220

Thread: OpenGL plugins

  1. #201
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Lots of mouse functions and such are much better in SRL-6.
    Ahh yeah i copied over the Mouse functions from SRL6 as well, but other than that there's hardly anything else that could work on resizable RS.
    If you need some generic methods, like TBox.contains() etc that cant find found in the glx, then u can simply copy them over as and when you need it.
    Much better than trying to include the entire SRL6 to the glx imo.

  2. #202
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Ahh yeah i copied over the Mouse functions from SRL6 as well, but other than that there's hardly anything else that could work on resizable RS.
    If you need some generic methods, like TBox.contains() etc that cant find found in the glx, then u can simply copy them over as and when you need it.
    Much better than trying to include the entire SRL6 to the glx imo.

    Yeah true, but this will make it more user friendly I think. Another thing I like is that you can set the interfaces to the same size as regular srl-6 interfaces and then use a lot of the same functions there too, just use OGL to get the new bounds.

  3. #203
    Join Date
    Feb 2012
    Location
    Portugal
    Posts
    91
    Mentioned
    3 Post(s)
    Quoted
    41 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Ahh yeah i copied over the Mouse functions from SRL6 as well, but other than that there's hardly anything else that could work on resizable RS.
    If you need some generic methods, like TBox.contains() etc that cant find found in the glx, then u can simply copy them over as and when you need it.
    Much better than trying to include the entire SRL6 to the glx imo.
    How about passing 6 hour limit and spawining Smart in OpenGL right away instead of manually doing it from Safe Mode? How about SPS, how about the whole rest, like productionScreens, and shit toon of stuff. Sure you could make a ogl include that would port all of that, but it would take soo long. I would love to work on an amazing piece like that one. Lets combine our forces toghether and designs a OpenGL include that looks exactly the same as SRL-6! That would be awesome, honestly I quite think that is the future of color botting. Either that or DirectX intersection.

  4. #204
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by PatriqDesigns View Post
    How about passing 6 hour limit and spawining Smart in OpenGL right away instead of manually doing it from Safe Mode? How about SPS, how about the whole rest, like productionScreens, and shit toon of stuff. Sure you could make a ogl include that would port all of that, but it would take soo long. I would love to work on an amazing piece like that one. Lets combine our forces toghether and designs a OpenGL include that looks exactly the same as SRL-6! That would be awesome, honestly I quite think that is the future of color botting. Either that or DirectX intersection.
    Idk what u mean by having to manually do it from safe mode? GL_RestartClient() restarts the SMART for you, Brandon even wrote GL_GameSession() for detecting game session ended though i wrote my own to consider rs update etc messages. Never had any problem running my scripts 24/7 with ogl

    You can modify the SPS include slightly to make it compatible with dynamic interface (using ogl functions to grab the minimap bounds, compass etc).
    As for other functions like production screen, i wrote them whenever i needed them.
    True enough, there's quite a lot that you have to write yourself, but it's easy to write glx functions and they are much more accurate and dynamic than the SRL6 versions.

    If u still prefer to make the include compatible with SRL6, just post whatever compiling error you are getting that you cant solve, we'd be happy to help

  5. #205
    Join Date
    Feb 2012
    Location
    Portugal
    Posts
    91
    Mentioned
    3 Post(s)
    Quoted
    41 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Idk what u mean by having to manually do it from safe mode? GL_RestartClient() restarts the SMART for you, Brandon even wrote GL_GameSession() for detecting game session ended though i wrote my own to consider rs update etc messages. Never had any problem running my scripts 24/7 with ogl

    You can modify the SPS include slightly to make it compatible with dynamic interface (using ogl functions to grab the minimap bounds, compass etc).
    As for other functions like production screen, i wrote them whenever i needed them.
    True enough, there's quite a lot that you have to write yourself, but it's easy to write glx functions and they are much more accurate and dynamic than the SRL6 versions.

    If u still prefer to make the include compatible with SRL6, just post whatever compiling error you are getting that you cant solve, we'd be happy to help
    Well why dont you release what you have done to the community? Why wont you make a repo for it where all could contribute. That would be awesome, and would let OpenGL development be more "accepted" and used.

  6. #206
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by PatriqDesigns View Post
    Well why dont you release what you have done to the community? Why wont you make a repo for it where all could contribute. That would be awesome, and would let OpenGL development be more "accepted" and used.
    I made my include with functional and development efficiency in mind, so the coding conventions/structures do not adhere to the proper standards of a public library. Sometimes when i look at my older codes even i couldnt understand what i was trying to do didn't practise commenting and glx scripting is just...numbers everywhere.

    I think only someone with the patience of coming up with a lot of constants for IDs/commenting every single ID used would be up to the task of maintaining an ogl include that can be developed and maintained by the public.


    Also, there's still a few issues with the plugin that may require modifying the GLXCore functions, eg:https://villavu.com/forum/showthread...81#post1327181
    @Brandon; have you thought of the best solution regarding the animated textures?
    I'd support option 2b. Add new class of Textures to the include. (with a separate GLX method that grabs them)
    Reasons being:
    1. Sometimes those animated textures appear in weird places (like the tiny dot in inventory) so scripters can avoid them by not calling the animated texture function. This also ensures that existing scripts that was created using the old plugin would not face any issues (eg. a function might only be expecting 1 gltexture, but the new plugin gives 1 extra animated texture which the function ended up using instead of the normal one)

    2. Animated textures are not very often used, so separating them could improve efficiency (by not grabbing the animated textures that wouldnt be used)

    3. Makes it easier to grab all animated textures instead of just one.

  7. #207
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    I'd support option 2b. Add new class of Textures to the include. (with a separate GLX method that grabs them)
    I did not think of a solution yet but I am leaning on doing exactly that. I've been trying really HARD to keep the new code-base understandable for all and not just me.. Then I've been working on optimising & micro-optimising (because this is low level graphics) stuff but trying to keep it readable as well..

    The current plugin has way too much patch code and it's really hard for me to just stick in new stuff..

    For example, some micro-ops would be:

    (2195 mod 256) - 11 I've optimised to (2195 & 255) - 11 to avoid the cost of modulo.. Now it may not look like a huge change, but when ran over thousands of times per second and bottle necks the CPU, it counts a lot. I've benched it and tested it.
    And since all textures are GL_TEXTURE_2D (power of two's.. about damn time Jagex updated their stuff), it makes this even faster than ever.


    Then I got rid of GL_TEXTURE_ARB (non-power of two textures) because the game no longer uses it and there's no need for unnecessary branching and extra checks.. Sometimes it uses it for the tiniest irrelevant code.

    I completely re-wrote fonts so that it doesn't have to store almost 10k fonts per frame per area.. Instead, it stores nothing and grabs them on the fly due to the above calculation.. This means that I don't have to delete anything because there's no memory being used..

    For example.. Previously I did:

    C++ Code:
    void Font::LogEndList()
    {
        if (this->Found) //check if a character was possibly rendered.
        {
            this->LastFont = false; //is this the last character rendered in a font set (256 * however many lists the game loads.. roughly 4k).

            if (!this->Fonts.size()) //if this is the last font, reset the next font to start at "32" aka space in ASCII.
                this->Letter = 32;
            else
                this->Letter = (!this->Fonts.back().LastFont) ? this->Fonts.back().Letter + 1 : 32; //Else, the next char is the last char + 1 in the ASCII table.

            if (++this->Count >= 255) //Every 256 fonts, we need to reset the font counter and start over.. There's roughly 4k lists to go through.
            {
                this->Count = 0;
                this->LastFont = true;
                this->Found = false;
            }
            this->Fonts.push_back(*this); //Store the current character in the Font vector structure.
        }
    }


    and now I do:

    C++ Code:
    void Font::LogFont(unsigned int List)
    {
        font->Letter = (List & 0xFF) - 11;
    }

    And trust me when I say that's probably the biggest improvement so far (because I haven't worked on anything else yet other than raw API code).. I went from storing 10k "Font structures" in a vector or maps and doing a look up to get each letter rendered.. To doing no look ups and storing nothing OR storing on a frame-by-frame basis in the very worst case.


    You can see that the new above generic algorithm works for all characters:

    C++ Code:
    1632  % 256 = 96    minus 11 = U
    1662  % 256 = 126   minus 11 = s
    1648  % 256 = 112   minus 11 = e
    1661  % 256 = ?  minus 11 = ?
    1657  ...
    1644  ...

    Derived Algorithm: Character = (List % 256) - 11.

    Faster Derived algorithm: Character = (List & 255) - 11.

    You can test it out for the remaining letters and see that it spells out "Username" which was the text written on the login screen. I tested this on menus, login, etc..


    Other than that, I've been working on the math and calculations:

    C++ Code:
    Mat4 Mat4::Transpose() const
    {
        Mat4 res;
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                res[j][i] = mat[i][j];
            }
        }
        return res;
    }

    Mat4 Mat4::Identity()
    {
        Mat4 res;
        res[0][0] = 1.0f;
        res[1][1] = 1.0f;
        res[2][2] = 1.0f;
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::Orthagonal(float w, float h, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 2.0f / w;
        res[1][1] = -2.0f / h;
        res[2][2] = -2.0f / (zFar - zNear);
        res[3][3] = 1.0f;
        res[3][0] = -1.0f;
        res[3][1] = 1.0f;
        res[3][2] = (zFar + zNear) / (zFar - zNear);
        return res;
    }

    Mat4 Mat4::Perspective(float w, float h, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 2.0f * zNear / w;
        res[1][1] = -2.0f * zNear / h;
        res[2][2] = ((-zFar - zNear) * zFar) / (zFar - zNear);
        res[2][3] = -2.0f * zNear / (zNear - zFar);
        res[3][2] = -1.0f;

        res[0][2] = 1.0f;
        res[1][2] = -1.0f;
        return res;
    }

    Mat4 Mat4::FieldOfView(float fov, float aspect, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 1.0f / tanf(fov / 2.0f);
        res[1][1] = aspect / tanf(fov / 2.0f);
        res[2][2] = zFar / (zFar - zNear);
        res[3][2] = (zFar * zNear) / (zNear - zFar);
        res[2][3] = -1.0f;
        res[3][3] = 0.0f;
        return res;
    }

    Mat4 Mat4::LookAt(const Vec3& Eye, const Vec3& At, const Vec3& Up)
    {
        Vec3 XAxis, YAxis, ZAxis;
        ZAxis = (Eye - At).Normalise();
        XAxis = (Up.Cross(ZAxis)).Normalise();
        YAxis = (ZAxis.Cross(XAxis)).Normalise();

        Mat4 res;
        res[0][0] = XAxis.x;
        res[1][0] = XAxis.y;
        res[2][0] = XAxis.z;
        res[3][0] = -XAxis.Dot(Eye);
        res[0][1] = YAxis.x;
        res[1][1] = YAxis.y;
        res[2][1] = YAxis.z;
        res[3][1] = -YAxis.Dot(Eye);
        res[0][2] = ZAxis.x;
        res[1][2] = ZAxis.y;
        res[2][2] = ZAxis.z;
        res[3][2] = -ZAxis.Dot(Eye);
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::RotX(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[1][1] = ct;
        res[1][2] = st;
        res[2][1] = -st;
        res[2][2] = ct;
        return res;
    }

    Mat4 Mat4::RotY(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[0][0] = ct;
        res[0][2] = st;
        res[2][0] = -st;
        res[2][2] = ct;
        return res;
    }

    Mat4 Mat4::RotZ(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[0][0] = ct;
        res[0][1] = st;
        res[1][0] = -st;
        res[1][1] = ct;
        return res;
    }

    Mat4 Mat4::Rot(float pitch, float yaw, float roll)
    {
        return RotY(yaw) * RotX(pitch) * RotZ(roll);
    }

    Mat4 Mat4::Scale(float val)
    {
        return Scale(val, val, val);
    }

    Mat4 Mat4::Scale(float x, float y, float z)
    {
        Mat4 res;
        res[0][0] = x;
        res[1][1] = y;
        res[2][2] = z;
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::Translate(float x, float y, float z)
    {
        Mat4 res;
        res[3][0] = x;
        res[3][1] = y;
        res[3][2] = z;
        res[0][0] = 1.0f;
        res[1][1] = 1.0f;
        res[2][2] = 1.0f;
        res[3][3] = 1.0f;
        return res;
    }


    But I re-wrote a bunch of code as well:


    Serialisation is brand spanking new and way faster and more efficient than before:

    C++ Code:
    #ifndef STREAM_HXX_INCLUDED
    #define STREAM_HXX_INCLUDED

    #include <vector>
    #include <list>
    #include <string>
    #include <sstream>

    /********************************************//**
     * @brief A class for serialising all data-types & containers into a buffer.
     ***********************************************/

    class Stream
    {
    private:
        std::stringstream Data;

        /********************************************//**
         * @brief Determines if two types are the exact same when decayed at compile time.
         *
         * @param T - Type to compare to.
         * @param U - Type that is decayed first and compared to T.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T, typename U>
        struct is_same_decay : public std::integral_constant<bool, std::is_same<T, typename std::decay<U>::type>::value> {};


        /********************************************//**
         * @brief Compares a type to a char*, or const char* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_cstring : public std::integral_constant<bool, is_same_decay<char*, T>::value || is_same_decay<const char*, T>::value> {};


        /********************************************//**
         * @brief Compares a type to a wchar_t*, or const wchar_t* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_wcstring : public std::integral_constant<bool, is_same_decay<wchar_t*, T>::value || is_same_decay<const wchar_t*, T>::value> {};


    public:
        /********************************************//**
         * @brief Constructs a stream class.
         *
         * @param Buffer void* - Buffer to serialise/de-serialise data to/from.
         * @param BufferSize std::size_t - Size of the specified buffer.
         *
         ***********************************************/

        Stream(void* Buffer, std::size_t BufferSize);

        template<typename T>
        void Read(T &Value);

        template<typename T>
        void Write(const T &Value);

        template<typename T>
        typename std::enable_if<!is_cstring<T>::value && !is_wcstring<T>::value, Stream&>::type operator << (const T &Value);

        template<typename T>
        typename std::enable_if<!is_cstring<T>::value && !is_wcstring<T>::value, Stream&>::type operator >> (T &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::vector<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::list<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::basic_string<T, Allocator> &Value);


        template<typename T, typename Allocator>
        Stream& operator >> (std::vector<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator >> (std::list<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator >> (std::basic_string<T, Allocator> &Value);
    };
    #endif // STREAM_HXX_INCLUDED


    Graphics is re-written too:

    C++ Code:
    #ifndef GRAPHICS_HXX_INCLUDED
    #define GRAPHICS_HXX_INCLUDED

    #include <GL/gl.h>
    #include <GL/glext.h>
    #include <utility>
    #include <string>
    #include <cstring>
    #include <vector>
    #include <fstream>

    #if defined _WIN32 || defined _WIN64
    #include <windows.h>
    #endif

    #include "Libraries/LodePNG.hxx"


    /********************************************//**
    * @brief Structured Union representing a tightly packed RGBA memory layout.
    ***********************************************/

    typedef union RGBA
    {
        unsigned int Colour;
        struct
        {
            unsigned char R, G, B, A;
        };
    } *PRGB;



    /********************************************//**
     * @brief A class representing a 32 bit Image such as Bitmaps and PNGs.
     *        24-bit is NOT support on purpose. Graphics cards process 32-bit images faster.
     ***********************************************/

    class Image
    {
    private:
        #ifdef GRAPHICS_IMAGE_LOADING
        std::vector<unsigned char> Pixels;
        #else
        unsigned char* Pixels;
        #endif
        unsigned int Width;
        unsigned int Height;

    public:
        enum class Format {GL_BMP, GL_PNG};

        #ifdef GRAPHICS_IMAGE_LOADING
        Image(const char* Path);
        #endif // ENABLE_IMAGE_LOADING

        Image(unsigned int Target, unsigned int ID);
        Image(void* Data, unsigned int Width, unsigned int Height);
        ~Image();

        const void* GetPixels() const;

        void Save(const char* Path, Format Fmt = Format::GL_PNG);

        void Flip();
        void FlipTo(void* Data);
        void Transpose();
        void TransposeTo(void* Data);
        static void Flip(void* In, void* &Out, int width, int height, uint32_t Bpp = 32);
    };




    /********************************************//**
    * @brief A class representing a texture in video memory. Upon destruction, the texture is deleted.
    ***********************************************/

    class Texture
    {
    private:
        unsigned int ID;
        unsigned int Target;
        unsigned int Width, Height;
        unsigned int Format;

    public:
        /********************************************//**
         * @brief Texture Constructor. Initialises a texture in video memory.
         *
         * @param Target unsigned int - Can be GL_TEXTURE_RECTANGLE OR GL_TEXTURE_2D
         * @param Width unsigned int  - Width of the texture to create.
         * @param Height unsigned int - Height of the texture to create.
         * @param unsigned char* Pixels = nullptr - Pixels are optional. If specified, must be in a 32-bit format (ARGB, BGRA, ABGR, etc).
         * @param unsigned int Format = GL_BGRA - Format of the 32-bit layout. (ARGB, BGRA, ABGR, etc..) CANNOT be 24-bit formats.
         *
         ***********************************************/

        Texture(unsigned int Target, unsigned int Width, unsigned int Height, unsigned char* Pixels = nullptr, unsigned int Format = GL_BGRA);


        /********************************************//**
         * @brief Texture Destructor. Deletes a texture from video memory. Cleanup.
         ***********************************************/

        ~Texture();



        /********************************************//**
         * @brief Sets the pixels of the entire texture.
         *         Pixels must be Width * Height * 4 OR ((Width * 32 + 31) / 32) * 4 * Height.
         *
         * @param unsigned char* Pixels - Buffer containing the pixels to be set.
         * @return
         *
         ***********************************************/

        void SetPixels(unsigned char* Pixels);


        /********************************************//**
         * @brief Draws this texture to the back-buffer with glColor4ub(255, 255, 255, 255).
         *
         * @param X1 float - The X-coordinate of the upper-left corner of the rectangle in which to render this texture.
         * @param Y1 float - The Y-coordinate of the upper-left corner of the rectangle in which to render this texture.
         * @param X2 float - The X-coordinate of the lower-right corner of the rectangle in which to render this texture.
         * @param Y2 float - The Y-coordinate of the lower-right corner of the rectangle in which to render this texture.
         * @return void
         *
         ***********************************************/

        void Draw(float X1, float Y1, float X2, float Y2);


        /********************************************//**
         * @brief Returns the ID of the texture generated by this class.
         *
         * @return unsigned int - ID of the texture in video memory.
         *
         ***********************************************/

        unsigned int GetID() const {return ID;}


        /********************************************//**
         * @brief Returns the PixelFormat of the texture generated by this class. Always returns a 32-bit format.
         *
         * @return unsigned int - Pixel Format: GL_RGBA, GL_BGRA, etc..
         *
         ***********************************************/

        unsigned int GetPixelFormat() const {return Format;}


        /********************************************//**
         * @brief Returns the Width of this texture as specified upon creation.
         *
         * @return int
         *
         ***********************************************/

        int GetWidth() const {return Width;}


        /********************************************//**
         * @brief Returns the Height of this texture as specified upon creation.
         *
         * @return int
         *
         ***********************************************/

        int GetHeight() const {return Height;}


        /********************************************//**
         * @brief Returns the Target of this texture as specified upon creation. GL_TEXTURE_RECTANGLE OR GL_TEXTURE_2D
         *
         * @return unsigned int
         *
         ***********************************************/

        unsigned int GetTarget() const {return Target;}
    };




    /********************************************//**
    * @brief A class representing a Font in Graphics Memory (DeviceContext). Upon destruction, the font is deleted.
    ***********************************************/

    class Font
    {
    private:
        HDC DC;
        unsigned int Base;
        unsigned int Size;
        const char* Name;


        /********************************************//**
         * @brief Determines if two types are the exact same when decayed at compile time.
         *
         * @param T - Type to compare to.
         * @param U - Type that is decayed first and compared to T.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T, typename U>
        struct is_same_decay : public std::integral_constant<bool, std::is_same<T, typename std::decay<U>::type>::value> {};


        /********************************************//**
         * @brief Compares a type to a char, char*, or const char* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_char_type : public std::integral_constant<bool, is_same_decay<char, T>::value || is_same_decay<char*, T>::value || is_same_decay<const char*, T>::value> {};


        /********************************************//**
         * @brief Overrides std::to_string via ADL but only if the parameter is a char, char* or const char* when decayed.
         *
         * @param value T to be convert to a string. Must be a char, char* or const char* for this function to be triggered.
         * @return An STL string containing the contents of the parameter.
         *
         ***********************************************/

        template<typename T>
        std::string to_string(T value)
        {
            static_assert(is_char_type<T>::value, "Argument: Value Must be of literal type.");
            std::string Result;
            Result += value;
            return Result;
        }

    public:
        /********************************************//**
         * @brief Constructor for constructing a BitmapFont in video memory.
         *
         * @param Name const char* - Name of the font to be used. Arial, TimesNewRoman, etc..
         * @param DC HDC - Device Context in which to select the new font into.
         * @param Size unsigned int - Size of the font.
         *
         ***********************************************/

        Font(const char* Name, HDC DC, unsigned int Size);


        /********************************************//**
         * @brief Destructor deleted the font from video memory.
         ***********************************************/

        ~Font();



        /********************************************//**
         * @brief Variadic template version of PrintF for OpenGL. Draws a string in white.
         *
         * @param X float - X position on the screen where the top left of the string is to be drawn.
         * @param Y float - Y position on the screen where the top left of the string is to be drawn.
         * @param Text const char* - Text containing the string as well as the format if necessary.
         * @param args Args&&... - Variadic parameter pack containing arguments deduced by the format string if any.
         * @return void
         *
         * Draw(X, Y, "This is a non-formated string");
         * Draw(X, Y, "This is a formated string with % number(s), 1);
         *
         ***********************************************/

        template<typename... Args>
        void Draw(float X, float Y, const char* Text, Args&&... args);


        /********************************************//**
         * @brief Variadic template version of PrintF for OpenGL. Draws a string in any colour.
         *
         * @param X float - X position on the screen where the top left of the string is to be drawn.
         * @param Y float - Y position on the screen where the top left of the string is to be drawn.
         * @param R float - R component in the RGB model of the colour to be used. 0.0f <= R <= 1.0f.
         * @param G float - G component in the RGB model of the colour to be used. 0.0f <= G <= 1.0f.
         * @param B float - B component in the RGB model of the colour to be used. 0.0f <= B <= 1.0f.
         * @param Text const char* - Text containing the string as well as the format if necessary.
         * @param args Args&&... - Variadic parameter pack containing arguments deduced by the format string if any.
         * @return void
         *
         * Draw(X, Y, 0.5f, 0.5f, 0.5f, "This is a non-formated string");
         * Draw(X, Y, 1.0f, 0.0f, 0.0f, "This is a formated string with % number(s), 1);
         ***********************************************/

        template<typename... Args>
        void Draw(float X, float Y, float R, float G, float B, const char* Text, Args&&... args);
    };

    #endif // GRAPHICS_HXX_INCLUDED



    The documentation takes the longest and wastes the most time.. So all in all, I have NOT been working on animated textures or patching the current plugin. I've instead been getting rid of the old code and slowly replacing it with faster and better new code with proper documentation.. That includes the hooking API so that things will be EASIER for me to hook. Otherwise, there's not really a way for me to just shove in a new texture API without headaches..

    Also been trying to make it as cross-platform as I can.. The reason for the re-write is simply.. It's impossible to hook model vertices with the current code.. This is something I keep getting asked to implement.. With the new code-base, I can port most of my Direct-X code to OpenGL for model hooks (We'll see if it works).

    Things like this: https://github.com/Brandon-T/SRL-GLX...ore.simba#L981 NEEDS to be updated.. It was written when Lape was in its earliest release stage and it's extremely nasty. I don't think I even remember how it works -__-..
    Last edited by Brandon; 02-08-2015 at 03:31 AM.
    I am Ggzz..
    Hackintosher

  8. #208
    Join Date
    Feb 2012
    Location
    Portugal
    Posts
    91
    Mentioned
    3 Post(s)
    Quoted
    41 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    I did not think of a solution yet but I am leaning on doing exactly that. I've been trying really HARD to keep the new code-base understandable for all and not just me.. Then I've been working on optimising & micro-optimising (because this is low level graphics) stuff but trying to keep it readable as well..

    The current plugin has way too much patch code and it's really hard for me to just stick in new stuff..

    For example, some micro-ops would be:

    (2195 mod 256) - 11 I've optimised to (2195 & 255) - 11 to avoid the cost of modulo.. Now it may not look like a huge change, but when ran over thousands of times per second and bottle necks the CPU, it counts a lot. I've benched it and tested it.
    And since all textures are GL_TEXTURE_2D (power of two's.. about damn time Jagex updated their stuff), it makes this even faster than ever.


    Then I got rid of GL_TEXTURE_ARB (non-power of two textures) because the game no longer uses it and there's no need for unnecessary branching and extra checks.. Sometimes it uses it for the tiniest irrelevant code.

    I completely re-wrote fonts so that it doesn't have to store almost 10k fonts per frame per area.. Instead, it stores nothing and grabs them on the fly due to the above calculation.. This means that I don't have to delete anything because there's no memory being used..

    For example.. Previously I did:

    C++ Code:
    void Font::LogEndList()
    {
        if (this->Found) //check if a character was possibly rendered.
        {
            this->LastFont = false; //is this the last character rendered in a font set (256 * however many lists the game loads.. roughly 4k).

            if (!this->Fonts.size()) //if this is the last font, reset the next font to start at "32" aka space in ASCII.
                this->Letter = 32;
            else
                this->Letter = (!this->Fonts.back().LastFont) ? this->Fonts.back().Letter + 1 : 32; //Else, the next char is the last char + 1 in the ASCII table.

            if (++this->Count >= 255) //Every 256 fonts, we need to reset the font counter and start over.. There's roughly 4k lists to go through.
            {
                this->Count = 0;
                this->LastFont = true;
                this->Found = false;
            }
            this->Fonts.push_back(*this); //Store the current character in the Font vector structure.
        }
    }


    and now I do:

    C++ Code:
    void Font::LogFont(unsigned int List)
    {
        font->Letter = (List & 0xFF) - 11;
    }

    And trust me when I say that's probably the biggest improvement so far (because I haven't worked on anything else yet other than raw API code).. I went from storing 10k "Font structures" in a vector or maps and doing a look up to get each letter rendered.. To doing no look ups and storing nothing OR storing on a frame-by-frame basis in the very worst case.


    You can see that the new above generic algorithm works for all characters:

    C++ Code:
    1632  % 256 = 96    minus 11 = U
    1662  % 256 = 126   minus 11 = s
    1648  % 256 = 112   minus 11 = e
    1661  % 256 = ?  minus 11 = ?
    1657  ...
    1644  ...

    Derived Algorithm: Character = (List % 256) - 11.

    Faster Derived algorithm: Character = (List & 255) - 11.

    You can test it out for the remaining letters and see that it spells out "Username" which was the text written on the login screen. I tested this on menus, login, etc..


    Other than that, I've been working on the math and calculations:

    C++ Code:
    Mat4 Mat4::Transpose() const
    {
        Mat4 res;
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                res[j][i] = mat[i][j];
            }
        }
        return res;
    }

    Mat4 Mat4::Identity()
    {
        Mat4 res;
        res[0][0] = 1.0f;
        res[1][1] = 1.0f;
        res[2][2] = 1.0f;
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::Orthagonal(float w, float h, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 2.0f / w;
        res[1][1] = -2.0f / h;
        res[2][2] = -2.0f / (zFar - zNear);
        res[3][3] = 1.0f;
        res[3][0] = -1.0f;
        res[3][1] = 1.0f;
        res[3][2] = (zFar + zNear) / (zFar - zNear);
        return res;
    }

    Mat4 Mat4::Perspective(float w, float h, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 2.0f * zNear / w;
        res[1][1] = -2.0f * zNear / h;
        res[2][2] = ((-zFar - zNear) * zFar) / (zFar - zNear);
        res[2][3] = -2.0f * zNear / (zNear - zFar);
        res[3][2] = -1.0f;

        res[0][2] = 1.0f;
        res[1][2] = -1.0f;
        return res;
    }

    Mat4 Mat4::FieldOfView(float fov, float aspect, float zNear, float zFar)
    {
        Mat4 res;
        res[0][0] = 1.0f / tanf(fov / 2.0f);
        res[1][1] = aspect / tanf(fov / 2.0f);
        res[2][2] = zFar / (zFar - zNear);
        res[3][2] = (zFar * zNear) / (zNear - zFar);
        res[2][3] = -1.0f;
        res[3][3] = 0.0f;
        return res;
    }

    Mat4 Mat4::LookAt(const Vec3& Eye, const Vec3& At, const Vec3& Up)
    {
        Vec3 XAxis, YAxis, ZAxis;
        ZAxis = (Eye - At).Normalise();
        XAxis = (Up.Cross(ZAxis)).Normalise();
        YAxis = (ZAxis.Cross(XAxis)).Normalise();

        Mat4 res;
        res[0][0] = XAxis.x;
        res[1][0] = XAxis.y;
        res[2][0] = XAxis.z;
        res[3][0] = -XAxis.Dot(Eye);
        res[0][1] = YAxis.x;
        res[1][1] = YAxis.y;
        res[2][1] = YAxis.z;
        res[3][1] = -YAxis.Dot(Eye);
        res[0][2] = ZAxis.x;
        res[1][2] = ZAxis.y;
        res[2][2] = ZAxis.z;
        res[3][2] = -ZAxis.Dot(Eye);
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::RotX(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[1][1] = ct;
        res[1][2] = st;
        res[2][1] = -st;
        res[2][2] = ct;
        return res;
    }

    Mat4 Mat4::RotY(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[0][0] = ct;
        res[0][2] = st;
        res[2][0] = -st;
        res[2][2] = ct;
        return res;
    }

    Mat4 Mat4::RotZ(float rad)
    {
        float ct = cosf(rad);
        float st = sinf(rad);
        Mat4 res = Identity();
        res[0][0] = ct;
        res[0][1] = st;
        res[1][0] = -st;
        res[1][1] = ct;
        return res;
    }

    Mat4 Mat4::Rot(float pitch, float yaw, float roll)
    {
        return RotY(yaw) * RotX(pitch) * RotZ(roll);
    }

    Mat4 Mat4::Scale(float val)
    {
        return Scale(val, val, val);
    }

    Mat4 Mat4::Scale(float x, float y, float z)
    {
        Mat4 res;
        res[0][0] = x;
        res[1][1] = y;
        res[2][2] = z;
        res[3][3] = 1.0f;
        return res;
    }

    Mat4 Mat4::Translate(float x, float y, float z)
    {
        Mat4 res;
        res[3][0] = x;
        res[3][1] = y;
        res[3][2] = z;
        res[0][0] = 1.0f;
        res[1][1] = 1.0f;
        res[2][2] = 1.0f;
        res[3][3] = 1.0f;
        return res;
    }


    But I re-wrote a bunch of code as well:


    Serialisation is brand spanking new and way faster and more efficient than before:

    C++ Code:
    #ifndef STREAM_HXX_INCLUDED
    #define STREAM_HXX_INCLUDED

    #include <vector>
    #include <list>
    #include <string>
    #include <sstream>

    /********************************************//**
     * @brief A class for serialising all data-types & containers into a buffer.
     ***********************************************/

    class Stream
    {
    private:
        std::stringstream Data;

        /********************************************//**
         * @brief Determines if two types are the exact same when decayed at compile time.
         *
         * @param T - Type to compare to.
         * @param U - Type that is decayed first and compared to T.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T, typename U>
        struct is_same_decay : public std::integral_constant<bool, std::is_same<T, typename std::decay<U>::type>::value> {};


        /********************************************//**
         * @brief Compares a type to a char*, or const char* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_cstring : public std::integral_constant<bool, is_same_decay<char*, T>::value || is_same_decay<const char*, T>::value> {};


        /********************************************//**
         * @brief Compares a type to a wchar_t*, or const wchar_t* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_wcstring : public std::integral_constant<bool, is_same_decay<wchar_t*, T>::value || is_same_decay<const wchar_t*, T>::value> {};


    public:
        /********************************************//**
         * @brief Constructs a stream class.
         *
         * @param Buffer void* - Buffer to serialise/de-serialise data to/from.
         * @param BufferSize std::size_t - Size of the specified buffer.
         *
         ***********************************************/

        Stream(void* Buffer, std::size_t BufferSize);

        template<typename T>
        void Read(T &Value);

        template<typename T>
        void Write(const T &Value);

        template<typename T>
        typename std::enable_if<!is_cstring<T>::value && !is_wcstring<T>::value, Stream&>::type operator << (const T &Value);

        template<typename T>
        typename std::enable_if<!is_cstring<T>::value && !is_wcstring<T>::value, Stream&>::type operator >> (T &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::vector<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::list<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator << (const std::basic_string<T, Allocator> &Value);


        template<typename T, typename Allocator>
        Stream& operator >> (std::vector<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator >> (std::list<T, Allocator> &Value);

        template<typename T, typename Allocator>
        Stream& operator >> (std::basic_string<T, Allocator> &Value);
    };
    #endif // STREAM_HXX_INCLUDED


    Graphics is re-written too:

    C++ Code:
    #ifndef GRAPHICS_HXX_INCLUDED
    #define GRAPHICS_HXX_INCLUDED

    #include <GL/gl.h>
    #include <GL/glext.h>
    #include <utility>
    #include <string>
    #include <cstring>
    #include <vector>
    #include <fstream>

    #if defined _WIN32 || defined _WIN64
    #include <windows.h>
    #endif

    #include "Libraries/LodePNG.hxx"


    /********************************************//**
    * @brief Structured Union representing a tightly packed RGBA memory layout.
    ***********************************************/

    typedef union RGBA
    {
        unsigned int Colour;
        struct
        {
            unsigned char R, G, B, A;
        };
    } *PRGB;



    /********************************************//**
     * @brief A class representing a 32 bit Image such as Bitmaps and PNGs.
     *        24-bit is NOT support on purpose. Graphics cards process 32-bit images faster.
     ***********************************************/

    class Image
    {
    private:
        #ifdef GRAPHICS_IMAGE_LOADING
        std::vector<unsigned char> Pixels;
        #else
        unsigned char* Pixels;
        #endif
        unsigned int Width;
        unsigned int Height;

    public:
        enum class Format {GL_BMP, GL_PNG};

        #ifdef GRAPHICS_IMAGE_LOADING
        Image(const char* Path);
        #endif // ENABLE_IMAGE_LOADING

        Image(unsigned int Target, unsigned int ID);
        Image(void* Data, unsigned int Width, unsigned int Height);
        ~Image();

        const void* GetPixels() const;

        void Save(const char* Path, Format Fmt = Format::GL_PNG);

        void Flip();
        void FlipTo(void* Data);
        void Transpose();
        void TransposeTo(void* Data);
        static void Flip(void* In, void* &Out, int width, int height, uint32_t Bpp = 32);
    };




    /********************************************//**
    * @brief A class representing a texture in video memory. Upon destruction, the texture is deleted.
    ***********************************************/

    class Texture
    {
    private:
        unsigned int ID;
        unsigned int Target;
        unsigned int Width, Height;
        unsigned int Format;

    public:
        /********************************************//**
         * @brief Texture Constructor. Initialises a texture in video memory.
         *
         * @param Target unsigned int - Can be GL_TEXTURE_RECTANGLE OR GL_TEXTURE_2D
         * @param Width unsigned int  - Width of the texture to create.
         * @param Height unsigned int - Height of the texture to create.
         * @param unsigned char* Pixels = nullptr - Pixels are optional. If specified, must be in a 32-bit format (ARGB, BGRA, ABGR, etc).
         * @param unsigned int Format = GL_BGRA - Format of the 32-bit layout. (ARGB, BGRA, ABGR, etc..) CANNOT be 24-bit formats.
         *
         ***********************************************/

        Texture(unsigned int Target, unsigned int Width, unsigned int Height, unsigned char* Pixels = nullptr, unsigned int Format = GL_BGRA);


        /********************************************//**
         * @brief Texture Destructor. Deletes a texture from video memory. Cleanup.
         ***********************************************/

        ~Texture();



        /********************************************//**
         * @brief Sets the pixels of the entire texture.
         *         Pixels must be Width * Height * 4 OR ((Width * 32 + 31) / 32) * 4 * Height.
         *
         * @param unsigned char* Pixels - Buffer containing the pixels to be set.
         * @return
         *
         ***********************************************/

        void SetPixels(unsigned char* Pixels);


        /********************************************//**
         * @brief Draws this texture to the back-buffer with glColor4ub(255, 255, 255, 255).
         *
         * @param X1 float - The X-coordinate of the upper-left corner of the rectangle in which to render this texture.
         * @param Y1 float - The Y-coordinate of the upper-left corner of the rectangle in which to render this texture.
         * @param X2 float - The X-coordinate of the lower-right corner of the rectangle in which to render this texture.
         * @param Y2 float - The Y-coordinate of the lower-right corner of the rectangle in which to render this texture.
         * @return void
         *
         ***********************************************/

        void Draw(float X1, float Y1, float X2, float Y2);


        /********************************************//**
         * @brief Returns the ID of the texture generated by this class.
         *
         * @return unsigned int - ID of the texture in video memory.
         *
         ***********************************************/

        unsigned int GetID() const {return ID;}


        /********************************************//**
         * @brief Returns the PixelFormat of the texture generated by this class. Always returns a 32-bit format.
         *
         * @return unsigned int - Pixel Format: GL_RGBA, GL_BGRA, etc..
         *
         ***********************************************/

        unsigned int GetPixelFormat() const {return Format;}


        /********************************************//**
         * @brief Returns the Width of this texture as specified upon creation.
         *
         * @return int
         *
         ***********************************************/

        int GetWidth() const {return Width;}


        /********************************************//**
         * @brief Returns the Height of this texture as specified upon creation.
         *
         * @return int
         *
         ***********************************************/

        int GetHeight() const {return Height;}


        /********************************************//**
         * @brief Returns the Target of this texture as specified upon creation. GL_TEXTURE_RECTANGLE OR GL_TEXTURE_2D
         *
         * @return unsigned int
         *
         ***********************************************/

        unsigned int GetTarget() const {return Target;}
    };




    /********************************************//**
    * @brief A class representing a Font in Graphics Memory (DeviceContext). Upon destruction, the font is deleted.
    ***********************************************/

    class Font
    {
    private:
        HDC DC;
        unsigned int Base;
        unsigned int Size;
        const char* Name;


        /********************************************//**
         * @brief Determines if two types are the exact same when decayed at compile time.
         *
         * @param T - Type to compare to.
         * @param U - Type that is decayed first and compared to T.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T, typename U>
        struct is_same_decay : public std::integral_constant<bool, std::is_same<T, typename std::decay<U>::type>::value> {};


        /********************************************//**
         * @brief Compares a type to a char, char*, or const char* when decayed at compile time.
         *
         * @param T - The type to decay and compare.
         * @return std::integral_constant<bool, true> if the types matched, std::integral_constant<bool, false> otherwise.
         *
         ***********************************************/

        template<typename T>
        struct is_char_type : public std::integral_constant<bool, is_same_decay<char, T>::value || is_same_decay<char*, T>::value || is_same_decay<const char*, T>::value> {};


        /********************************************//**
         * @brief Overrides std::to_string via ADL but only if the parameter is a char, char* or const char* when decayed.
         *
         * @param value T to be convert to a string. Must be a char, char* or const char* for this function to be triggered.
         * @return An STL string containing the contents of the parameter.
         *
         ***********************************************/

        template<typename T>
        std::string to_string(T value)
        {
            static_assert(is_char_type<T>::value, "Argument: Value Must be of literal type.");
            std::string Result;
            Result += value;
            return Result;
        }

    public:
        /********************************************//**
         * @brief Constructor for constructing a BitmapFont in video memory.
         *
         * @param Name const char* - Name of the font to be used. Arial, TimesNewRoman, etc..
         * @param DC HDC - Device Context in which to select the new font into.
         * @param Size unsigned int - Size of the font.
         *
         ***********************************************/

        Font(const char* Name, HDC DC, unsigned int Size);


        /********************************************//**
         * @brief Destructor deleted the font from video memory.
         ***********************************************/

        ~Font();



        /********************************************//**
         * @brief Variadic template version of PrintF for OpenGL. Draws a string in white.
         *
         * @param X float - X position on the screen where the top left of the string is to be drawn.
         * @param Y float - Y position on the screen where the top left of the string is to be drawn.
         * @param Text const char* - Text containing the string as well as the format if necessary.
         * @param args Args&&... - Variadic parameter pack containing arguments deduced by the format string if any.
         * @return void
         *
         * Draw(X, Y, "This is a non-formated string");
         * Draw(X, Y, "This is a formated string with % number(s), 1);
         *
         ***********************************************/

        template<typename... Args>
        void Draw(float X, float Y, const char* Text, Args&&... args);


        /********************************************//**
         * @brief Variadic template version of PrintF for OpenGL. Draws a string in any colour.
         *
         * @param X float - X position on the screen where the top left of the string is to be drawn.
         * @param Y float - Y position on the screen where the top left of the string is to be drawn.
         * @param R float - R component in the RGB model of the colour to be used. 0.0f <= R <= 1.0f.
         * @param G float - G component in the RGB model of the colour to be used. 0.0f <= G <= 1.0f.
         * @param B float - B component in the RGB model of the colour to be used. 0.0f <= B <= 1.0f.
         * @param Text const char* - Text containing the string as well as the format if necessary.
         * @param args Args&&... - Variadic parameter pack containing arguments deduced by the format string if any.
         * @return void
         *
         * Draw(X, Y, 0.5f, 0.5f, 0.5f, "This is a non-formated string");
         * Draw(X, Y, 1.0f, 0.0f, 0.0f, "This is a formated string with % number(s), 1);
         ***********************************************/

        template<typename... Args>
        void Draw(float X, float Y, float R, float G, float B, const char* Text, Args&&... args);
    };

    #endif // GRAPHICS_HXX_INCLUDED



    The documentation takes the longest and wastes the most time.. So all in all, I have NOT been working on animated textures or patching the current plugin. I've instead been getting rid of the old code and slowly replacing it with faster and better new code with proper documentation.. That includes the hooking API so that things will be EASIER for me to hook. Otherwise, there's not really a way for me to just shove in a new texture API without headaches..

    Also been trying to make it as cross-platform as I can.. The reason for the re-write is simply.. It's impossible to hook model vertices with the current code.. This is something I keep getting asked to implement.. With the new code-base, I can port most of my Direct-X code to OpenGL for model hooks (We'll see if it works).

    Things like this: https://github.com/Brandon-T/SRL-GLX...ore.simba#L981 NEEDS to be updated.. It was written when Lape was in its earliest release stage and it's extremely nasty. I don't think I even remember how it works -__-..
    If there is something I can do please tell me

  9. #209
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    I did not think of a solution yet but I am leaning on doing exactly that. I've been trying really HARD to keep the new code-base understandable for all and not just me.. Then I've been working on optimising & micro-optimising (because this is low level graphics) stuff but trying to keep it readable as well..
    Thanks for the great work, looking forward to the revamped source!

    I've read your tutorial https://villavu.com/forum/showthread.php?t=89645, now reading through the plugin source to learn more about hooking there's still plenty of things that i dont understand though....especially since my knowledge of c++ is only limited to http://greenteapress.com/thinkcpp/thinkCScpp.pdf lol

    https://github.com/Brandon-T/GLX/blo...ports.cpp#L236
    What's line 235-237 (and 250-252) for? The next 3 lines does the exact same thing except adding in a boolean comparison?
    Last edited by riwu; 02-08-2015 at 01:48 PM.

  10. #210
    Join Date
    Dec 2011
    Posts
    2,147
    Mentioned
    221 Post(s)
    Quoted
    1068 Post(s)

    Default

    Quote Originally Posted by PatriqDesigns View Post
    Well why dont you release what you have done to the community? Why wont you make a repo for it where all could contribute. That would be awesome, and would let OpenGL development be more "accepted" and used.
    Fear not
    I'm sure @riwu, like myself, has not released much OGL work to the community simply because it is so powerful in terms of profit potential, and the things he has likely made are not really public material (e.g. fishers, choppers, miners focused on XP not GP).

    However, the tutorial and library @Obscurity and I are working on will give everyone the tools to do these things themselves. As a result, your profits will be merit based, as I believe they should be. However, I do plan on releasing my dungeoneering script fully free and to the public when it is eventually finished (been forever I know!).

    I only release scripts when I am totally done using them for my own purposes, else I end up bringing in a ton of competition against myself, and nobody wants to do that. Idk about others' mentalities.

    So, with the OGL release I plan on releasing to higher boards some mid-level money makers like frost dragons, since I've stopped using them entirely in favor of higher level profit scripts (GWD, etc.)

    I'm sure Obscurity has similar plans.
    Last edited by Clarity; 02-09-2015 at 04:36 PM.

  11. #211
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    I don't plan on releasing ones like Tormented Demons or Ascension, but I'd be happy to give the Bandos/etc to members. :-).

    Also, sorry for ditching you last night, Clarity. My PC is in pieces in front of me here at work. Gonna take some fixing before I can get back online (phone ATM).




    Skype: obscuritySRL@outlook.com

  12. #212
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    @Brandon;
    Simba's memory usage is rising proportional to time running
    it got over 1GB after 20hr+ of running

    Are u already aware of this and is waiting for simba changes to fix it?
    https://github.com/MerlijnWajer/Simba/issues/340

  13. #213
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    @Brandon;
    Simba's memory usage is rising proportional to time running
    it got over 1GB after 20hr+ of running

    Are u already aware of this and is waiting for simba changes to fix it?
    https://github.com/MerlijnWajer/Simba/issues/340


    That request on Simba's github is just to make things easier and compatible with future plugins and doesn't have anything to do with the current plugin. It would be extremely nice of the Simba dev team to add it. It will make ANY plugin written in ANY language exponentially more powerful. Hence the reason why I made the request (which I normally never do and instead find work around's for)

    As for memory usage increasing, I'd check your script because the Simba plugin doesn't allocate a drop of raw memory. All it does is pass pointers to Simba and read and write data to the SMART plugin. It doesn't require any allocations at all.


    https://github.com/riwu/GLX/blob/mas...xports.cpp#L88


    For example, take the above function. If you notice, it takes a "size" variable as a reference/pointer. It will set this variable to the amount of models available from the client. This tells Simba how many models to read directly from memory (yes, Simba does all of the reading/writing as well). This way, the plugin doesn't have to allocate anything and instead, allocations are done in Simba itself via SetLength as shown below:

    https://github.com/Brandon-T/SRL-GLX...ore.simba#L170

    Simba Code:
    Function glGetTextures: glTextureArray;
    var
      Size, I: Cardinal;
      Ptr: Pointer;
    Begin
      Result := [];
      Ptr := GLXTextures(Size); //get a pointer to data from the plugin (directly from the Smart plugin).
      SetLength(Result, Size); //Allocate memory for the textures we're going to read (via Simba).

      For I := 0 To Size - 1 Do //read this many textures from the client.
      Begin
        Result[I] := glTexture(Ptr^); //cast the pointer to a texture.
        Ptr.Inc(sizeof(glTexture)); //move the pointer to the next texture.
      End;
    End;

    If you notice, all the plugin functions use SetLength on the Simba side and simply read the data into the memory allocated by Simba. This makes it impossible for the plugin to leak because it never allocated anything in the first place. I've purposely done this (made Simba do all the allocations via SetLength) so that I would not have to worry about anyone complaining about plugin leaks.

    In fact, if Simba could read from SharedMemory directly, the GLX.dll plugin would never exist (it only exists to give Simba a pointer to the shared memory block and synchronise communications via Event/Mutex). SmartRemote32 might not exist either or any other communication plugins.

    Though, I am curious as to what would raise your memory usage that high. It would only be possible to leak memory if you were to use AllocMem, GetMem or CreateBitmap and functions such as those. That's the ONLY way (other than constantly crashing and restarting the script thread.. in which case, add on terminate won't be called to free the one and only bitmap the plugin uses).


    However, do note that the include does not use such. It only uses CreateBitmap internal (for Smart's debug of course). I can't see a problem with that as only one bitmap is ever created per smart per script for the duration of the lifetime of the script entirely.

    The only way I can see you leaking is if you created a ton of your own bitmaps and freed none (which I doubt as well).

    Are you allocating raw memory in Simba anywhere? Are all your images freed?
    Last edited by Brandon; 02-25-2015 at 07:37 AM.
    I am Ggzz..
    Hackintosher

  14. #214
    Join Date
    Feb 2009
    Location
    Denmark.
    Posts
    359
    Mentioned
    12 Post(s)
    Quoted
    64 Post(s)

    Default

    @Brandon;
    I'm having some trouble installing your plugin.

    I really want this so i can use it with This.

    But i can not for the life of me, figure out which files to download and where to put them xD

    Could you help me out with this?

    Regards Semtex

  15. #215
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    On his GLX Github, click Releases, download OpenGL32 and GLX.dll to your plugin folder.




    Skype: obscuritySRL@outlook.com

  16. #216
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    ..
    Hey Brandon;
    There's something rather minor that puzzled me
    https://github.com/Brandon-T/SRL-GLX...ore.simba#L259
    Why do you have to start from address 1 then subtract 1 from the computed result? Isnt it the same as to just start calculation from address 0?
    Like PtrUInt(@(ptr_glTexture(nil)^.X));

  17. #217
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Hey Brandon;
    There's something rather minor that puzzled me
    https://github.com/Brandon-T/SRL-GLX...ore.simba#L259
    Why do you have to start from address 1 then subtract 1 from the computed result? Isnt it the same as to just start calculation from address 0?
    Like PtrUInt(@(ptr_glTexture(nil)^.X));

    I guess you don't have to add 1. I tested it in FPC and it works but for some reason in Pascal script it didn't unless I added 1 to nil.. but then it was off by 1 so I had to subtract 1 AFTER the cast. When it was written of course.

    At the time Dgby helped me write that macro on IRC because a direct translation from the C macro didn't work (without the +/-1. Seems to work in FPC though: http://ideone.com/gsFDGX

    There's a lot of things that were done that no longer needs to be done with the Lape updates over the years.
    Last edited by Brandon; 12-20-2015 at 05:06 PM.
    I am Ggzz..
    Hackintosher

  18. #218
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    ---
    Thanks for the explanation!

    Any idea why TextureID of glChar always changes every log in?

  19. #219
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Thanks for the explanation!

    Any idea why TextureID of glChar always changes every log in?
    It's generated by the game as with all texture ID's. I only happen to hash regular textures and not characters.
    I am Ggzz..
    Hackintosher

  20. #220
    Join Date
    Dec 2017
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I feel stupid for asking these kind of questions, but the whole reflection/OpenGL etc side of Botting is new to me.

Page 9 of 9 FirstFirst ... 789

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •