diff --git a/Debug/grk-cw9.exe b/Debug/grk-cw9.exe index 615018c..64a8b47 100644 Binary files a/Debug/grk-cw9.exe and b/Debug/grk-cw9.exe differ diff --git a/Debug/grk-cw9.pdb b/Debug/grk-cw9.pdb index e15326c..c416c65 100644 Binary files a/Debug/grk-cw9.pdb and b/Debug/grk-cw9.pdb differ diff --git a/cw 9/Debug/Box.obj b/cw 9/Debug/Box.obj index d3b85a4..3cb1b02 100644 Binary files a/cw 9/Debug/Box.obj and b/cw 9/Debug/Box.obj differ diff --git a/cw 9/Debug/Camera.obj b/cw 9/Debug/Camera.obj index a2dac95..6bcba78 100644 Binary files a/cw 9/Debug/Camera.obj and b/cw 9/Debug/Camera.obj differ diff --git a/cw 9/Debug/Laser.obj b/cw 9/Debug/Laser.obj index b1f9a79..5340576 100644 Binary files a/cw 9/Debug/Laser.obj and b/cw 9/Debug/Laser.obj differ diff --git a/cw 9/Debug/Render_Utils.obj b/cw 9/Debug/Render_Utils.obj index 458482f..e9260df 100644 Binary files a/cw 9/Debug/Render_Utils.obj and b/cw 9/Debug/Render_Utils.obj differ diff --git a/cw 9/Debug/SOIL.obj b/cw 9/Debug/SOIL.obj index 017cecb..e253515 100644 Binary files a/cw 9/Debug/SOIL.obj and b/cw 9/Debug/SOIL.obj differ diff --git a/cw 9/Debug/Shader_Loader.obj b/cw 9/Debug/Shader_Loader.obj index d189d4b..824fd6d 100644 Binary files a/cw 9/Debug/Shader_Loader.obj and b/cw 9/Debug/Shader_Loader.obj differ diff --git a/cw 9/Debug/SpaceShip.obj b/cw 9/Debug/SpaceShip.obj index 62d4890..8c9c86f 100644 Binary files a/cw 9/Debug/SpaceShip.obj and b/cw 9/Debug/SpaceShip.obj differ diff --git a/cw 9/Debug/Texture.obj b/cw 9/Debug/Texture.obj index 2ff0583..f298fdc 100644 Binary files a/cw 9/Debug/Texture.obj and b/cw 9/Debug/Texture.obj differ diff --git a/cw 9/Debug/grk-cw9.exe.recipe b/cw 9/Debug/grk-cw9.exe.recipe index e1898f4..87950e8 100644 --- a/cw 9/Debug/grk-cw9.exe.recipe +++ b/cw 9/Debug/grk-cw9.exe.recipe @@ -2,7 +2,7 @@ - C:\Users\Serhii\source\repos\grk_game_scene\Debug\grk-cw9.exe + C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.log b/cw 9/Debug/grk-cw9.log index b29002f..fdab361 100644 --- a/cw 9/Debug/grk-cw9.log +++ b/cw 9/Debug/grk-cw9.log @@ -1,48 +1,49 @@  main.cpp -C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition -C:\Users\Serhii\source\repos\grk_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(124,30): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(168,38): warning C4305: '=': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(191,16): warning C4305: 'initializing': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(232,20): warning C4018: '<': signed/unsigned mismatch -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(268,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(282,98): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition +C:\Users\arciom\Desktop\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(133,30): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(175,38): warning C4305: '=': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(198,16): warning C4305: 'initializing': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(239,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(288,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(302,98): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(285,68): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(305,68): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(319,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(374,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(383,108): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(339,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(422,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(433,108): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(391,87): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(441,87): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(391,223): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(394,59): warning C4305: 'argument': truncation from 'double' to 'T' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(441,223): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(444,59): warning C4305: 'argument': truncation from 'double' to 'T' with [ T=float ] -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(395,37): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(430,2): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(436,20): warning C4018: '<': signed/unsigned mismatch -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(441,50): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(442,51): warning C4305: 'argument': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(520,21): warning C4018: '<': signed/unsigned mismatch -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(522,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(726,21): warning C4305: '-=': truncation from 'double' to 'float' -C:\Users\Serhii\source\repos\grk_game_scene\cw 9\src\ex_9_1.hpp(728,21): warning C4305: '+=': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(445,37): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(482,2): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(493,20): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(498,50): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(499,51): warning C4305: 'argument': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(576,21): warning C4018: '<': signed/unsigned mismatch +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(578,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(601,17): warning C4101: 'data': unreferenced local variable +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(803,21): warning C4305: '-=': truncation from 'double' to 'float' +C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(805,21): warning C4305: '+=': truncation from 'double' to 'float' Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library - grk-cw9.vcxproj -> C:\Users\Serhii\source\repos\grk_game_scene\Debug\grk-cw9.exe + grk-cw9.vcxproj -> C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe diff --git a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog index ebe3aef..266af2c 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.command.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog index 13da725..11a3da8 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog index c7756f7..e10162a 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/CL.write.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate index dc00425..253b6db 100644 --- a/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate +++ b/cw 9/Debug/grk-cw9.tlog/grk-cw9.lastbuildstate @@ -1,2 +1,2 @@ -PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: -Debug|Win32|C:\Users\Serhii\source\repos\grk_game_scene\| +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.22000.0: +Debug|Win32|C:\Users\arciom\Desktop\GRK_game_scene\| diff --git a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog index 5c1bd22..e6d8cb5 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.read.1.tlog differ diff --git a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog index aa10d29..17d7dbb 100644 Binary files a/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog and b/cw 9/Debug/grk-cw9.tlog/link.write.1.tlog differ diff --git a/cw 9/Debug/image_DXT.obj b/cw 9/Debug/image_DXT.obj index 1369428..f729735 100644 Binary files a/cw 9/Debug/image_DXT.obj and b/cw 9/Debug/image_DXT.obj differ diff --git a/cw 9/Debug/image_helper.obj b/cw 9/Debug/image_helper.obj index 4b21e18..ade8958 100644 Binary files a/cw 9/Debug/image_helper.obj and b/cw 9/Debug/image_helper.obj differ diff --git a/cw 9/Debug/main.obj b/cw 9/Debug/main.obj index 53d118a..4fb0ab0 100644 Binary files a/cw 9/Debug/main.obj and b/cw 9/Debug/main.obj differ diff --git a/cw 9/Debug/stb_image_aug.obj b/cw 9/Debug/stb_image_aug.obj index bb6c7dd..3a0d38f 100644 Binary files a/cw 9/Debug/stb_image_aug.obj and b/cw 9/Debug/stb_image_aug.obj differ diff --git a/cw 9/Debug/vc142.idb b/cw 9/Debug/vc142.idb index acf0e53..9cc8f7f 100644 Binary files a/cw 9/Debug/vc142.idb and b/cw 9/Debug/vc142.idb differ diff --git a/cw 9/Debug/vc142.pdb b/cw 9/Debug/vc142.pdb index 076768f..bd75438 100644 Binary files a/cw 9/Debug/vc142.pdb and b/cw 9/Debug/vc142.pdb differ diff --git a/cw 9/grk-cw9.vcxproj b/cw 9/grk-cw9.vcxproj index 286278b..88bec74 100644 --- a/cw 9/grk-cw9.vcxproj +++ b/cw 9/grk-cw9.vcxproj @@ -45,6 +45,10 @@ + + + + diff --git a/cw 9/grk-cw9.vcxproj.filters b/cw 9/grk-cw9.vcxproj.filters index 9bbb6e5..d0188b5 100644 --- a/cw 9/grk-cw9.vcxproj.filters +++ b/cw 9/grk-cw9.vcxproj.filters @@ -133,5 +133,17 @@ Shader Files + + Shader Files + + + Shader Files + + + Shader Files + + + Shader Files + \ No newline at end of file diff --git a/cw 9/models/cube.obj b/cw 9/models/cube.obj new file mode 100644 index 0000000..4eb693e --- /dev/null +++ b/cw 9/models/cube.obj @@ -0,0 +1,40 @@ +# Blender v2.90.0 OBJ File: '' +# www.blender.org +mtllib cube.mtl +o Cube +v -10.000000 -10.000000 10.000000 +v -10.000000 10.000000 10.000000 +v -10.000000 -10.000000 -10.000000 +v -10.000000 10.000000 -10.000000 +v 10.000000 -10.000000 10.000000 +v 10.000000 10.000000 10.000000 +v 10.000000 -10.000000 -10.000000 +v 10.000000 10.000000 -10.000000 +vt 0.375000 0.000000 +vt 0.625000 0.000000 +vt 0.625000 0.250000 +vt 0.375000 0.250000 +vt 0.625000 0.500000 +vt 0.375000 0.500000 +vt 0.625000 0.750000 +vt 0.375000 0.750000 +vt 0.625000 1.000000 +vt 0.375000 1.000000 +vt 0.125000 0.500000 +vt 0.125000 0.750000 +vt 0.875000 0.500000 +vt 0.875000 0.750000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 1.0000 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 1.0000 0.0000 +usemtl _PBR +s 1 +f 1/1/1 2/2/1 4/3/1 3/4/1 +f 3/4/2 4/3/2 8/5/2 7/6/2 +f 7/6/3 8/5/3 6/7/3 5/8/3 +f 5/8/4 6/7/4 2/9/4 1/10/4 +f 3/11/5 7/6/5 5/8/5 1/12/5 +f 8/5/6 4/13/6 2/14/6 6/7/6 diff --git a/cw 9/shaders/shader_skybox.frag b/cw 9/shaders/shader_skybox.frag new file mode 100644 index 0000000..7052ca9 --- /dev/null +++ b/cw 9/shaders/shader_skybox.frag @@ -0,0 +1,12 @@ +#version 430 core + +uniform samplerCube skybox; + +in vec3 texCoord; + +out vec4 out_color; + +void main() +{ + out_color = texture(skybox,texCoord); +} \ No newline at end of file diff --git a/cw 9/shaders/shader_skybox.vert b/cw 9/shaders/shader_skybox.vert new file mode 100644 index 0000000..9fee19a --- /dev/null +++ b/cw 9/shaders/shader_skybox.vert @@ -0,0 +1,13 @@ +#version 430 core + +layout(location = 0) in vec3 vertexPosition; + +uniform mat4 transformation; + +out vec3 texCoord; + +void main() +{ + texCoord = vertexPosition; + gl_Position = transformation * vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/cw 9/shaders/shader_tex.frag b/cw 9/shaders/shader_tex.frag new file mode 100644 index 0000000..74fad90 --- /dev/null +++ b/cw 9/shaders/shader_tex.frag @@ -0,0 +1,21 @@ +#version 430 core + +float AMBIENT = 0.1; + +uniform vec3 color; +//uniform vec3 lightPos; +uniform sampler2D colorTexture; + +in vec3 vecNormal; +in vec3 worldPos; +in vec2 vecTex; + +out vec4 outColor; +void main() +{ + //vec3 lightDir = normalize(lightPos-worldPos); + vec3 normal = normalize(vecNormal); + vec3 textureColor = texture2D(colorTexture, vecTex).xyz; + //float diffuse=max(0,dot(normal,lightDir)); + outColor = vec4(textureColor/**min(1,AMBIENT+diffuse)*/, 1.0); +} \ No newline at end of file diff --git a/cw 9/shaders/shader_tex.vert b/cw 9/shaders/shader_tex.vert new file mode 100644 index 0000000..6b27aa8 --- /dev/null +++ b/cw 9/shaders/shader_tex.vert @@ -0,0 +1,21 @@ +#version 430 core + +layout(location = 0) in vec3 vertexPosition; +layout(location = 1) in vec3 vertexNormal; +layout(location = 2) in vec2 vertexTexCoord; + +uniform mat4 transformation; +uniform mat4 modelMatrix; + +out vec3 vecNormal; +out vec3 worldPos; +out vec2 vecTex; + +void main() +{ + worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz; + vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz; + vecTex = vertexTexCoord; + vecTex.y = 1.0 - vecTex.y; + gl_Position = transformation * vec4(vertexPosition, 1.0); +} diff --git a/cw 9/skybox/negx.jpg b/cw 9/skybox/negx.jpg new file mode 100644 index 0000000..d72ed3b Binary files /dev/null and b/cw 9/skybox/negx.jpg differ diff --git a/cw 9/skybox/negy.jpg b/cw 9/skybox/negy.jpg new file mode 100644 index 0000000..baa2416 Binary files /dev/null and b/cw 9/skybox/negy.jpg differ diff --git a/cw 9/skybox/negz.jpg b/cw 9/skybox/negz.jpg new file mode 100644 index 0000000..088ce34 Binary files /dev/null and b/cw 9/skybox/negz.jpg differ diff --git a/cw 9/skybox/posx.jpg b/cw 9/skybox/posx.jpg new file mode 100644 index 0000000..4416e28 Binary files /dev/null and b/cw 9/skybox/posx.jpg differ diff --git a/cw 9/skybox/posy.jpg b/cw 9/skybox/posy.jpg new file mode 100644 index 0000000..1eeecfb Binary files /dev/null and b/cw 9/skybox/posy.jpg differ diff --git a/cw 9/skybox/posz.jpg b/cw 9/skybox/posz.jpg new file mode 100644 index 0000000..fd27d57 Binary files /dev/null and b/cw 9/skybox/posz.jpg differ diff --git a/cw 9/src/ex_9_1.hpp b/cw 9/src/ex_9_1.hpp index fec0c2e..65a083a 100644 --- a/cw 9/src/ex_9_1.hpp +++ b/cw 9/src/ex_9_1.hpp @@ -10,6 +10,8 @@ //#include "Texture.h" #include "Laser.h" #include "SpaceShip.h" +#include "Texture.h" +#include "SOIL/SOIL.h" #include #include "Box.cpp" @@ -20,7 +22,12 @@ const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; -int WIDTH = 500, HEIGHT = 500; +int WIDTH = 950, HEIGHT = 950; + +namespace texture { + GLuint skybox; + GLuint sofa; +} namespace models { @@ -71,6 +78,7 @@ GLuint programSun; GLuint programTest; GLuint programTex; GLuint programDepth; +GLuint programSkybox; GLuint programLaser; @@ -78,6 +86,7 @@ Core::Shader_Loader shaderLoader; Core::RenderContext shipContext; Core::RenderContext sphereContext; +Core::RenderContext skyboxContext; glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f); glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f); @@ -156,8 +165,6 @@ std::vector lasersLightPos{ laserLightPos0, laserLightPos1, laserLigh std::vector lasers; - - void updateDeltaTime(float time) { if (lastTime < 0) { lastTime = time; @@ -263,6 +270,19 @@ void drawObjectDepth(Core::RenderContext context, glm::mat4 viewProjectionMatrix Core::DrawContext(context); } +//TEXTURES +//void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID) { +// glUseProgram(programTex); +// glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix(); +// glm::mat4 transformation = viewProjectionMatrix * modelMatrix; +// glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation); +// glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix); +// //glUniform3f(glGetUniformLocation(programTex, "lightPos"), 0, 0, 0); +// Core::SetActiveTexture(textureID, "colorTexture", programTex, 0); +// Core::DrawContext(context); +// glUseProgram(0); +// +//} void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) { float time = glfwGetTime(); @@ -347,6 +367,31 @@ void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst, int in } +void drawSkybox(Core::RenderContext& context, GLuint textureID) { + + glDisable(GL_DEPTH_TEST); + glUseProgram(programSkybox); + glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix(); + glm::mat4 pos = glm::mat4({ + 1,0.,0.,cameraPos.x, + 0.,1.,0.,cameraPos.y, + 0.,0.,1.,cameraPos.z, + 0.,0.,0.,1., + }); + + + pos = glm::transpose(pos); + glm::mat4 transformation = viewProjectionMatrix * pos; + glUniformMatrix4fv(glGetUniformLocation(programSkybox, "transformation"), 1, GL_FALSE, (float*)&transformation); + glUniformMatrix4fv(glGetUniformLocation(programSkybox, "modelMatrix"), 1, GL_FALSE, (float*)&pos); + //glUniform3f(glGetUniformLocation(programSkybox, "lightPos"), 0, 0, 0); + glBindTexture(GL_TEXTURE_CUBE_MAP, textureID); + //Core::SetActiveTexture(textureID, "skybox", programSkybox, 0); + Core::DrawContext(context); + glEnable(GL_DEPTH_TEST); +} + + void initDepthMap() { glGenFramebuffers(1, &depthMapFBOSun); @@ -367,6 +412,9 @@ void initDepthMap() glBindFramebuffer(GL_FRAMEBUFFER, 0); } + + + void renderScene(GLFWwindow* window) { glClearColor(0.4f, 0.4f, 0.8f, 1.0f); @@ -377,6 +425,8 @@ void renderScene(GLFWwindow* window) glm::mat4 lightVPSun = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0)); renderShadowapSun(depthMapFBOSun, lightVPSun); + drawSkybox(skyboxContext, texture::skybox); + //space lamp glUseProgram(programSun); glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix(); @@ -400,7 +450,7 @@ void renderScene(GLFWwindow* window) drawObjectPBR(models::sofaContext, glm::mat4(), glm::vec3(0.620f, 0.313f, 0.131f), 0.2f, 0.0f); drawObjectPBR(models::tvTableContext, glm::mat4(), glm::vec3(0.4f, 0.4f, 0.4f), 0.4f, 0.0f); drawObjectPBR(models::tableContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f); - drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f); + drawObjectPBR(models::doorContext, glm::mat4()/*glm::rotate(glm::mat4(), time * glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f))*/, glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f); drawObjectPBR(models::drawerContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f); drawObjectPBR(models::tvContext, glm::mat4(), glm::vec3(1.f, 1.f, 1.f), 0.5f, 1.0f); drawObjectPBR(models::xThingContext, glm::mat4(), glm::vec3(0.10039f, 0.018356f, 0.001935f), 0.1f, 0.0f); @@ -423,11 +473,18 @@ void renderScene(GLFWwindow* window) // glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi()), // glm::vec3(0.3, 0.3, 0.5) // ); + + drawObjectPBR(shipContext, glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi()) * glm::scale(glm::vec3(0.015f)), glm::vec3(0.3, 0.3, 0.5), 0.2, 1.0 ); + + /*drawObjectTexture(models::sofaContext, + glm::mat4(), + texture::sofa + );*/ spotlightPos = spaceShip.getSpaceShipPos() + 0.2 * spaceShip.getSpaceShipDir(); spotlightConeDir = spaceShip.getSpaceShipDir(); @@ -449,7 +506,6 @@ void renderScene(GLFWwindow* window) //std::cout << spaceShip.getSpaceShipPos().z << std::endl; - //test depth buffer /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(programTest); @@ -535,6 +591,34 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) } +GLuint LoadSkybox(char* filepath[6]) +{ + GLuint id; + glGenTextures(1, &id); + glBindTexture(GL_TEXTURE_CUBE_MAP, id); + + int w, h; + unsigned char* data; + for (unsigned int i = 0; i < 6; i++) + { + unsigned char* image = SOIL_load_image(filepath[i], &w, &h, 0, SOIL_LOAD_RGBA); + glTexImage2D( + GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, + 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image + ); + + } + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + glGenerateMipmap(GL_TEXTURE_2D); + //SOIL_free_image_data(image); + + return id; +} void init(GLFWwindow* window) @@ -558,13 +642,15 @@ void init(GLFWwindow* window) programDepth = shaderLoader.CreateProgram("shaders/shader_shadowap_sun.vert", "shaders/shader_shadowap_sun.frag"); - - programLaser = shaderLoader.CreateProgram("shader_laser.vert", "shader_laser.frag"); + programSkybox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag"); + + programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag"); + loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/spaceship.obj", shipContext); - + loadModelToContext("./models/cube.obj", skyboxContext); loadModelToContext("./models/books.obj", models::booksContext); loadModelToContext("./models/sofa.obj", models::sofaContext); @@ -581,6 +667,9 @@ void init(GLFWwindow* window) loadModelToContext("./models/window.obj", models::windowContext); loadModelToContext("./models/test.obj", models::testContext); + texture::sofa = Core::LoadTexture("textures/sofa.jpg"); + texture::skybox = LoadSkybox(new char* [6]{ "skybox/posx.jpg", "skybox/negx.jpg", "skybox/posy.jpg","skybox/negy.jpg", "skybox/posz.jpg", "skybox/negz.jpg" }); + //lasersContexts.reserve(spaceShip.getMaxNumberOfLasers()); for (int i = 0; i < spaceShip.getMaxNumberOfLasers(); i++) { @@ -612,7 +701,7 @@ bool check_room_collision(int plus_or_minus) { spaceShipPos.x < -1.61 || spaceShipPos.x > 1.59 || spaceShipPos.y > 2.15 || spaceShipPos.y < 0.11; - return collision; + return collision; //if you want check textures position, return false instead collision } //obsluga wejscia diff --git a/cw 9/src/main.cpp b/cw 9/src/main.cpp index 4e939cd..64a73b7 100644 --- a/cw 9/src/main.cpp +++ b/cw 9/src/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) #endif // tworzenie okna za pomoca glfw - GLFWwindow* window = glfwCreateWindow(500, 500, "FirstWindow", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(950, 950, "FirstWindow", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; diff --git a/cw 9/textures/floor.jpg b/cw 9/textures/floor.jpg new file mode 100644 index 0000000..e5c3a42 Binary files /dev/null and b/cw 9/textures/floor.jpg differ diff --git a/cw 9/textures/sofa.jpg b/cw 9/textures/sofa.jpg new file mode 100644 index 0000000..76a6fae Binary files /dev/null and b/cw 9/textures/sofa.jpg differ diff --git a/cw 9/textures/wall.jpg b/cw 9/textures/wall.jpg new file mode 100644 index 0000000..2c27905 Binary files /dev/null and b/cw 9/textures/wall.jpg differ