PDA

View Full Version : GlQuad - strange behaviour



code_glitch
08-10-2011, 01:22 PM
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 :o

Here is the quad 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


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:
620

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

Traveler
08-10-2011, 04:06 PM
I think your vertex coordinates are wrong. To be sure, turn on wireframes. (glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); )

code_glitch
08-10-2011, 04:39 PM
Ah, I think I may have inverted something in those co-ords... I'm getting the loading icon from a windows xp machine:

621

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...

code_glitch
08-10-2011, 05:47 PM
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


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...

User137
08-10-2011, 07:06 PM
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

code_glitch
09-10-2011, 10:13 AM
Ah thanks, I figured it might be something idiotic... Well, all resolved :)