Base program with textured ground

This commit is contained in:
Teo-CD 2019-11-03 18:05:58 +01:00
commit bbe9a7394c
7 changed files with 172 additions and 0 deletions

122
src/main.cpp Normal file
View file

@ -0,0 +1,122 @@
//
// Created by trotFunky on 03/11/2019.
//
#include "Engine.h"
#include "DataHandling/Texture.h"
static Texture map;
void manage_inputs()
{
if (InputStatus::is_key_pressed(0x1B))
{
glutDestroyWindow(glutGetWindow());
exit(EXIT_SUCCESS);
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_RIGHT))
{
OGLE::camera.local_translate({0, 0, 0.1});
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_LEFT))
{
OGLE::camera.local_translate({0, 0, -0.1});
}
if (InputStatus::is_key_pressed(' '))
{
OGLE::camera.local_translate({0, 0.1, 0});
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_PAGE_DOWN))
{
OGLE::camera.local_translate({0, -0.1, 0});
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_UP))
{
OGLE::camera.local_translate({0.1, 0, 0});
}
if (InputStatus::is_special_key_pressed(GLUT_KEY_DOWN))
{
OGLE::camera.local_translate({-0.1, 0, 0});
}
Vec2i mouse_delta = InputStatus::get_mouse_delta(true);
if (mouse_delta.x != 0 || mouse_delta.y != 0)
{
OGLE::camera.rotate({0,
-mouse_delta.x / InputStatus::mouse_sensitivity.x,
-mouse_delta.y / InputStatus::mouse_sensitivity.y});
}
}
void display()
{
manage_inputs();
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glColor3f(0.5,0,0);
glVertex3i(-1,-10,-1);
glVertex3i(-1,10,-1);
glVertex3i(1,10,-1);
glVertex3i(1,-10,-1);
glColor3f(0.5,0,0);
glVertex3i(-1,-10,-1);
glVertex3i(-1,10,-1);
glVertex3i(-1,10,1);
glVertex3i(-1,-10,1);
glColor3f(0.5,0,0);
glVertex3i(1,-10,1);
glVertex3i(1,10,1);
glVertex3i(1,10,-1);
glVertex3i(1,-10,-1);
glColor3f(0.5,0,0);
glVertex3i(1,-10,1);
glVertex3i(1,10,1);
glVertex3i(-1,10,1);
glVertex3i(-1,-10,1);
glEnd();
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glBindTexture(GL_TEXTURE_2D,map.opengl_id[0]);
glColor4f(1.0f, 1.0f, 1.0f,1.00);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3i(0,0,0);
glTexCoord2d(0,1);
glVertex3i(0,0,256);
glTexCoord2d(1,1);
glVertex3i(256,0,256);
glTexCoord2d(1,0);
glVertex3i(256,0,0);
glEnd();
glDisable(GL_ALPHA_TEST);
}
int main(int argc, char** argv)
{
OGLE::setup(argc,argv,display,"The Labyrinth !");
map.load_rgb_tga("resources/map.tga");
glutMainLoop();
return 0;
}