Results 1 to 6 of 6

Thread: GlQuad - strange behaviour

  1. #1
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45

    GlQuad - strange behaviour

    Hey all, long time no gl fail, but this one is beyond me so I figured I'd ask some more knowledgeable people on the Gl topic, I checked my gl code over and over again but no luck... Go help us all if I'm doing something crucial wrong when rendering a quad

    Here is the quad code:
    Code:
    procedure Image.RenderQuad(TextureArrayX: tRealArray1x2; TextureArrayY: tRealArray1x2; ScreenArrayX: tInt64Array1x2; ScreenArrayY: tInt64Array1x2);
    begin        
        glBegin(GL_QUADS);
            glTexCoord2f(TextureArrayX[1], TextureArrayY[1]);
            glVertex3f(ScreenArrayX[1], ScreenArrayY[1], 0);
            writeln('TX [',TextureArrayX[1], '.', TextureArrayY[1],'] SX [',ScreenArrayX[1],'.',ScreenArrayY[1],']');
            
            glTexCoord2f(TextureArrayX[2], TextureArrayY[1]);
            glVertex3f(ScreenArrayX[2], ScreenArrayY[1], 0);
            writeln('TX [',TextureArrayX[2], '.', TextureArrayY[1],'] SX [',ScreenArrayX[2],'.',ScreenArrayY[1],']');
            
            glTexCoord2f(TextureArrayX[1], TextureArrayY[2]);
            glVertex3f(ScreenArrayX[1], ScreenArrayY[2], 0);
            writeln('TX [',TextureArrayX[1], '.', TextureArrayY[2],'] SX [',ScreenArrayX[1],'.',ScreenArrayY[2],']');
            
            glTexCoord2f(TextureArrayX[2], TextureArrayY[2]);
            glVertex3f(ScreenArrayX[2], ScreenArrayY[2], 0);
            writeln('TX [',TextureArrayX[2], '.', TextureArrayY[2],'] SX [',ScreenArrayX[2],'.',ScreenArrayY[2],']');
            
            readln();
        glEnd;
    end;
    where the values written to the screen are
    Code:
    TX [ 0.00000000000000E+000. 0.00000000000000E+000] SX [125.125]
    TX [ 1.00000000000000E+000. 0.00000000000000E+000] SX [225.125]
    TX [ 0.00000000000000E+000. 1.00000000000000E+000] SX [125.225]
    TX [ 1.00000000000000E+000. 1.00000000000000E+000] SX [225.225]
    Note that I am using a scale factor of 2 on noth the X and Y - all of this seems to work normally, but now for the screen shot where everything escapes me:
    Weird Gl Quad.png

    Why does it have that slice missing out of it? I cant for the life of me figure this one out - what I did come to a conclusion of though was that it was either something very simple and idiotic or something beyond what I was looking for...

    Thanks,
    code
    Last edited by code_glitch; 08-10-2011 at 01:29 PM. Reason: Typo. Cold hands...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  2. #2
    I think your vertex coordinates are wrong. To be sure, turn on wireframes. (glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); )

  3. #3
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Ah, I think I may have inverted something in those co-ords... I'm getting the loading icon from a windows xp machine:

    GlQuad Mexh Mode.png

    Edit: Scratch tha, inverting the X values on the glVertex3f moves the missing triangl to the other side... Tweak time.

    Edit 2: And inverting the X values sent to gltexcoord helps none either...
    Last edited by code_glitch; 08-10-2011 at 04:43 PM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    All fixed up... I don't know why but copy pasting a similar procedure from some other code of mine worked - even though it is literally (as far as I can see), exactly the same!

    Now reads
    Code:
    procedure Image.RenderQuad(VxR, VyR: tRealArray1x2; PxR, PyR: tInt64Array1x2);
    begin        
        glBegin( GL_QUADS );
            glTexCoord2f( VxR[1], VyR[1] );
            glVertex3f( PxR[1], PyR[1], 0. );
    
            glTexCoord2f( VxR[2], VyR[1] );
            glVertex3f( PxR[2], PyR[1], 0. );
    
            glTexCoord2f( VxR[2], VyR[2] );
            glVertex3f( PxR[2], PyR[2], 0. );
    
            glTexCoord2f( VxR[1], VyR[2] );
            glVertex3f( PxR[1], PyR[2], 0. );
        glEnd();
    end;
    If anyone feels like a hero, please do tell if you see any differences...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    It's the X and Y index pairs.
    1-1
    2-1
    2-2
    1-2

    versus the crossed bug version

    1-1
    2-1
    1-2
    2-2

  6. #6
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Ah thanks, I figured it might be something idiotic... Well, all resolved
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •