Sphere visible but still buggy...

master
Martin Felis 2020-10-29 18:03:50 +01:00
parent 0622c53d29
commit 6dd7d27777
1 changed files with 14 additions and 14 deletions

View File

@ -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 =