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|
|
|
|
|
5, 6, 7,
|
|
|
|
|
7, 8, 9,
|
|
|
|
|
9, 10, 11,
|
|
|
|
|
11, 12, 13, |
|
|
|
|
0, 1, 3,
|
|
|
|
|
3, 4, 5,
|
|
|
|
|
5, 6, 7,
|
|
|
|
|
7, 8, 9,
|
|
|
|
|
9, 10, 11,
|
|
|
|
|
11, 12, 13, |
|
|
|
|
0, 1, 3,
|
|
|
|
|
3, 4, 5,
|
|
|
|
|
5, 6, 7,
|
|
|
|
|
7, 8, 9,
|
|
|
|
|
9, 10, 11,
|
|
|
|
|
11, 12, 13, |
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); |
|
|
|
@ -78,10 +150,15 @@ int main() { |
|
|
|
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); |
|
|
|
|
|
|
|
|
|
Renderer::Obj2D ro(verts, indices); |
|
|
|
|
renderer.spawnObject(ro); |
|
|
|
|
renderer.setCamera(glm::vec3(0.0f, 0.0f, -8.0f)); |
|
|
|
|
Renderer::Obj2D ro2(verts, indices); |
|
|
|
|
|
|
|
|
|
ro2.setTexture("assets/textures/meep.jpg"); |
|
|
|
|
ro.setTexture(RUSTY_METAL_TEXTURE); |
|
|
|
|
|
|
|
|
|
renderer.spawnObject(ro); |
|
|
|
|
renderer.spawnObject(ro2); |
|
|
|
|
renderer.setCamera(glm::vec3(0.0f, 0.0f, -4.0f)); |
|
|
|
|
|
|
|
|
|
// Window width & height
|
|
|
|
|
while (!glfwWindowShouldClose(win)) { |
|
|
|
|
// Handle input
|
|
|
|
@ -93,7 +170,7 @@ int main() { |
|
|
|
|
/* OBJECT RENDERING */ |
|
|
|
|
float time = glfwGetTime(); |
|
|
|
|
float gVal = sin(time) / 10.5f; |
|
|
|
|
renderer.setCamera(glm::vec3(0.0f, 0.0f, -gVal)); |
|
|
|
|
renderer.setCamera(glm::vec3(0.0f, 0.0f, gVal/10.0f)); |
|
|
|
|
|
|
|
|
|
// Transformation
|
|
|
|
|
float rotang = time; |
|
|
|
|