Base program with textured ground
This commit is contained in:
commit
bbe9a7394c
7 changed files with 172 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
**out/
|
||||
**.vs/
|
||||
**.idea/
|
||||
**cmake-build*/
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "libs/OpenGL-JIN"]
|
||||
path = libs/OpenGL-JIN
|
||||
url = https://git.tfk-astrodome.net/Teo-CD/OpenGL-JIN.git
|
32
CMakeLists.txt
Normal file
32
CMakeLists.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
if(DEFINED ENV{VCPKG_ROOT})
|
||||
set(VCPKG_TARGET_TRIPLET "x64-windows")
|
||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(labyrinthe)
|
||||
|
||||
add_subdirectory(libs/OpenGL-JIN)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLUT REQUIRED)
|
||||
|
||||
|
||||
add_executable(game
|
||||
src/main.cpp)
|
||||
|
||||
target_include_directories(game PRIVATE
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
${GLUT_INCLUDE_DIR}
|
||||
libs/OpenGL-JIN/src)
|
||||
|
||||
target_link_libraries(game PRIVATE
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLUT_LIBRARIES}
|
||||
engine)
|
10
README.md
Normal file
10
README.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Labyrinth
|
||||
|
||||
This very small project is the final part of my OpenGL course. It uses my custom engine.
|
||||
|
||||
## Building
|
||||
### Dependencies
|
||||
|
||||
- OpenGL
|
||||
- Glut
|
||||
- My custom engine (Submodule of the project)
|
1
libs/OpenGL-JIN
Submodule
1
libs/OpenGL-JIN
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6209e91c2849dfb3294afa39fcd5a526b045c6ca
|
BIN
resources/Map.tga
Normal file
BIN
resources/Map.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 192 KiB |
122
src/main.cpp
Normal file
122
src/main.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Reference in a new issue