• Immutable Page
  • Info
  • Attachments

GLFragment

/**
 * Describes a texture modification fragment program
 * for a texture
 */
namespace GLFragment {

    class Storage;

    typedef unsigned int FunctionId;

    class PrivateFunctionData;
    class PrivateAttrib;

    class FunctionData {
        public:
            FunctionData ();
            ~FunctionData ();

            /**
             * Returns the status of this fragment program
             * (valid or invalid)
             */
            bool status ();

            void addTempHeaderOp (const char *name);

            void addParamHeaderOp (const char *name);

            void addAttribHeaderOp (const char *name);


            void addFetchOp (const char *dst, const char *offset, int target);

            void addColorOp (const char *dst, const char *src);

            void addDataOp (const char *str, ...);

            void addBlendOp (const char *str, ...);

            FunctionId createFragmentFunction (const char *name);

        private:
            PrivateFunctionData *priv;
    };

    class Attrib {
        public:
            Attrib (const GLWindowPaintAttrib &paint);
            Attrib (const Attrib&);
            ~Attrib ();

            Attrib &operator= (const Attrib &rhs);

            unsigned int allocTextureUnits (unsigned int nTexture);

            unsigned int allocParameters (unsigned int nParam);

            void addFunction (FunctionId function);

            bool enable (bool *blending);
            void disable ();

            unsigned short getSaturation ();
            unsigned short getBrightness ();
            unsigned short getOpacity ();

            void setSaturation (unsigned short);
            void setBrightness (unsigned short);
            void setOpacity (unsigned short);

            bool hasFunctions ();

        private:
            PrivateAttrib *priv;
    };

    void destroyFragmentFunction (FunctionId id);

    FunctionId getSaturateFragmentFunction (GLTexture *texture,
                                            int       param);
};

GLFragment Attribute

The GLFragment::Attrib class describes a set of common fragment operations on a window, implemented in the core of the opengl plugin to do with brightness, saturation and opacity. As such, it can be construted from a GLWindowPaintAttrib &. Opacity, Brightness and Saturation are thus controlled through the getters and setters in the class

Get

Set

getSaturation ()

setSaturation ()

getBrightness ()

setBrightness ()

getOpacity ()

setOpacity ()

/!\ A small detail to note here is that saturation is implemented both through an ARB fragment program and through fixed-function texture manipulation. As a plugin developer, you don't need to check which one is in use in most cases, however if you need to know for the sake of optimisation of your fragment program, then you can use GL::canDoSlightlySaturated and GL::canDoSlightlySaturated} to check.

Adding a simple fragment program for batch-time binding to the graphics processor can also be done through GLFragment::Attrib. Just use your generated GLFragment::FunctionId and pass it to GLFragment::addFunction ().

If you need to add extra texture units or parameters to the attribute, then you can use allocTextureUnits ()} and allocParameters () to do this.

For rendering purposes, you may also want to check if there are already fragment functiosn in the list of functions to be executed at fragment-time. To do this, use hasFunctions ()

Creating a new fragment function with GLFragment::FunctionData

The OpenGL plugin provides a simple interface for building fragment programs too. Tod do this, you can use the functons in this class (This documentation will be updated at a later data).

Development/zero-nine/OpenGLClasses/GLFragment (last edited 2010-10-17 02:59:09 by 58-7-165-35)