Posted December 28, 201311 yr Hi all. I'm testing some ideas i have for a mod. I created a block, assigned a custom renderer for it and it all works. Then, i created a FBO (Frame Buffer Object) and did some code for rendering to it. When i assigned the FBO texture to the custom renderer, it only renders the background but not the quad i'm drawing. Here´s some of the code: https://gist.github.com/anonymous/8154703 And here is a video of this code in action: PD: it actually is a block, not a square in the center of the screen, thanks perspective.
December 28, 201311 yr Hi Is there some way you can "inspect" your FBO to make sure it contains the correct texture? Apart from that - Although I don't know much about OpenGL, I'm suspicious of this bit in renderBlock glBegin(GL_QUADS); glVertex3f(1f, 0f, 0f); glVertex3f(0f, 0f, 0f); glVertex3f(0f, 1f, 0f); glVertex3f(1f, 1f, 0f); glEnd(); How does OpenGL know that you want to map your entire FBO texture to the size of the quad? i.e. when using the Tessellator you need to tell it both [x,y,z] and [u,v]. http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html -TGG
December 28, 201311 yr Author I edited my code so now it looks like glColor3f(1f, 1f, 1f); glBegin(GL_QUADS); glTexCoord2f(0f, 0f); glVertex3f(1f, 0f, 0f); glTexCoord2f(1f, 0f); glVertex3f(0f, 0f, 0f); glTexCoord2f(1f, 1f); glVertex3f(0f, 1f, 0f); glTexCoord2f(0f, 1f); glVertex3f(1f, 1f, 0f); glEnd(); but i get the same results. I've also tried with Tessellator.addVertexWithUV() and Tessellator.setTranslation() but with weird results: GUI shifted, slimes flying and my block isnt rendering I'm sure it contains the correct texture, because the background is cleared in a rainbow, but over that rainbow there should be a yellow rectangle: glColor4f(1f, 1f, 0, 0f); glBegin(GL_QUADS); glVertex3f(0.8f, 0.2f, 1f); glVertex3f(0.2f, 0.2f, 1f); glVertex3f(0.2f, 0.8f, 1f); glVertex3f(0.8f, 0.8f, 1f); glEnd();
December 28, 201311 yr Hi I think it would be worthwhile to try and split the possible causes into two: (1) your FBO texture is wrong (your background is obviously correct but maybe the yellow rect isn't) vs (2) your renderBlock code isn't properly mapping the entire FBO texture to the rect that you're drawing. If you can somehow manually inspect the FBO texture that would be the most direct way, but perhaps you could also test it by drawing the yellow rect over the entire FBO, to see if your rendered rect changes to yellow (i.e. the entire rect is being textured with just one texel). Perhaps there's something subtle going on with alpha or depth values? Can't really be of much help unfortunately, I haven't got much idea about OpenGL. -TGG
December 28, 201311 yr Author Ok, its solver. I just changed almost everything and magically it works. Thanks
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.