summaryrefslogtreecommitdiff
path: root/demo.c
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-05-21 10:16:59 -0500
committersanine-a <sanine.not@pm.me>2020-05-21 10:16:59 -0500
commit8b7e8a1a3e77b4e3b56ea9025af8b254faa16c13 (patch)
tree3f39bb785d5f1df1f026589a6cc1aa2749e30e6d /demo.c
parent9b66b322b600ab0db66cb6f3ff5a7c4196b9193f (diff)
add textured cube primitive
Diffstat (limited to 'demo.c')
-rw-r--r--demo.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/demo.c b/demo.c
index 2213dc7..e2ef74a 100644
--- a/demo.c
+++ b/demo.c
@@ -132,10 +132,8 @@ void draw() {
honey_shader_set_matrix_4fv(shader, "model", (float*) model);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, container.texture_id);
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, happy_face.texture_id);
+ honey_texture_use(container, 0);
+ honey_texture_use(happy_face, 1);
honey_mesh_draw(cube, shader);
@@ -164,43 +162,13 @@ int main() {
return 1;
}
- /* create triangle */
- /*float vertices[] = {
- /* positions colors tex coords /
- -0.5, -0.5, 0.5, 1.0, 0.0, 0.0, 0.0, 0.0,
- 0.5, -0.5, 0.5, 0.0, 1.0, 0.0, 1.0, 0.0,
- -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 0.0, 1.0,
- 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0,
- -0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 0.0, 0.0,
- 0.5, -0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0,
- -0.5, 0.5, -0.5, 0.0, 0.0, 1.0, 0.0, 1.0,
- 0.5, 0.5, -0.5, 1.0, 1.0, 1.0, 1.0, 1.0 };
-
- unsigned int indices[] = { 0, 1, 2,
- 1, 2, 3,
- 4, 5, 6,
- 5, 6, 7,
- 0, 2, 4,
- 2, 4, 6,
- 1, 3, 5,
- 3, 5, 7,
- 2, 3, 6,
- 3, 6, 7,
- 0, 1, 4,
- 1, 4, 5 };
-
- unsigned int attribute_sizes[] = { 3, 3, 2 }; /* position, color, texture coordinate /
- enum honey_mesh_result result = honey_mesh_new(&cube,
- vertices, 8, 3, attribute_sizes,
- indices,
- sizeof(indices)/sizeof(unsigned int)); */
- if (honey_mesh_new_cube(&cube, 1, 1, 1) != MESH_OK) {
+ if (honey_mesh_new_textured_cube(&cube, 1, 1, 1) != MESH_OK) {
fprintf(stderr, "Failed to load cube\n");
return 1;
}
- /*honey_shader_set_int(shader, "boxTexture", 0);
- honey_shader_set_int(shader, "happyTexture", 1);*/
+ honey_shader_set_int(shader, "box_texture", 0);
+ honey_shader_set_int(shader, "happy_texture", 1);
glm_mat4_identity(model);
glm_rotate_x(model, glm_rad(-55), model);