Click here to Skip to main content
11,928,078 members (42,490 online)
Rate this:
Please Sign up or sign in to vote.
See more: OpenGL QT
I am new user of OpenGl Shader. I'm creating a shader for brightness and I am done with creation of shader. I also draw the image on QGlWidget but after that I'm not able to apply gl_fragColor value to Image.

Please have a Look at my code and let me know how to use gl_FragColor value while updating the image in paintGL() function.
void GLWidget::initializeGL()
//***************Shader for Brightness************************//
QGLShader *vshader1 = new QGLShader(QGLShader::Vertex, this);
const char *vsrc1 =
"varying mediump vec4 Alpha;"
"void main(void)\n"
"vec3 col = vec3(0.40, 1.0, 0.0);"
"Alpha = vec4(col * 0.2 + col * 0.8 * 0.45, 1.0);"
"Alpha = clamp(Alpha, 0.0, 1.0);"
"gl_Position = Alpha;"
bool b1 = vshader1->compileSourceCode(vsrc1);
QGLShader *fshader1 = new QGLShader(QGLShader::Fragment, this);
const char *fsrc1 =
"varying mediump float Alpha;"
"void main (void)"
"gl_FragColor = gl_Color * Alpha;"
bool bl = fshader1->compileSourceCode(fsrc1);
bool addS = program1.addShader(fshader1);
bool addS1 = program1.addShader(vshader1);
bool link =;

Could someone please help me? Its urgent..

Posted 12-Oct-10 0:26am
Edited 13-Oct-10 0:57am
pmgpm 6-Jun-14 4:11am
Did u get the solution for this ?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | Last Updated 13 Oct 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100