feedback buffer problem

Member
Posts: 469
Joined: 2002.10
Post: #1
I'm using the feedback buffer to get tex coords from screen coords. It works fine except for the very first poly I draw in immediate mode. The tex coords I get back are mirrored across the seam where the two triangles meet in the middle of the quad. This only happens on the very first rect I draw in immediate mode in feedback rendermode. This doesn't happen with the polys I draw from coordarrays. I'm not sure what is happening because the problem doesn't occur after the first poly. I'm setting the render mode back to render, and then back to feedback between each set of polys so I can better keep track of the texture I'm working with and to keep my buffer small.

Does anyone know what's going on or how to fix?
[edit: I fixed it]

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 148
Joined: 2003.03
Post: #2
Do you call glFeedbackBuffer before you set the render mode to feedback? Not sure if it's relevant, but it's the most I can come up with without any code to look at.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #3
yes, I call glFeedbackBuffer before I set the rendermode.
[edit] here's my code:

Code:
int bufferSize = 1024;
    GLfloat feedBuffer[bufferSize];
    glFeedbackBuffer (bufferSize, GL_3D_COLOR_TEXTURE, feedBuffer);

while ( sprite = [sprts nextObject] ) {
        if ( [sprite visible] ) {
            
            (void) glRenderMode (GL_FEEDBACK);
            glEnable(GL_TEXTURE_2D);
            glBindTexture(GL_TEXTURE_2D, NULL);
            glBegin (GL_TRIANGLE_STRIP); {
                glVertex3d (width, 0, 0.0);         glTexCoord2f (1.0, 1.0);
                glVertex3d (width, height, 0.0);     glTexCoord2f (0.0, 0.0);
                glVertex3d (0, 0, 0.0);         glTexCoord2f (0.0, 1.0);
                glVertex3d (0, height, 0.0);         glTexCoord2f (1.0, 0.0);
            } glEnd();

            GLint size = glRenderMode (GL_RENDER);
GLfloat token;
            GLint count = size;
            while (count) {
                token = feedBuffer[size-count]; count--;
                if (token == GL_POLYGON_TOKEN) {
                    int polycount = feedBuffer[size-count]; count--;
from here I just get feedBuffer[size-count+7] and feedBuffer[size-count+8] to get the coordinates relative to the quad. As I said, this only messes up with the first immediate mode sprite I draw.

to see the weirdness in action, I've provided a build:
http://www.variableaspect.com/experiment...edback.sit

one of the big browse hands gets correct coords (the second one) while the first one gets the weird mirroring. I have the exact coords move around the screen in a text sprite (drawarrays doesn't seem to be affected) so you can see the weirdness.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #4
ok, just to show off my complete opengl newbness, my problem came from calling my vertexcoords BEFORE my texturecoords. I totally didn't know you couldn't do this.

um, also I noticed that for whatever reason, I'm trying to stick floats into int params; this wasn't causing problems, just bad programming.

anyhow, I changed my draw code to this:
Code:
glBegin (GL_TRIANGLE_STRIP); {
                glTexCoord2d (1, 0);        glVertex3d (width, 0, 0);
                glTexCoord2d (1, 1);        glVertex3d (width, height, 0);
                glTexCoord2d (0, 0);        glVertex3d (0, 0, 0);
                glTexCoord2d (0, 1);        glVertex3d (0, height, 0);
            } glEnd();

and now everything seems to be working ok. (crosses fingers and toes)Shock

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
Arent you supposed to push a name (0) onto the selection name stack in the beginning, before anything is drawn in selection mode?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
Why? Only the top name in the stack is used for anything... The usual usage is simply to call glLoadName for each object, with a different id each time.
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #7
You are supposed to do one push to "prime" the stack before you can start using it in selection mode, according to the red book.
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #8
Feedbackbuffer != SelectionBuffer.

feedback
select

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #9
Quote:Originally posted by kelvin
Feedbackbuffer != SelectionBuffer.

feedback
select


sorry, wasn't thinking.
Quote this message in a reply
Post Reply