diff --git a/LearnOpenGL/OpenGLWrapper.cpp b/LearnOpenGL/OpenGLWrapper.cpp index ca6868faf874d61ca96029e3b311befed17ac0c5..f44f78bd9938d02ba9e70f87fc64bef2f78d2b27 100644 --- a/LearnOpenGL/OpenGLWrapper.cpp +++ b/LearnOpenGL/OpenGLWrapper.cpp @@ -335,7 +335,7 @@ GLuint allocate_VBO(const GLuint attribIndex, std::vector<glm::vec2> *VBO) glBufferData(GL_ARRAY_BUFFER, VBO->size() * sizeof(glm::vec2), &(VBO->front()), GL_STATIC_DRAW); glEnableVertexAttribArray(attribIndex); - glVertexAttribPointer(attribIndex, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); + glVertexAttribPointer(attribIndex, 2, GL_FLOAT, GL_FALSE, 0, (void*)0); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/LearnOpenGL/Source.cpp b/LearnOpenGL/Source.cpp index 03ab6df728d3bb7fb77c1e87c2213af7002cd22f..1333b7fe06cf070ec4dfbb237a25f1a859fa973d 100644 --- a/LearnOpenGL/Source.cpp +++ b/LearnOpenGL/Source.cpp @@ -71,7 +71,7 @@ int main() auto defaultMaterial = new Material(lightmap, orange, transparent); auto cubeMaterial = new Material(lightmap, container_diffuse, container_specular); - auto planeMaterial = new Material(lightmap, magenta, white); + auto planeMaterial = new Material(lightmap, container_diffuse, transparent); auto teapot = make_render_object(make_mesh("teapot.obj")); { @@ -120,6 +120,14 @@ int main() cube3->set_material(cubeMaterial); } + auto cube4 = make_render_object(cube); + { + cube4->set_translate(glm::vec3(0.0f, 10.0f, 0.0f)); + } + { + cube4->set_material(cubeMaterial); + } + while (!glfwWindowShouldClose(window)) { double currentFrame = glfwGetTime(); @@ -137,6 +145,7 @@ int main() cube2->render(camera); cube3->render(camera); plane->render(camera); + cube4->render(camera); } glfwSwapBuffers(window); diff --git a/Models/cube.obj b/Models/cube.obj index cc2599259518bc92be74f605e7419f179beee428..d89113f016ba63304ddfd102eaeb598e22ca0799 100644 --- a/Models/cube.obj +++ b/Models/cube.obj @@ -6,23 +6,15 @@ v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -1.000000 -v 0.999999 1.000000 1.000001 +v 1.000000 1.000000 1.000000 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 -vt 0.748573 0.750412 -vt 0.749279 0.501284 -vt 0.999110 0.501077 -vt 0.999455 0.750380 -vt 0.250471 0.500702 -vt 0.249682 0.749677 -vt 0.001085 0.750380 -vt 0.001517 0.499994 -vt 0.499422 0.500239 -vt 0.500149 0.750166 -vt 0.748355 0.998230 -vt 0.500193 0.998728 -vt 0.498993 0.250415 -vt 0.748953 0.250920 + +vt 0.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 + vn 0.000000 0.000000 -1.000000 vn -1.000000 -0.000000 -0.000000 vn -0.000000 -0.000000 1.000000 @@ -32,15 +24,15 @@ vn 1.000000 0.000000 0.000001 vn 0.000000 1.000000 -0.000000 vn -0.000000 -1.000000 0.000000 -f 5/1/1 1/2/1 4/3/1 -f 5/1/1 4/3/1 8/4/1 -f 3/5/2 7/6/2 8/7/2 -f 3/5/2 8/7/2 4/8/2 -f 2/9/3 6/10/3 3/5/3 -f 6/10/4 7/6/4 3/5/4 -f 1/2/5 5/1/5 2/9/5 -f 5/1/6 6/10/6 2/9/6 -f 5/1/7 8/11/7 6/10/7 -f 8/11/7 7/12/7 6/10/7 -f 1/2/8 2/9/8 3/13/8 -f 1/2/8 3/13/8 4/14/8 \ No newline at end of file +f 5/4/1 1/3/1 4/1/1 +f 5/4/1 4/1/1 8/2/1 +f 3/3/2 7/4/2 8/2/2 +f 3/3/2 8/2/2 4/1/2 +f 2/3/3 6/4/3 3/1/3 +f 6/4/4 7/2/4 3/1/4 +f 1/3/5 5/4/5 2/1/5 +f 5/4/6 6/2/6 2/1/6 +f 5/4/7 8/2/7 6/3/7 +f 8/2/7 7/1/7 6/3/7 +f 1/4/8 2/3/8 3/1/8 +f 1/4/8 3/1/8 4/2/8 \ No newline at end of file