Getting A Classic Zelda View
alright thanks.
Ok. I'm having some more trouble. I have set up the projection as such:
Yet when I start a quad at (0,0) it places it in the middle of the screen instead of the top left corner. Is there something I'm missing?
Code:
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluOrtho2D(0,width,height,0);
Yet when I start a quad at (0,0) it places it in the middle of the screen instead of the top left corner. Is there something I'm missing?
Well, what are your modelview matrix and viewport?
Code:
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluOrtho2D(0,width,height,0);
glViewport(0,0,width,height); // Make our viewport the whole window
// We could make the view smaller inside
// Our window if we wanted too.
// The glViewport takes (x, y, width, height)
// This basically means, what our our drawing boundries
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
I think I did the modelview wrong.
Here's what I'm trying to draw.
Code:
glBegin(GL_QUADS);
glColor3ub(255,0,0);
glVertex2f(0,0);
glVertex2f(10,0);
glVertex2f(10,10);
glVertex2f(0,10);
glEnd();
glBegin(GL_TRIANGLES);
glColor4ub(0,0,255,200);
glVertex2f(2,2);
glVertex2f(4,4);
glVertex2f(0,4);
glEnd();
I'm not sure how I did it, but it's working fine now. Thanks for all the help I've gotten up to now. I'll post again if I need more advice. I think my problem was defining the viewport AFTER the projection matrix because that's all I did (move it above the projection and modelview matrices).
I'm trying to play with the alpha channel right now and running into trouble. I'm trying to draw a red rectangle with a blue semi-transparent triangle over half of it. Here's my code:
When I run it, I only see the red rectangle. Why is my triangle not there?
Code:
glBegin(GL_QUADS);
glColor3ub(255,0,0);
glVertex2f(0,0);
glVertex2f(20,0);
glVertex2f(20,50);
glVertex2f(0,50);
glEnd();
glBegin(GL_TRIANGLES);
glColor4ub(0,0,255,100);
glVertex2f(0,0);
glVertex2f(20,50);
glVertex2f(0,50);
glEnd();
Ah yes, forgot the disabling of the depth sorting.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
When to create custom OpenGL view instead of subclass NSOpenGL view | Coyote | 37 | 44,915 |
Oct 20, 2009 08:16 PM Last Post: Coyote |