|
|
@ -49,6 +49,8 @@ int main() { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renderer::Renderer3D renderer(win); |
|
|
|
|
|
|
|
|
|
|
|
glfwMakeContextCurrent(win); |
|
|
|
glfwMakeContextCurrent(win); |
|
|
|
|
|
|
|
|
|
|
|
if ( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) ) { |
|
|
|
if ( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) ) { |
|
|
@ -56,18 +58,18 @@ int main() { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float verts[] = { |
|
|
|
std::vector<float> verts({ |
|
|
|
0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, |
|
|
|
0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, |
|
|
|
-0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, |
|
|
|
-0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, |
|
|
|
-0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f |
|
|
|
-0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f |
|
|
|
}; |
|
|
|
}); |
|
|
|
// Vert struc: x y z r g b tx ty
|
|
|
|
// Vert struc: x y z r g b tx ty
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int indices[] = {
|
|
|
|
std::vector<unsigned int> indices({
|
|
|
|
0, 1, 3,
|
|
|
|
0, 1, 3,
|
|
|
|
1, 2, 3
|
|
|
|
1, 2, 3
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); |
|
|
|
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); |
|
|
|
glfwSetFramebufferSizeCallback(win, framebuffer_size_callback); |
|
|
|
glfwSetFramebufferSizeCallback(win, framebuffer_size_callback); |
|
|
@ -75,13 +77,8 @@ int main() { |
|
|
|
float borderColor[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
|
|
|
float borderColor[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
|
|
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); |
|
|
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); |
|
|
|
|
|
|
|
|
|
|
|
printf("%u %u\n", sizeof(indices), sizeof(verts)); |
|
|
|
Renderer::RenderObject ro(verts, indices); |
|
|
|
Renderer::Obj2D ro2(indices, sizeof(indices), verts, sizeof(verts)); |
|
|
|
renderer.spawnObject(ro); |
|
|
|
ro2.setTexture(RUSTY_METAL_TEXTURE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Renderer::RenderObject ro(verts, indices);
|
|
|
|
|
|
|
|
// Renderer::Renderer3D renderer(win);
|
|
|
|
|
|
|
|
// renderer.spawnObject(ro);
|
|
|
|
|
|
|
|
// ro.setTexture(RUSTY_METAL_TEXTURE);
|
|
|
|
// ro.setTexture(RUSTY_METAL_TEXTURE);
|
|
|
|
|
|
|
|
|
|
|
|
// Window width & height
|
|
|
|
// Window width & height
|
|
|
@ -102,10 +99,9 @@ int main() { |
|
|
|
glm::mat4 T = glm::mat4(1.0f); |
|
|
|
glm::mat4 T = glm::mat4(1.0f); |
|
|
|
T = glm::rotate(T, rotang, glm::vec3(1.0, 0.0, 1.0)); |
|
|
|
T = glm::rotate(T, rotang, glm::vec3(1.0, 0.0, 1.0)); |
|
|
|
T = glm::scale(T, glm::vec3(0.5, 0.5, 0.5)); |
|
|
|
T = glm::scale(T, glm::vec3(0.5, 0.5, 0.5)); |
|
|
|
ro2.transform(T); |
|
|
|
ro.transform(T); |
|
|
|
ro2.render(win); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//renderer.render();
|
|
|
|
renderer.render(); |
|
|
|
|
|
|
|
|
|
|
|
// glfw
|
|
|
|
// glfw
|
|
|
|
glfwSwapBuffers(win); |
|
|
|
glfwSwapBuffers(win); |
|
|
|