map coordinates 1:1 to pixels
This commit is contained in:
parent
193a23e682
commit
51b8e2109f
19
sdl_tmplt.c
19
sdl_tmplt.c
@ -14,20 +14,27 @@ void init(void)
|
|||||||
glViewport(0, 0, WIDTH, HEIGHT);
|
glViewport(0, 0, WIDTH, HEIGHT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(60.0, (GLfloat)WIDTH/(GLfloat)WIDTH, 1.0, 30.0);
|
glOrtho(-0.5, WIDTH - 0.5, -0.5, HEIGHT - 0.5, -1, 1);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.0, 0.0, -3.6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(SDL_Window * window)
|
void display(SDL_Window * window)
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glColor3f(1, 1, 1);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex3f(-2.0, -1.0, 0.0);
|
glVertex3f(10, HEIGHT / 2, 0.0);
|
||||||
glVertex3f(-2.0, 1.0, 0.0);
|
glVertex3f(10, 3 * HEIGHT / 4, 0.0);
|
||||||
glVertex3f(0.0, 1.0, 0.0);
|
glVertex3f(WIDTH / 2, 3 * HEIGHT / 4, 0.0);
|
||||||
glVertex3f(0.0, -1.0, 0.0);
|
glVertex3f(WIDTH / 2, HEIGHT / 2, 0.0);
|
||||||
|
glEnd();
|
||||||
|
glColor3f(1, 0.6, 0);
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
glVertex2f(0, 0);
|
||||||
|
glVertex2f(WIDTH - 1, 0);
|
||||||
|
glVertex2f(WIDTH - 1, HEIGHT - 1);
|
||||||
|
glVertex2f(0, HEIGHT - 1);
|
||||||
glEnd();
|
glEnd();
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user