优化体验及性能 #3
|
@ -21,6 +21,10 @@ add_subdirectory(./deps/glm)
|
||||||
##test target##
|
##test target##
|
||||||
add_executable(jungle ./test/main.cpp ./deps/glad/src/glad.c)
|
add_executable(jungle ./test/main.cpp ./deps/glad/src/glad.c)
|
||||||
target_include_directories(jungle PRIVATE ./test/)
|
target_include_directories(jungle PRIVATE ./test/)
|
||||||
|
if (${BLENDING})
|
||||||
|
add_definitions(-DBLENDING=1)
|
||||||
|
message("开启BLENDING")
|
||||||
|
endif()
|
||||||
#glfw dep
|
#glfw dep
|
||||||
add_dependencies(jungle glfw)
|
add_dependencies(jungle glfw)
|
||||||
target_include_directories(jungle PRIVATE ./deps/glfw/include/ ./deps/glad/include/ ./inc)
|
target_include_directories(jungle PRIVATE ./deps/glfw/include/ ./deps/glad/include/ ./inc)
|
||||||
|
|
|
@ -40,7 +40,9 @@ int main()
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
// glEnable(GL_BLEND);
|
#ifdef BLENDING
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||||
|
@ -73,8 +75,10 @@ int main()
|
||||||
|
|
||||||
// configure global opengl state
|
// configure global opengl state
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// glEnable(GL_BLEND);
|
#ifdef BLENDING
|
||||||
// glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
|
||||||
|
#endif
|
||||||
// glEnable(GL_DEPTH_TEST);
|
// glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
// build and compile our shader zprogram
|
// build and compile our shader zprogram
|
||||||
|
@ -296,19 +300,21 @@ int main()
|
||||||
// glDepthMask(GL_FALSE);
|
// glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
// render transparent objects with blending enabled
|
// render transparent objects with blending enabled
|
||||||
// glEnable(GL_BLEND);
|
#ifdef BLENDING
|
||||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glEnable(GL_BLEND);
|
||||||
// for (unsigned int i = 5; i < 10; i++)
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
// {
|
for (unsigned int i = 5; i < 10; i++)
|
||||||
// ourShader.setIVec2("index", cubeTextures[i]);
|
{
|
||||||
|
ourShader.setIVec2("index", cubeTextures[i]);
|
||||||
|
|
||||||
// // calculate the model matrix for each object and pass it to shader before drawing
|
// 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
|
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
|
||||||
// model = glm::translate(model, glm::vec3(cubePositions[i]));
|
model = glm::translate(model, glm::vec3(cubePositions[i]));
|
||||||
// ourShader.setMat4("model", model);
|
ourShader.setMat4("model", model);
|
||||||
// glDrawArrays(GL_TRIANGLES, 0, 36);
|
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||||
// }
|
}
|
||||||
// glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
#endif
|
||||||
|
|
||||||
// glDisable(GL_DEPTH_TEST);
|
// glDisable(GL_DEPTH_TEST);
|
||||||
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
|
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
|
||||||
|
|
Loading…
Reference in New Issue