Jump to content
  • Advertisement
Sign in to follow this  


This topic is 4249 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a few beginners questions!! But first let me show you some code snipet the following code exists in the void COpenGLCanvas::paintGL() method where i am doing some drawings.......... ....... ....... ....... glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbColor); glClearColor(1, 1, 1, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLuint sh = shDVR; glUseProgram(sh); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, volume.txVolume); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glUniform1i(glGetUniformLocation(sh, "txVolume"), 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, txTf); glUniform1i(glGetUniformLocation(sh, "txTf"), 1); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, txNoise); glUniform1i(glGetUniformLocation(sh, "txNoise"), 2); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, txDepth0); glUniform1i(glGetUniformLocation(sh, "txDepth0"), 3); glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, txDepth1); glUniform1i(glGetUniformLocation(sh, "txDepth1"), 4); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, peel % 2 ? txDepth4 : txDepth2); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); glUniform1i(glGetUniformLocation(sh, "txDepth2"), 5); glActiveTexture(GL_TEXTURE6); glBindTexture(GL_TEXTURE_2D, peel % 2 ? txDepth5 : txDepth3); glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); glUniform1i(glGetUniformLocation(sh, "txDepth3"), 6); glActiveTexture(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D, txColor2); glUniform1i(glGetUniformLocation(sh, "txGradient"), 7); glUniform1f(glGetUniformLocation(sh, "zn"), zNear); glUniform1f(glGetUniformLocation(sh, "zf"), zFar); glUniform2f(glGetUniformLocation(sh, "contrast"), contrast.x, contrast.y); glUniform1f(glGetUniformLocation(sh, "minIntensity"), minIntensity); glUniform3f(glGetUniformLocation(sh, "extent"), modelScale.x, modelScale.y, modelScale.z); glUniform1f(glGetUniformLocation(sh, "stepSize"), stepSize); glUniform1i(glGetUniformLocation(sh, "rayDistort"), rayDistort); glUniform1i(glGetUniformLocation(sh, "layer"), layer); glUniform1i(glGetUniformLocation(sh, "maxSamples"), maxSamples); glUniform1f(glGetUniformLocation(sh, "gilThickness"), impreglayerSize); glUniform1i(glGetUniformLocation(sh, "gGThickness"), gGThickness); glBegin(GL_QUADS); glVertex2f(-1, -1); glVertex2f(-1, 1); glVertex2f( 1, 1); glVertex2f( 1, -1); glEnd(); // render image to screen glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0, 0, width(), height()); glUseProgram(0); glClearColor(1, 1, 1, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, txColor0); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-1, -1); glTexCoord2f(0, 1); glVertex2f(-1, 1); glTexCoord2f(1, 1); glVertex2f( 1, 1); glTexCoord2f(1, 0); glVertex2f( 1, -1); glEnd(); ...... ...... ...... this is the code that i recieved from some one and have to make some changes in that. Q1: is my following observations right? "The program makes a frame buffer and passes it to a shader along with many other uniform variables. That shader writes output onto the framebuffer called fbColor. call to 'glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);' prints that output onto the screen. the 'gl_FragColor' statement in the fragment shader in fact writes to the frame buffer and not directly to the fragment!!" Q2 :) My job is to add a second shader here. The idea of my program goes on like this -> The current output from the shader (already implemented) should go to the frame buffer (which i suppose is happening) and that frame buffer should be used as input into a new shader. That new shader modifies the frame buffer somehow and then the updated frame buffer should be displayed. How can I achieve this? how would i access the current frame buffer in the new shader that i will write? do i have to bind all the uniform variables to the new shader as well? how can the new shader be called immediately after the first has finished? is there some quick and simple example or tutorial out on the web?? :( thanks in advance :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!