From ba04cf73d09cffeb35ca472f32e0165294f93a72 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 Jan 2012 23:32:30 +0900 Subject: [PATCH] Add my test tetrahedrons. --- libs/video/renderer/glsl/glsl_alias.c | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libs/video/renderer/glsl/glsl_alias.c b/libs/video/renderer/glsl/glsl_alias.c index f134c46d8..f71018f5c 100644 --- a/libs/video/renderer/glsl/glsl_alias.c +++ b/libs/video/renderer/glsl/glsl_alias.c @@ -150,6 +150,20 @@ R_InitAlias (void) void R_DrawAlias (void) { +#ifdef TETRAHEDRON + static aliasvrt_t debug_verts[] = { + {{0,0,0},{0,0,0}}, + {{255,255,0},{0,300,0}}, + {{0,255,255},{300,300,0}}, + {{255,0,255},{300,0,0}}, + }; + static GLushort debug_indices[] = { + 0, 1, 2, + 0, 3, 1, + 1, 3, 2, + 0, 2, 3, + }; +#endif static quat_t color = { 1, 1, 1, 1}; static vec3_t lightvec = { -1, 0, 0 }; //FIXME float ambient = 128; //FIXME @@ -193,8 +207,10 @@ R_DrawAlias (void) qfglBindTexture (GL_TEXTURE_2D, skin->texnum); +#ifndef TETRAHEDRON qfglBindBuffer (GL_ARRAY_BUFFER, hdr->posedata); qfglBindBuffer (GL_ELEMENT_ARRAY_BUFFER, hdr->commands); +#endif qfglVertexAttrib4fv (quake_mdl.color.location, color); qfglUniform1f (quake_mdl.ambient.location, ambient); @@ -204,6 +220,7 @@ R_DrawAlias (void) qfglUniformMatrix4fv (quake_mdl.mvp_matrix.location, 1, false, mvp_mat); qfglUniformMatrix3fv (quake_mdl.norm_matrix.location, 1, false, norm_mat); +#ifndef TETRAHEDRON qfglVertexAttribPointer (quake_mdl.vertex.location, 3, GL_UNSIGNED_BYTE, 0, sizeof (aliasvrt_t), pose + field_offset (aliasvrt_t, vertex)); @@ -211,6 +228,17 @@ R_DrawAlias (void) 0, sizeof (aliasvrt_t), pose + field_offset (aliasvrt_t, stn)); qfglDrawElements (GL_TRIANGLES, hdr->mdl.numtris, GL_UNSIGNED_SHORT, 0); +#else + qfglVertexAttribPointer (quake_mdl.vertex.location, 3, GL_UNSIGNED_BYTE, + 0, sizeof (aliasvrt_t), + &debug_verts[0].vertex); + qfglVertexAttribPointer (quake_mdl.stn.location, 3, GL_SHORT, + 0, sizeof (aliasvrt_t), + &debug_verts[0].stn); + qfglDrawElements (GL_TRIANGLES, + sizeof (debug_indices) / sizeof (debug_indices[0]), + GL_UNSIGNED_SHORT, debug_indices); +#endif } // All alias models are drawn in a batch, so avoid thrashing the gl state