How would i draw a square in 2d?
I just want to draw a square with 2d verticies, not x,y and z, just x and y. How would i go about doing so?
try this...
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(1, 0);
glVertex2f(1, 1);
glVertex2f(0, 1);
glEnd();
Dave007
dave007@volny.cz
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(1, 0);
glVertex2f(1, 1);
glVertex2f(0, 1);
glEnd();
Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
First setup and orthographic projection matrix. You only need to do this once, then you can use glPushMatrix and glPopMatrix or glGet and glLoadMatrix to change project matricies.
Then you can simply use glVertex2i to pick whatever pixel position you want.
[Resist Windows XP''s Invasive Production Activation Technology!]
|
Then you can simply use glVertex2i to pick whatever pixel position you want.
[Resist Windows XP''s Invasive Production Activation Technology!]
Well, there are no errors, but the box doesnt show up. I just used the glVertex2i(x,y); commands after the code you gave me. Do i have to do somethign else?
Most likely the problem is that you''re not doing the vertices in a counterclockwise order. Or you can disable culling: glDisable(GL_CULL_FACE).
[Resist Windows XP''s Invasive Production Activation Technology!]
[Resist Windows XP''s Invasive Production Activation Technology!]
try positioning the square at (0,0) and make the width at least more than 10 so that you can see it..
you''re probably doing something like so:
glVertex2i(0,0)
glVertex2i(1,0)
glVertex2i(1,1)
glVertex2i(0,1)
this make the quad 1 pixel wide! Quite hard to see...
you''re probably doing something like so:
glVertex2i(0,0)
glVertex2i(1,0)
glVertex2i(1,1)
glVertex2i(0,1)
this make the quad 1 pixel wide! Quite hard to see...
I think that in ortho mode you still have to go:
glTranslatef(0.0f, 0.0f, -1.0f);
You can put any negative value in the 3rd param.
Open mouth, insert foot
glTranslatef(0.0f, 0.0f, -1.0f);
You can put any negative value in the 3rd param.
Open mouth, insert foot
No, well, at least, you shouldn''t have to. The near is -1.0, which is behind the default 0.0.
[Resist Windows XP''s Invasive Production Activation Technology!]
[Resist Windows XP''s Invasive Production Activation Technology!]
Well, i got it to work, BUT!, It will only draw in black only if GL_BLEND is disabled, so how come it wont draw in color even though i set it to white?
I'm trying to draw a box behind some text, i eventually want to texture the box. Thats what i'm trying to accomplish here
Edited by - _titan_ on September 15, 2001 12:25:32 AM
I'm trying to draw a box behind some text, i eventually want to texture the box. Thats what i'm trying to accomplish here
Edited by - _titan_ on September 15, 2001 12:25:32 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement