Added skybox. And not working code for textures
@ -2,7 +2,7 @@
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\Serhii\source\repos\grk_game_scene\Debug\grk-cw9.exe</FullPath>
|
||||
<FullPath>C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
|
@ -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
|
||||
|
@ -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\|
|
||||
|
@ -45,6 +45,10 @@
|
||||
<None Include="shaders\shader_9_1.vert" />
|
||||
<None Include="shaders\shader_8_sun.frag" />
|
||||
<None Include="shaders\shader_8_sun.vert" />
|
||||
<None Include="shaders\shader_skybox.frag" />
|
||||
<None Include="shaders\shader_skybox.vert" />
|
||||
<None Include="shaders\shader_tex.frag" />
|
||||
<None Include="shaders\shader_tex.vert" />
|
||||
<None Include="shaders\test.frag" />
|
||||
<None Include="shaders\test.vert" />
|
||||
<None Include="shader_laser.frag" />
|
||||
|
@ -133,5 +133,17 @@
|
||||
<None Include="shader_shadowap_sun.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_skybox.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_skybox.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_tex.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
40
cw 9/models/cube.obj
Normal file
@ -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
|
12
cw 9/shaders/shader_skybox.frag
Normal file
@ -0,0 +1,12 @@
|
||||
#version 430 core
|
||||
|
||||
uniform samplerCube skybox;
|
||||
|
||||
in vec3 texCoord;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
out_color = texture(skybox,texCoord);
|
||||
}
|
13
cw 9/shaders/shader_skybox.vert
Normal file
@ -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);
|
||||
}
|
21
cw 9/shaders/shader_tex.frag
Normal file
@ -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);
|
||||
}
|
21
cw 9/shaders/shader_tex.vert
Normal file
@ -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);
|
||||
}
|
BIN
cw 9/skybox/negx.jpg
Normal file
After Width: | Height: | Size: 1012 KiB |
BIN
cw 9/skybox/negy.jpg
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
cw 9/skybox/negz.jpg
Normal file
After Width: | Height: | Size: 840 KiB |
BIN
cw 9/skybox/posx.jpg
Normal file
After Width: | Height: | Size: 946 KiB |
BIN
cw 9/skybox/posy.jpg
Normal file
After Width: | Height: | Size: 205 KiB |
BIN
cw 9/skybox/posz.jpg
Normal file
After Width: | Height: | Size: 920 KiB |
@ -10,6 +10,8 @@
|
||||
//#include "Texture.h"
|
||||
#include "Laser.h"
|
||||
#include "SpaceShip.h"
|
||||
#include "Texture.h"
|
||||
#include "SOIL/SOIL.h"
|
||||
|
||||
#include <string>
|
||||
#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<glm::vec3> lasersLightPos{ laserLightPos0, laserLightPos1, laserLigh
|
||||
|
||||
std::vector<Laser> 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,12 +473,19 @@ void renderScene(GLFWwindow* window)
|
||||
// glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
||||
// glm::vec3(0.3, 0.3, 0.5)
|
||||
// );
|
||||
|
||||
|
||||
drawObjectPBR(shipContext,
|
||||
glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * 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
|
||||
|
@ -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;
|
||||
|
BIN
cw 9/textures/floor.jpg
Normal file
After Width: | Height: | Size: 266 KiB |
BIN
cw 9/textures/sofa.jpg
Normal file
After Width: | Height: | Size: 256 KiB |
BIN
cw 9/textures/wall.jpg
Normal file
After Width: | Height: | Size: 1.4 MiB |