优化体验及性能 #3

Merged
pointer-to-bios merged 5 commits from pointer-to-bios/JungleOpenSourceProjectRepo:main into main 2024-04-27 06:46:10 +08:00
2 changed files with 25 additions and 15 deletions
Showing only changes of commit 5b99adfe38 - Show all commits

View File

@ -21,6 +21,10 @@ add_subdirectory(./deps/glm)
##test target##
add_executable(jungle ./test/main.cpp ./deps/glad/src/glad.c)
target_include_directories(jungle PRIVATE ./test/)
if (${BLENDING})
add_definitions(-DBLENDING=1)
message("开启BLENDING")
endif()
#glfw dep
add_dependencies(jungle glfw)
target_include_directories(jungle PRIVATE ./deps/glfw/include/ ./deps/glad/include/ ./inc)

View File

@ -40,7 +40,9 @@ int main()
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// glEnable(GL_BLEND);
#ifdef BLENDING
glEnable(GL_BLEND);
#endif
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
@ -73,8 +75,10 @@ int main()
// configure global opengl state
// -----------------------------
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
#ifdef BLENDING
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
#endif
// glEnable(GL_DEPTH_TEST);
// build and compile our shader zprogram
@ -296,19 +300,21 @@ int main()
// glDepthMask(GL_FALSE);
// render transparent objects with blending enabled
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// for (unsigned int i = 5; i < 10; i++)
// {
// ourShader.setIVec2("index", cubeTextures[i]);
#ifdef BLENDING
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (unsigned int i = 5; i < 10; i++)
{
ourShader.setIVec2("index", cubeTextures[i]);
// // calculate the model matrix for each object and pass it to shader before drawing
// glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
// model = glm::translate(model, glm::vec3(cubePositions[i]));
// ourShader.setMat4("model", model);
// glDrawArrays(GL_TRIANGLES, 0, 36);
// }
// glDisable(GL_BLEND);
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
model = glm::translate(model, glm::vec3(cubePositions[i]));
ourShader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
}
glDisable(GL_BLEND);
#endif
// glDisable(GL_DEPTH_TEST);
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)