From bbe9a7394cd1a56c391f41d52071152826f790ff Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sun, 3 Nov 2019 18:05:58 +0100 Subject: [PATCH] Base program with textured ground --- .gitignore | 4 ++ .gitmodules | 3 ++ CMakeLists.txt | 32 ++++++++++++ README.md | 10 ++++ libs/OpenGL-JIN | 1 + resources/Map.tga | Bin 0 -> 196652 bytes src/main.cpp | 122 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 172 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 160000 libs/OpenGL-JIN create mode 100644 resources/Map.tga create mode 100644 src/main.cpp 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 0000000000000000000000000000000000000000..a37f997da321c6bc1e86cbaf3107e23f2ae4e1b1 GIT binary patch literal 196652 zcmeH`ONt-`6a-sO;nEA}Ek+m+1%G(|i;OOGQ>!4r1YbqZVkpR$)e)8b@$vP?KR;i6 z{Qd8nZ~uMl{|sax0~yFb1~QO=3}he!8OT5eGLV4`WFP|>$Up`%kbw+jAOji5Kn609 zfed6I0~yG`|H;6Yell>;0Q@7oh#pf0zO?^F@MZ(;|IJ@N_V(Wf-fW=#zxnIO-u~Ob zn+>%8H-G)u+kYE)vw`;i=C2=n`)>npHqidx{PkmR|83yS2HO9dzkclPzYVL65 z*N?sZw}Ces`0w@)n~P;&Y2fk44qyGaB9E}SSO%5`9@B-deq519*jy|FO9PMT!dE}8 z$RlhnmVu>#$8_PVA6MiNHW$ml(!gW7@YRni@(7!YWngLGFm&BZdXH1L=% zeD&jsJi_K;8CV*4Oc%cTaYY_sbFmC84Lqg`U;VfukFdE|29^dM(}k~oT#-lETr2}i z1CQy#S3j=EBWx~~fu(`Rbm6NXSL6{k7t6rXz+<}b)sHLk2%GmY^2?Wbi2*o2VFNbr zV}hlVs|Miw1U_uu#{^3!R}H}V34GYRj|rAet{Q;z6Zo)s9}_H{Tr~jaC-7nOJ|Csz%?`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0XRQ_51aQf!P3c918{xkp;KSy9Ot5rv)c~BIz=zHIm|*GTssT7Zfe)MaF~QQwRReH-0v|T-V}hlVs|Miw z1U_uu#{^3!R}H}V34GYRj|rAet{Q;z6Zo)s9}_H{Tr~jaC-7nOJ| zCsz%?`3Zd3ypIW%POch&^Aq^6c^?xjom@2l=O^%C^FAh6I=N~9&QIXO=6y`CbaK@I zoS(pl&HI>O>Ex;bI6r|8oA)un(#cf=aDDvFSUS0C0M1X~!{&WVuyk_O0Gyw|ht2z# zVCm$l0XRQ_51aQf!P3c918{xkp;KSy9Ot5rv)c~BIz=zHIm|*GTssT7Z zfe)MaF~QQwRReH-0v|T-V}hlVs|Miw1U_uu#{^3!R}H}V34GYRj|rAet{Q;z6Zo)s z9}_H{Tr~jaC-7nOJ|Csz%?`3Zd3ypIW%POch&^Aq^6c^?xjom@2l z=O^%C^FAh6I=N~9&QIXO=6y`CbaK@IoS(pl&HI>O>Ex;bI6r|8oA)un(#cf=aDDvF zSUS0C0M1X~!{&WVuyk_O0Gyw|ht2z#VCm$l0XRQ_51aQf!P3c918{xkp z;KSy9Ot5rv)c~BIz=zHIm|*GTssT7Zfe)MaF~QQwRReH-0v|T-V}hlVs|Miw1U_uu z#{^3!R}H}V34GYRj|rAet{Q;z6Zo)s9}_H{Tr~jaC-7nOJ|$Up`%kbw+jAOji5Kn609fed6I0~yFb u1~QO=3}he!8OT5eGLV4`WMFRKw_kq$^vCC4KmYvGcYpry`NvP+fBXdvBk!XC literal 0 HcmV?d00001 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