• Advertisement
Sign in to follow this  

Someone plz help..........problem with textures and shaders

This topic is 3175 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

hello friends , i am a newbie in opengl but i have given a difficult task of creating an ray cast application for which i need to pass 4- 5 textures to my glsl shaders. i have 2 issues ISSUE 1) when i pass textures to my shaders like this , i get the output image on my screen texture_locationTemp = glGetUniformLocation(p2, "temporarytexture"); glUniform1i(texture_locationTemp, 1); texture_locationVol = glGetUniformLocation(p2, "VolumeTexture"); glUniform1i(texture_locationVol, 2); texture_locationDir = glGetUniformLocation(p2, "Directiontexture"); glUniform1i(texture_locationDir,3); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, swapLogic[ 1- currentSurface]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_3D, Volumetex3d); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, texIDBack); But when i pass textures like this (Starting from location GL_TEXTURE0 instead of GL_TEXTURE1), i get the distored image. texture_locationTemp = glGetUniformLocation(p2, "temporarytexture"); glUniform1i(texture_locationTemp, 0); texture_locationVol = glGetUniformLocation(p2, "VolumeTexture"); glUniform1i(texture_locationVol, 1); texture_locationDir = glGetUniformLocation(p2, "Directiontexture"); glUniform1i(texture_locationDir,2); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, swapLogic[ 1- currentSurface]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_3D, Volumetex3d); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texIDBack); i am not able to understand this starange behavior , seems like GL_TEXTURE0 does not work. ISSUE 2) ISSUE 2 is related to issue 1) in the beginning before starting rendering ( before onpaint method), i m creating 7-8 2d textures and 1-2 3d textures which i will pass further to my shaders during final rendering step... and this code is executed only once during execution.. Gluint Volumetex3d = textureHandlerObj.Create3DTexture(path,rawdata); Gluint texIDEmptySpaceTexture = Create3DTextureEmptyScpaceTexture(); Gluint crop2dTex = Create2DTexture(viewPort.width,viewPort.height); Gluint texIDBack = Create2DTexture(viewPort.width,viewPort.height); Gluint texIDfront = Create2DTexture(viewPort.width,viewPort.height); ... .... the issue is that if i change the order of creation of these textures, the output on my screen changes.... for instance if i change the order to Gluint Volumetex3d = textureHandlerObj.Create3DTexture(path,rawdata); Gluint texIDEmptySpaceTexture = Create3DTextureEmptyScpaceTexture(); Gluint crop2dTex = Create2DTexture(viewPort.width,viewPort.height); Gluint texIDfront = Create2DTexture(viewPort.width,viewPort.height); Gluint texIDBack = Create2DTexture(viewPort.width,viewPort.height); now texidFront texture is created before textureIdBack texture..... code inside all this functions like similar to this ( using GL_TEXTURE_2D for 2d texture and GL_TEXTURE_3D for 3d texture)... GLuint img; glGenTextures(1, &img); glBindTexture(GL_TEXTURE_2D, img); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA, GL_FLOAT, data); i dont understand why order of creation of this textures effect my output.... what i think can be a bug is if i use the order no 1 then the the texture binded to GL_TEXTURE_2D after the end of the function is texIdfront but if i use order no 2 then it is texIdBack .. i think this binding switch is somewhere casuing the problem due to which these textures are not passed to shaders properly which cause the distortion. but i m not able to find out what i am missing and what i have to do to make it work for any order ( why it deopends upon order).... PLZ HELP ..

Share this post


Link to post
Share on other sites
Advertisement
i m an Idiot... unknowingly i have commented some of my code due to which i was getting the weird results...

this topic can be closed.... :)

Share this post


Link to post
Share on other sites
Quote:
Original post by divasg
this topic can be closed.... :)


Users close their topics themselves by prefixing the topic title with "[solved]" or "[closed]". Mods generally won't hard-close threads for several good reasons.

So, in your case, replace "Someone plz help..........problem with textures and shaders " with "[solved] Someone plz help..........problem with textures and shaders ".

And maybe next time, skip the "Someone plz help.........."-part and just write "problem with textures and shaders" ;)

Share this post


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

  • Advertisement