Getting A Classic Zelda View

Sage
Posts: 1,066
Joined: 2004.07
Post: #31
alright thanks.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #32
Ok. I'm having some more trouble. I have set up the projection as such:
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?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #33
Well, what are your modelview matrix and viewport?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #34
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();
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #35
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).
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #36
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:

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();
When I run it, I only see the red rectangle. Why is my triangle not there?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #37
Ah yes, forgot the disabling of the depth sorting.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  When to create custom OpenGL view instead of subclass NSOpenGL view Coyote 37 22,562 Oct 20, 2009 08:16 PM
Last Post: Coyote