diff --git a/build/.cmake/api/v1/reply/index-2024-01-20T06-42-18-0124.json b/build/.cmake/api/v1/reply/index-2024-01-20T07-04-31-0894.json similarity index 100% rename from build/.cmake/api/v1/reply/index-2024-01-20T06-42-18-0124.json rename to build/.cmake/api/v1/reply/index-2024-01-20T07-04-31-0894.json diff --git a/build/CMakeFiles/GraphicsTest.dir/main.cpp.obj b/build/CMakeFiles/GraphicsTest.dir/main.cpp.obj index c1cae2c..e37e9ed 100644 Binary files a/build/CMakeFiles/GraphicsTest.dir/main.cpp.obj and b/build/CMakeFiles/GraphicsTest.dir/main.cpp.obj differ diff --git a/build/CMakeFiles/GraphicsTest.dir/objects.a b/build/CMakeFiles/GraphicsTest.dir/objects.a index 28c870a..94084cd 100644 Binary files a/build/CMakeFiles/GraphicsTest.dir/objects.a and b/build/CMakeFiles/GraphicsTest.dir/objects.a differ diff --git a/build/GraphicsTest.exe b/build/GraphicsTest.exe index 5f33270..1993414 100644 Binary files a/build/GraphicsTest.exe and b/build/GraphicsTest.exe differ diff --git a/build/Testing/20240120-0638/Test.xml b/build/Testing/20240120-0638/Test.xml index 680c00f..a422580 100644 --- a/build/Testing/20240120-0638/Test.xml +++ b/build/Testing/20240120-0638/Test.xml @@ -24,11 +24,11 @@ ProcessorClockFrequency="3193" > - Jan 20 00:42 Central Standard Time - 1705732938 + Jan 20 01:04 Central Standard Time + 1705734272 - Jan 20 00:42 Central Standard Time - 1705732938 + Jan 20 01:04 Central Standard Time + 1705734272 0 diff --git a/build/Testing/Temporary/LastTest_20240120-0638.log b/build/Testing/Temporary/LastTest_20240120-0638.log index 5b1368d..2b09831 100644 --- a/build/Testing/Temporary/LastTest_20240120-0638.log +++ b/build/Testing/Temporary/LastTest_20240120-0638.log @@ -1,3 +1,3 @@ -Start testing: Jan 20 00:42 Central Standard Time +Start testing: Jan 20 01:04 Central Standard Time ---------------------------------------------------------- -End testing: Jan 20 00:42 Central Standard Time +End testing: Jan 20 01:04 Central Standard Time diff --git a/data.cpp b/data.cpp index 8057f91..cccf6d2 100644 --- a/data.cpp +++ b/data.cpp @@ -1,12 +1,52 @@ float vertices[] = { - // Positions // Colors // Texture Coords - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, - -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f + // Positions // Texture Coords + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, + + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, + + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + -0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 1.0f, 1.0f + }; +/* unsigned int indices[] = { // note that we start from 0! 0, 1, 3, // first triangle 1, 2, 3 }; +*/ \ No newline at end of file diff --git a/main.cpp b/main.cpp index 3f6caaf..02e3f44 100644 --- a/main.cpp +++ b/main.cpp @@ -45,18 +45,16 @@ int main() { glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)0); - glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)(3*sizeof(float))); - glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)(6*sizeof(float))); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void*)0); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5*sizeof(float), (void*)(3*sizeof(float))); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); - glEnableVertexAttribArray(2); // Element Buffers - unsigned int EBO; - glGenBuffers(1, &EBO); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); + // unsigned int EBO; + // glGenBuffers(1, &EBO); + // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); + // glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); // Use and set shader Shader myShader("../shad/vert.vs", "../shad/frag.fs"); @@ -76,7 +74,7 @@ int main() { glBindTexture(GL_TEXTURE_2D, texture1); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width1, height1, 0, GL_RGB, GL_UNSIGNED_BYTE, data1); glGenerateMipmap(GL_TEXTURE_2D); - + glActiveTexture(GL_TEXTURE1); glGenTextures(1, &texture2); glBindTexture(GL_TEXTURE_2D, texture2); @@ -89,27 +87,43 @@ int main() { } else { std::cout << "COULD NOT LOAD TEXTUREs!\n"; } - stbi_image_free(data1); stbi_image_free(data2); // Camera Work - glm::mat4 trans = glm::rotate(glm::mat4(1.0f), (float)glfwGetTime(), glm::vec3(0.0f, 0.0f, 1.0f)); - unsigned int transLoc = glGetUniformLocation(myShader.id, "transform"); - glUniformMatrix4fv(transLoc, 1, GL_FALSE, glm::value_ptr(trans)); + glm::mat4 model = glm::mat4(1.0f); + model = glm::rotate(model, glm::radians(-55.0f), glm::vec3(1.0f, 0.0f, 0.0f)); + glm::mat4 view = glm::mat4(1.0f); + view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f)); + + glm::mat4 projection; + projection = glm::perspective(glm::radians(45.0f), 800.0f/600.0f, 0.1f, 100.0f); + + int modelLoc, viewLoc, projLoc; + modelLoc = glGetUniformLocation(myShader.id, "model"); + viewLoc = glGetUniformLocation(myShader.id, "view"); + projLoc = glGetUniformLocation(myShader.id, "projection"); + + glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); + glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view)); + glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection)); + + glEnable(GL_DEPTH_TEST); // Window loop while(!glfwWindowShouldClose(window)) { // Input checking processInput(window); + // Rotate Model + model = glm::rotate(glm::mat4(1.0f), (float)glfwGetTime() * glm::radians(50.0f), glm::vec3(0.5f, 1.0f, 0.0f)); + glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); + // Rendering Loop - trans = glm::rotate(glm::mat4(1.0f), (float)glfwGetTime(), glm::vec3(0.0f, 0.0f, 1.0f)); - glUniformMatrix4fv(transLoc, 1, GL_FALSE, glm::value_ptr(trans)); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindVertexArray(VAO); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); + glDrawArrays(GL_TRIANGLES, 0, 36); // Events and buffer swap glfwPollEvents(); diff --git a/shad/frag.fs b/shad/frag.fs index 58b46b1..d7e8c89 100644 --- a/shad/frag.fs +++ b/shad/frag.fs @@ -1,6 +1,5 @@ #version 330 core -in vec4 vertexColor; in vec2 textureCoord; out vec4 FragColor; @@ -10,6 +9,5 @@ uniform sampler2D texture2; void main() { FragColor = mix(texture(texture1, textureCoord), - texture(texture2, textureCoord), 0.2); - + texture(texture2, textureCoord), 0.3); } \ No newline at end of file diff --git a/shad/vert.vs b/shad/vert.vs index 0185987..a0ad777 100644 --- a/shad/vert.vs +++ b/shad/vert.vs @@ -1,16 +1,15 @@ #version 330 core layout(location=0) in vec3 aPos; -layout(location=1) in vec3 vColor; -layout(location=2) in vec2 tCoord; +layout(location=1) in vec2 tCoord; -out vec4 vertexColor; out vec2 textureCoord; -uniform mat4 transform; +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; void main() { - gl_Position = transform * vec4(aPos, 1.0); - vertexColor = vec4(vColor, 1.0); + gl_Position = projection * view * model * vec4(aPos, 1.0); textureCoord = tCoord; } \ No newline at end of file