|
|
|
@ -141,7 +141,7 @@ class SDLGLGLWindow {
@@ -141,7 +141,7 @@ class SDLGLGLWindow {
|
|
|
|
|
SDL_GL_CONTEXT_PROFILE_CORE ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
gWindow = SDL_CreateWindow( "𝔭𝔬𝔫𝔡𝔢𝔯 𝔱𝔥𝔢 𝔬𝔯𝔟", SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
|
SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height,
|
|
|
|
|
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); |
|
|
|
|
|
|
|
|
@ -518,9 +518,9 @@ class SDLGLGLWindow {
@@ -518,9 +518,9 @@ class SDLGLGLWindow {
|
|
|
|
|
-1.0f, -1.0f, 0.0f, 0.0f, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
|
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); |
|
|
|
|
glEnable(GL_BLEND); |
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
|
|
|
//glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
|
|
|
|
|
|
|
|
|
//IBO data
|
|
|
|
|
// GLuint indexData[] = { 0, 1, 2, 3, 0, 2};
|
|
|
|
@ -560,17 +560,17 @@ class SDLGLGLWindow {
@@ -560,17 +560,17 @@ class SDLGLGLWindow {
|
|
|
|
|
|
|
|
|
|
/********** CUBEMAPS ***************/ |
|
|
|
|
|
|
|
|
|
std::vector<std::string> faces { |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
stbi_set_flip_vertically_on_load(false); |
|
|
|
|
Cubemap c (std::vector<std::string> { |
|
|
|
|
fmt::format("{}/sky/right.png", SKYBOX_DIR), |
|
|
|
|
fmt::format("{}/sky/left.png",SKYBOX_DIR), |
|
|
|
|
fmt::format("{}/sky/up.png",SKYBOX_DIR), |
|
|
|
|
fmt::format("{}/sky/down.png",SKYBOX_DIR), |
|
|
|
|
fmt::format("{}/sky/front.png",SKYBOX_DIR), |
|
|
|
|
fmt::format("{}/sky/back.png",SKYBOX_DIR), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
stbi_set_flip_vertically_on_load(false); |
|
|
|
|
Cubemap c (faces); |
|
|
|
|
}); |
|
|
|
|
cubemap = c.id; |
|
|
|
|
|
|
|
|
|
/************ ENDCUBEMAP ***********/ |
|
|
|
@ -627,7 +627,7 @@ class SDLGLGLWindow {
@@ -627,7 +627,7 @@ class SDLGLGLWindow {
|
|
|
|
|
|
|
|
|
|
//Clear color buffer
|
|
|
|
|
|
|
|
|
|
glClearColor(0.2f, 0.3f, 0.3f, 1.0f); |
|
|
|
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
|
|
|
glCheckError(); |
|
|
|
|
|
|
|
|
@ -750,8 +750,6 @@ class SDLGLGLWindow {
@@ -750,8 +750,6 @@ class SDLGLGLWindow {
|
|
|
|
|
glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(projection)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap); |
|
|
|
|
running_level->draw_system->draw(view, projection); |
|
|
|
|
|
|
|
|
|
//bp_model->draw(*shader);
|
|
|
|
|
// objects->draw(view, projection);
|
|
|
|
@ -778,6 +776,9 @@ class SDLGLGLWindow {
@@ -778,6 +776,9 @@ class SDLGLGLWindow {
|
|
|
|
|
|
|
|
|
|
/** draw skybox cubemap */ |
|
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE11); |
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glCheckError(); |
|
|
|
|
skyboxShader->use(); |
|
|
|
@ -785,6 +786,7 @@ class SDLGLGLWindow {
@@ -785,6 +786,7 @@ class SDLGLGLWindow {
|
|
|
|
|
glCheckError(); |
|
|
|
|
glCheckError(); |
|
|
|
|
|
|
|
|
|
skyboxShader->setInt("skybox", 11); |
|
|
|
|
loc = skyboxShader->get_uniform("view"); |
|
|
|
|
glm::mat4 skybox_view = glm::mat4(glm::mat3(view)); |
|
|
|
|
glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(skybox_view)); |
|
|
|
@ -795,7 +797,6 @@ class SDLGLGLWindow {
@@ -795,7 +797,6 @@ class SDLGLGLWindow {
|
|
|
|
|
glCheckError(); |
|
|
|
|
|
|
|
|
|
glBindVertexArray(gVAO); |
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap); |
|
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 36); |
|
|
|
|
glCheckError(); |
|
|
|
|
|
|
|
|
@ -803,6 +804,13 @@ class SDLGLGLWindow {
@@ -803,6 +804,13 @@ class SDLGLGLWindow {
|
|
|
|
|
printProgramLog(skyboxShader->program); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap);
|
|
|
|
|
running_level->draw_system->draw(view, projection); |
|
|
|
|
running_level->shader->setInt("skybox", 11); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. now blit multisampled buffer(s) to normal colorbuffer of intermediate FBO. Image is stored in screenTexture
|
|
|
|
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); |
|
|
|
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, intermediateFBO); |
|
|
|
@ -816,7 +824,7 @@ class SDLGLGLWindow {
@@ -816,7 +824,7 @@ class SDLGLGLWindow {
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT); |
|
|
|
|
glDisable(GL_DEPTH_TEST); |
|
|
|
|
|
|
|
|
|
//glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
|
|
|
|
|
|
|
|
|
texShader->use(); |
|
|
|
|
glBindVertexArray(quadVAO); |
|
|
|
@ -885,8 +893,17 @@ int main(int argc, char **argv) {
@@ -885,8 +893,17 @@ int main(int argc, char **argv) {
|
|
|
|
|
quit = true; |
|
|
|
|
} |
|
|
|
|
if (e.type == SDL_KEYDOWN) { |
|
|
|
|
bool shademode = true; |
|
|
|
|
const float camera_speed = 0.4f; |
|
|
|
|
switch (e.key.keysym.scancode) { |
|
|
|
|
case SDL_SCANCODE_X: |
|
|
|
|
if ((shademode = !shademode)) { |
|
|
|
|
glShadeModel(GL_FLAT); |
|
|
|
|
} else { |
|
|
|
|
glShadeModel(GL_SMOOTH); |
|
|
|
|
} |
|
|
|
|
glCheckError_("mpoo", 0); |
|
|
|
|
break; |
|
|
|
|
case SDL_SCANCODE_SPACE: |
|
|
|
|
mouse_mode = !mouse_mode; |
|
|
|
|
SDL_SetRelativeMouseMode(mouse_mode ? SDL_TRUE : SDL_FALSE); |
|
|
|
|