Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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();

Posted

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

 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.