Click here to Skip to main content
15,997,402 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created an opengl texture , now i need to chnage its brightness and contrast how to do it.

What I have tried:

I tried gltexparameter but no use
Posted
Updated 19-Apr-16 21:21pm
Comments
KarstenK 12-Apr-16 8:10am    
The question is unclear, but check: you must recommit the texture to the OpenGL and redraw it.
Member 10536430 20-Apr-16 3:21am    
i got the solution by using glcolor4f with different slider values

1 solution

C#
GLuint glTexture ; 

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glEnable( GL_TEXTURE_2D );
 //   glEnable(GL_BLEND);
 //   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 //   glEnable(GL_ALPHA_TEST);
 //   glAlphaFunc(GL_GREATER,0.01);
    //glEnable (GL_LIGHTING); //enable the lighting
    //glEnable (GL_LIGHT0); //enable LIGHT0, our Diffuse Light
    //glEnable (GL_LIGHT1); //enable LIGHT1, our Ambient Light
    //glShadeModel (GL_SMOOTH); //set the shader to smooth shader
    glEnable(GL_COLOR_MATERIAL);
    glGenTextures( 1, &glTexture );
    glBindTexture( GL_TEXTURE_2D, glTexture );
    glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );    // Select modulate to mix texture with color for shading
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );   // When texture area is small, bilinear filter the closest mipmap
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );        // When texture area is large, bilinear filter the original
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );       // The texture wraps over at the edges (repeat)
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
    glColor4f( float( ( float )g_nRedSlider / 10 ), float( ( float )g_nGreenSlider/ 10 ), float( ( float )g_nBlueSlider / 10 ), float( ( float )g_nAlphaSlider / 10 ));
    glTexImage2D( GL_TEXTURE_2D, 0, GL_INTENSITY, WIDTH, HEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_pbyImageData ); 
    glEnable( GL_TEXTURE_2D );
    glBindTexture( GL_TEXTURE_2D, glTexture );
    glBegin( GL_QUADS );
    glTexCoord2d( 0.0,0.0 ); 
    glVertex2f( -0.8f, -0.8f ); 
    glTexCoord2d( 1.0,0.0 );
    glVertex2f( 0.8f, -0.8f );
    glTexCoord2d( 1.0,1.0 );
    glVertex2f( 0.8f,  0.8f );
    glTexCoord2d( 0.0,1.0 );
    glVertex2f( -0.8f,  0.8f );
    glEnd();
    SwapBuffers( m_hDeviceContextDC );
    glDisable( GL_TEXTURE_2D );
    glDisable( GL_COLOR_MATERIAL );
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900