Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualBrother Bob

Posted 22 July 2013 - 12:24 PM

This is how I do it. 

//----------------------------

 

//==================================================================================_GLOBAL_VARIABLES

GLfloat rubber_COLOR[] = { 1.0, 1.0, 1.0, 1.0};

GLuint   UNIFORM_rubber_COLOR; 

//==================================================================================_GLOBAL_VARIABLES

 

//==================================================================================_INIT

  rubber_SHADER_FRAGMENT = glCreateShader(GL_FRAGMENT_SHADER);  

  glShaderSource(rubber_SHADER_FRAGMENT, 1, &fragmentSource_rubber, NULL);     glCompileShader(rubber_SHADER_FRAGMENT);       //------------------------------------------------     glAttachShader(rubber_SHADER, rubber_SHADER_VERTEX);     glAttachShader(rubber_SHADER, rubber_SHADER_FRAGMENT);     //------------------------------------------------     glBindAttribLocation(rubber_SHADER,   0, "position");     glBindAttribLocation(rubber_SHADER,   1, "normal");       glBindAttribLocation(rubber_SHADER,   2, "texture");       //------------------------------------------------     glLinkProgram(rubber_SHADER);

 

  UNIFORM_rubber_COLOR = glGetUniformLocation(rubber_SHADER,   "color"); //This last part 'color' is how you access the variable in the shader

//==================================================================================_INIT_

 

//==================================================================================_FRAGMENT_SHADER

 uniform highp vec4  color;  

 

    void main()       {           gl_FragColor   =  color;         }

//===================================================================================_FRAGMENT_SHADER

 

//===================================================================================_RENDER

rubber_COLOR[3] -= fadeAlpha;

 

glUseProgram(rubber_SHADER);

 

 glUniform4f(UNIFORM_rubber_COLOR,  rubber_COLOR[0], rubber_COLOR[1], rubber_COLOR[2], rubber_COLOR[3]); 

 

//drawCall goes here

//====================================================================================_RENDER


#3marcClintDion

Posted 22 July 2013 - 03:21 AM

There is far too much arrogance and out right abuse by site moderators, they are teaching other people to behave this way.  The posts I've made will all be shorty removed and replaced with this notice.  Game development is not the only thing being taught here, bad behavior is being taught as well.


#2marcClintDion

Posted 16 June 2013 - 03:11 PM

This is how I do it. 

//----------------------------

 

//==================================================================================_GLOBAL_VARIABLES

GLfloat     rubber_COLOR[] = { 1.0, 1.0, 1.0, 1.0};

GLuint      UNIFORM_rubber_COLOR; 

//==================================================================================_GLOBAL_VARIABLES

 

//==================================================================================_INIT

      rubber_SHADER_FRAGMENT = glCreateShader(GL_FRAGMENT_SHADER);                                                                                     

      glShaderSource(rubber_SHADER_FRAGMENT, 1, &fragmentSource_rubber, NULL);                                                                          
      glCompileShader(rubber_SHADER_FRAGMENT);                                                                                                         
      //------------------------------------------------                                                                                              
      glAttachShader(rubber_SHADER, rubber_SHADER_VERTEX);                                                                                              
      glAttachShader(rubber_SHADER, rubber_SHADER_FRAGMENT);                                                                                            
      //------------------------------------------------                                                                                              
      glBindAttribLocation(rubber_SHADER,    0, "position");                                                                                            
      glBindAttribLocation(rubber_SHADER,    1, "normal");       
      glBindAttribLocation(rubber_SHADER,    2, "texture");                                                                                           
      //------------------------------------------------                                                                                              
      glLinkProgram(rubber_SHADER);

 

      UNIFORM_rubber_COLOR             = glGetUniformLocation(rubber_SHADER,      "color");       //This last part 'color' is how you access the variable in the shader

//==================================================================================_INIT_

 

//==================================================================================_FRAGMENT_SHADER

 uniform highp vec4  color;                                                   

 

           void main()                                                                                                                                       
           {                                                                                                                                                          

                gl_FragColor              =  color;                                    

           }

//===================================================================================_FRAGMENT_SHADER

 

//===================================================================================_RENDER

rubber_COLOR[3] -= fadeAlpha;

 

glUseProgram(rubber_SHADER);

 

 glUniform4f(UNIFORM_rubber_COLOR,  rubber_COLOR[0], rubber_COLOR[1], rubber_COLOR[2], rubber_COLOR[3]); 

 

//drawCall goes here

//====================================================================================_RENDER


#1marcClintDion

Posted 16 June 2013 - 03:11 PM

This is how I do it. 

//----------------------------

 

//==================================================================================_GLOBAL_VARIABLES

GLfloat     rubber_COLOR[] = { 1.0, 1.0, 1.0, 1.0};

GLuint      UNIFORM_rubber_COLOR; 

//==================================================================================_GLOBAL_VARIABLES

 

//==================================================================================_INIT

   

     

      rubber_SHADER_FRAGMENT = glCreateShader(GL_FRAGMENT_SHADER);                                                                                     
      glShaderSource(rubber_SHADER_FRAGMENT, 1, &fragmentSource_rubber, NULL);                                                                          
      glCompileShader(rubber_SHADER_FRAGMENT);                                                                                                         
      //------------------------------------------------                                                                                              
      glAttachShader(rubber_SHADER, rubber_SHADER_VERTEX);                                                                                              
      glAttachShader(rubber_SHADER, rubber_SHADER_FRAGMENT);                                                                                            
      //------------------------------------------------                                                                                              
      glBindAttribLocation(rubber_SHADER,    0, "position");                                                                                            
      glBindAttribLocation(rubber_SHADER,    1, "normal");       
      glBindAttribLocation(rubber_SHADER,    2, "texture");                                                                                           
      //------------------------------------------------                                                                                              
      glLinkProgram(rubber_SHADER);

 

      UNIFORM_rubber_COLOR             = glGetUniformLocation(rubber_SHADER,      "color");       //This last part 'color' is how you access the variable in the shader

//==================================================================================_INIT_

 

//==================================================================================_FRAGMENT_SHADER

 uniform highp vec4  color;                                                   

 

           void main()                                                                                                                                       
           {                                                                                                                                                          

                gl_FragColor              =  color;                                    

           }

//===================================================================================_FRAGMENT_SHADER

 

//===================================================================================_RENDER

rubber_COLOR[3] -= fadeAlpha;

 

glUseProgram(rubber_SHADER);

 

 glUniform4f(UNIFORM_rubber_COLOR,  rubber_COLOR[0], rubber_COLOR[1], rubber_COLOR[2], rubber_COLOR[3]); 

 

//drawCall goes here

//====================================================================================_RENDER


PARTNERS