Set gl ortho.
This commit is contained in:
parent
e98856a874
commit
f919b166df
1 changed files with 16 additions and 6 deletions
22
gl.cc
22
gl.cc
|
@ -31,10 +31,20 @@ void pressButton(cont_state_t* controller_state, int button, T&& callback) {
|
|||
|
||||
void initScreen() {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
glViewport(0, 0, 640, 480);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, 640, 0, 480, -100, 100);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
|
||||
}
|
||||
|
||||
void glVertex3fNormalized(float x, float y, float z) {
|
||||
int xSize, ySize;
|
||||
xSize = 640;
|
||||
ySize = 480;
|
||||
|
||||
glVertex3f(x * xSize, y * ySize, z);
|
||||
}
|
||||
|
||||
void displayStuff() {
|
||||
|
@ -46,16 +56,16 @@ void displayStuff() {
|
|||
glColor3f(0.5f, 0.0f, 1.0f);
|
||||
glBegin(GL_POLYGON);
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.25f, 0.25f, 0.0f);
|
||||
glVertex3fNormalized(0.25f, 0.25f, 0.0f);
|
||||
|
||||
glColor3f(0.0f, 1.0f, 0.0f);
|
||||
glVertex3f(0.75f, 0.25f, 0.0f);
|
||||
glVertex3fNormalized(0.75f, 0.25f, 0.0f);
|
||||
|
||||
glColor3f(0.0f, 0.0f, 1.0f);
|
||||
glVertex3f(0.75f, 0.75f, 0.0f);
|
||||
glVertex3fNormalized(0.75f, 0.75f, 0.0f);
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glVertex3f(0.25f, 0.75f, 0.0f);
|
||||
glVertex3fNormalized(0.25f, 0.75f, 0.0f);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
// clang-format on
|
||||
|
|
Loading…
Reference in a new issue