commit bbe9a7394cd1a56c391f41d52071152826f790ff Author: Teo-CD Date: Sun Nov 3 18:05:58 2019 +0100 Base program with textured ground diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39d29e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +**out/ +**.vs/ +**.idea/ +**cmake-build*/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1438ee5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/OpenGL-JIN"] + path = libs/OpenGL-JIN + url = https://git.tfk-astrodome.net/Teo-CD/OpenGL-JIN.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..818e15c --- /dev/null +++ b/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..40aba2e --- /dev/null +++ b/README.md @@ -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) \ No newline at end of file diff --git a/libs/OpenGL-JIN b/libs/OpenGL-JIN new file mode 160000 index 0000000..6209e91 --- /dev/null +++ b/libs/OpenGL-JIN @@ -0,0 +1 @@ +Subproject commit 6209e91c2849dfb3294afa39fcd5a526b045c6ca diff --git a/resources/Map.tga b/resources/Map.tga new file mode 100644 index 0000000..a37f997 Binary files /dev/null and b/resources/Map.tga differ diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..8545d02 --- /dev/null +++ b/src/main.cpp @@ -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; +} \ No newline at end of file