From 6dd7d277773a20df1862e79e85db16e453cce6cb Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Thu, 29 Oct 2020 18:03:50 +0100 Subject: [PATCH] Sphere visible but still buggy... --- src/srender.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/srender.h b/src/srender.h index 301ebb5..80352d9 100644 --- a/src/srender.h +++ b/src/srender.h @@ -426,10 +426,10 @@ void init_debug_meshes() { // gCubeMesh.vao_id = gDebugShapesVAId; gCubeMesh.vb_id = gDebugShapesVBOId; - gCubeMesh.nvertices = 48; + gCubeMesh.nvertices = 24; // clang-format off - srvrtxdata cube_vertices[48] = { + srvrtxdata cube_vertices[24] = { // +x { 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 255, 0, 0, 255}, { 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 255, 0, 0, 255}, @@ -509,8 +509,8 @@ void init_debug_meshes() { gUVSphereMesh.vb_id = gDebugShapesVBOId; // loosely based on http://www.songho.ca/opengl/gl_sphere.html - int stack_count = 4; - int sector_count = 4; + int stack_count = 14; + int sector_count = 14; gUVSphereMesh.nvertices = (stack_count + 1) * (sector_count + 1); gLog("UVsphere vertices: %d", gUVSphereMesh.nvertices); @@ -549,9 +549,9 @@ void init_debug_meshes() { vertex->s = (float)j / sector_count; vertex->t = (float)i / stack_count; - vertex->r = 128; - vertex->g = 128; - vertex->b = 128; + vertex->r = 228; + vertex->g = 228; + vertex->b = 228; vertex->a = 255; } } @@ -581,16 +581,16 @@ void init_debug_meshes() { // 2 triangles per sector excluding first and last stacks // k1 => k2 => k1+1 if (i != 0) { - uvsphere_indices[++tri_index] = k1; - uvsphere_indices[++tri_index] = k2; uvsphere_indices[++tri_index] = k1 + 1; + uvsphere_indices[++tri_index] = k2; + uvsphere_indices[++tri_index] = k1; } // k1+1 => k2 => k2+1 if (i != (stack_count - 1)) { - uvsphere_indices[++tri_index] = k1 + 1; - uvsphere_indices[++tri_index] = k2; uvsphere_indices[++tri_index] = k2 + 1; + uvsphere_indices[++tri_index] = k2; + uvsphere_indices[++tri_index] = k1 + 1; } gLog("tri_index = %d", tri_index); @@ -612,7 +612,7 @@ void init_debug_meshes() { free(uvsphere_indices); - gUVSphereMesh.mode = GL_TRIANGLES; + gUVSphereMesh.mode = GL_TRIANGLE_STRIP; gUVSphereMesh.count = gUVSphereMesh.nindices; glBindVertexArray(0); @@ -802,8 +802,8 @@ void srndr_render(srndr* srndr, srview* sview, srcmdbuf* scmdbuf) { glClearColor(0.1f, 0.1f, 0.1f, 0.1f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); - // glEnable(GL_CULL_FACE); - // glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); glUseProgram(gDefaultShader.program_id); GLint view_mat_loc =