[SOLVED] FBObject Orientation/Scaling Issues

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[SOLVED] FBObject Orientation/Scaling Issues

bgroenks96
This post was updated on .
Hi

I'm trying to get a simple drawing routine to work using FBObject.

I'm basically just doing: draw quad to FBO -> draw FBO to screen

The goal is to have a quad drawn at (0,  0) with size 200x200 pixels.  I'm using immediate mode at the moment for testing purposes:

in GLAutoDrawable.reshape:

                fbo.reset(gl, width, height, glWin.getChosenGLCapabilities().getNumSamples(), true);
                fbo.attachTexture2D(gl, 0, true);
                fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 32);
                fbo.syncSamplingSink(gl);

in GLAutoDrawable.display:

                gl.glClear(GL.GL_COLOR_BUFFER_BIT);
               
                fbo.bind(gl);

                handle.setViewport(0, 0, wt, ht, 1); // sets glOrtho(x, x+width, y, y+height, 0, 1)
                gl.glColor3f(1,0,0);
                gl.glBegin(GL2.GL_QUADS);
                gl.glVertex2f(0, 0);
                gl.glVertex2f(0, 200);
                gl.glVertex2f(200, 200);
                gl.glVertex2f(200, 0);
                gl.glEnd();
               
                fbo.syncSamplingSink(gl);
               
                final TextureAttachment tex0 = (TextureAttachment) fbo.getColorbuffer(0);
                gl.glActiveTexture(GL2.GL_TEXTURE0);
                gl.glEnable(GL2.GL_TEXTURE_2D);
                fbo.use(gl, tex0);
                gl.glBegin(GL2.GL_QUADS);
                gl.glVertex2f(0, 0);    gl.glTexCoord2f(0, 0);
                gl.glVertex2f(0, ht); gl.glTexCoord2f(0, 1);
                gl.glVertex2f(wt, ht); gl.glTexCoord2f(1, 1);
                gl.glVertex2f(wt, 0); gl.glTexCoord2f(1, 0);
                gl.glEnd();
                fbo.unuse(gl);

This results in a rectangular (not square as expected) quad drawn in the upper left hand corner, stretched along the X axis.

I'm guessing I'm missing something rather trivial here... but I haven't used FBObject before, so I'm not really sure what.

Any help would be greatly appreciated, as always.
Reply | Threaded
Open this post in threaded view
|

Re: FBObject Orientation/Scaling Issues

bgroenks96
In this case, the problem was nothing more than that the glTexCoord calls have to be BEFORE the glVertex calls.  Stupid FFP caveat that's easy to forget since most of us probably aren't used to dealing with it anymore.

                gl.glBegin(GL2.GL_QUADS);
                gl.glTexCoord2f(0, 0);
                gl.glVertex2f(0, 0);
                gl.glTexCoord2f(0, 1);
                gl.glVertex2f(0, ht);
                gl.glTexCoord2f(1, 1);
                gl.glVertex2f(wt, ht);
                gl.glTexCoord2f(1, 0);
                gl.glVertex2f(wt, 0);
                gl.glEnd();
Reply | Threaded
Open this post in threaded view
|

Re: FBObject Orientation/Scaling Issues

gouessej
Administrator
In the worst case, I use glArrayElement but I prefer vertex arrays and VBOs of course. You could use com.jogamp.opengl.util.ImmModeSink too.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: FBObject Orientation/Scaling Issues

bgroenks96
I was only using it as a quickly thrown together test for the FBO.  Now everything is working, except I can't get the shaders to write to the FBO colorbuffer.  But that's a question for another topic I suppose :)


On Sun, Feb 9, 2014 at 4:23 AM, gouessej [via jogamp] <[hidden email]> wrote:
In the worst case, I use glArrayElement but I prefer vertex arrays and VBOs of course. You could use com.jogamp.opengl.util.ImmModeSink too.


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/SOLVED-FBObject-Orientation-Scaling-Issues-tp4031228p4031515.html
To unsubscribe from [SOLVED] FBObject Orientation/Scaling Issues, click here.
NAML



--

Brian Groenke
[hidden email]