void templateAppDraw(void) { static const float POSITION[8] = { 0.0f, 0.0f, // Down left (pivot point) 1.0f, 0.0f, // Up left 0.0f, 1.0f, // Down right 1.0f, 1.0f // Up right }; static const float COLOR[16] = { 1.0f, 0.0f, 0.0f, 1.0f, // Red 0.0f, 1.0f, 0.0f, 1.0f, // Green 0.0f, 0.0f, 1.0f, 1.0f, // Blue 1.0f, 1.0f, 0.0f, 1.0f // Yellow }; glClearColor(0.5f, 0.5f, 0.5f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); GFX_set_matrix_mode(MODELVIEW_MATRIX); GFX_load_identity(); GFX_scale(100.0f, 100.0f, 0.0f); if (program->pid) { char attribute, uniform; glUseProgram(program->pid); uniform = PROGRAM_get_uniform_location(program, (char *)"MODELVIEWPROJECTIONMATRIX"); glUniformMatrix4fv(uniform, 1 /* How many 4x4 matrix */ , GL_FALSE /* Transpose the matrix? */ , (float *)GFX_get_modelview_projection_matrix()); attribute = PROGRAM_get_vertex_attrib_location(program, (char *)"POSITION"); glEnableVertexAttribArray(attribute); glVertexAttribPointer(attribute, 2, GL_FLOAT, GL_FALSE, 0, POSITION); attribute = PROGRAM_get_vertex_attrib_location(program, (char *)"COLOR"); glEnableVertexAttribArray(attribute); glVertexAttribPointer(attribute, 4, GL_FLOAT, GL_FALSE, 0, COLOR); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } }
void GFX_set_orthographic( float screen_ratio, float scale, float aspect_ratio, float clip_start, float clip_end, float screen_orientation ) { scale = ( scale * 0.5f ) * aspect_ratio; GFX_ortho( -1.0f, 1.0f, -screen_ratio, screen_ratio, clip_start, clip_end ); GFX_scale( 1.0f / scale, 1.0f / scale, 1.0f ); if( screen_orientation ) GFX_rotate( screen_orientation, 0.0f, 0.0f, 1.0f ); }