BackBufferToTex problem
BlitzMax Forums/MiniB3D Module/BackBufferToTex problem
| ||
Hi, I'm converting code from B3D and I've set up a shadow texture. Problem is that when 'copying' to the texture it gets flipped. I've traced the problem to glCopyTexImage2D which copies from the bottom left instead of the top left. Any solutions? Thanks Jim |
| ||
It's hacky but you could try scaling the mesh you're putting the texture on through itself. if your picture is upside down ScaleMesh(theTexturedMesh, 1, -1, 1); That should make the top of the mesh the bottom, and the bottom the top, essentially flipping the texture coords... or if you've found the problem in minib3d you could change it so it works the way you want... yay exposed source code. |
| ||
Hi ima747, didn't get your method to work. However instead of looking down on the scene I look up then things work. Jim |
| ||
glad you got it working. in retro spect I think you might need to flip mesh after you do the scale mesh to turn it right side out again, haven't tried it myself so dunno for sure. can you post your fix incase anyone else needs it some time? |
| ||
I think he is suggesting rotating the camera 180 degrees, which obviously isn't an ideal solution. This should be easy to fix, I'll take a look. I doubt that ScaleMesh/FlipMesh would work. |
| ||
Yes, just rotating 180 degrees and changing height of camera from above to below. Jim |
| ||
I found a way around this problem by doing:ScaleTexture texture,1.0,-1.0 |
| ||
Here is a fix for the normal texture in TTexture.bmx:Method BackBufferToTex(mipmap_no=0,frame=0) If flags&128=0 ' normal texture Local x=0,y=0 glBindtexture GL_TEXTURE_2D,gltex[frame] glCopyTexImage2D(GL_TEXTURE_2D,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Self.ScaleTexture(1.0,-1.0) 'Ked was here Else ' cubemap texture Local x=0,y=0 glBindtexture GL_TEXTURE_CUBE_MAP_EXT,gltex[0] Select cube_face Case 0 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Case 1 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Case 2 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Case 3 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Case 4 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) Case 5 glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y,mipmap_no,GL_RGBA8,x,TGlobal.height-y-height,width,height,0) End Select EndIf End Method If there is a problem with cubemap textures with this function also, then sticking in the "Self.ScaleTexture(1.0,-1.0)" should work too. I'm not 100% sure though. :) |
| ||
Hi Ked, that does work for me! Thanks Jim |