enum piglit_result piglit_display(void) { bool pass = true; float green[] = {0, 1, 0}; float blue[] = {0, 0, 1}; glClearColor(blue[0], blue[1], blue[2], 1.0); glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); /* Top Quad */ glDrawRangeElementsBaseVertex(GL_TRIANGLES, 0, 3, 6, GL_UNSIGNED_INT, NULL, 0); /* Bot Quad */ glDrawRangeElementsBaseVertex(GL_TRIANGLES, 4, 7, 6, GL_UNSIGNED_INT, (GLvoid *)(sizeof(GLuint)*6), 2); /* Check for test pass */ pass = piglit_probe_pixel_rgb(100, 175, green) && pass; pass = piglit_probe_pixel_rgb(100, 125, blue) && pass; pass = piglit_probe_pixel_rgb(100, 75, blue) && pass; pass = piglit_probe_pixel_rgb(100, 25, green) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void VertexManager::Draw(u32 stride) { u32 index_size = IndexGenerator::GetIndexLen(); u32 max_index = IndexGenerator::GetNumVerts(); GLenum primitive_mode = 0; switch (current_primitive_type) { case PRIMITIVE_POINTS: primitive_mode = GL_POINTS; break; case PRIMITIVE_LINES: primitive_mode = GL_LINES; break; case PRIMITIVE_TRIANGLES: primitive_mode = g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? GL_TRIANGLE_STRIP : GL_TRIANGLES; break; } if (g_ogl_config.bSupportsGLBaseVertex) { glDrawRangeElementsBaseVertex(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset, (GLint)s_baseVertex); } else { glDrawRangeElements(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr+s_index_offset); } INCSTAT(stats.thisFrame.numIndexedDrawCalls); }
void VertexManager::Draw(u32 stride) { u32 index_size = IndexGenerator::GetIndexLen(); u32 max_index = IndexGenerator::GetNumVerts(); GLenum primitive_mode = 0; static const GLenum modes[3] = { GL_POINTS, GL_LINES, GL_TRIANGLES }; primitive_mode = modes[current_primitive_type]; bool cull_changed = primitive_mode != GL_TRIANGLES && bpmem.genMode.cullmode > 0; if(cull_changed) { glDisable(GL_CULL_FACE); } if (g_ogl_config.bSupportsGLBaseVertex) { glDrawRangeElementsBaseVertex(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr + s_index_offset, (GLint)s_baseVertex); } else { glDrawRangeElements(primitive_mode, 0, max_index, index_size, GL_UNSIGNED_SHORT, (u8*)nullptr + s_index_offset); } INCSTAT(stats.thisFrame.numDrawCalls); if (cull_changed) static_cast<Renderer*>(g_renderer.get())->SetGenerationMode(); }
inline void VL_glDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, int basevertex) { if (glDrawRangeElementsBaseVertex) glDrawRangeElementsBaseVertex(mode, start, end, count, type, (void*)indices, basevertex); else VL_UNSUPPORTED_FUNC(); }
inline void drawRangeElementsBaseVertex( DrawRangeElementsBaseVertexMode mode, GLuint start, GLuint end, GLsizei count, DrawRangeElementsBaseVertexType type, GLvoid *indices, GLint basevertex) { glDrawRangeElementsBaseVertex( GLenum(mode), start,end,count, GLenum(type),indices,basevertex ); }
void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr indexOffset) #endif { const Implementation::MeshState& state = *Context::current()->state().mesh; /* Nothing to draw */ if(!count || !instanceCount) return; (this->*state.bindImplementation)(); /* Non-instanced mesh */ if(instanceCount == 1) { /* Non-indexed mesh */ if(!_indexBuffer) { glDrawArrays(GLenum(_primitive), baseVertex, count); /* Indexed mesh with base vertex */ } else if(baseVertex) { #ifndef MAGNUM_TARGET_GLES /* Indexed mesh with specified range */ if(indexEnd) { glDrawRangeElementsBaseVertex(GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), baseVertex); /* Indexed mesh */ } else glDrawElementsBaseVertex(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), baseVertex); #else CORRADE_ASSERT(false, "Mesh::draw(): desktop OpenGL is required for base vertex specification in indexed meshes", ); #endif /* Indexed mesh */ } else { /** @todo re-enable for WebGL 2.0 when glDrawRangeElements() no longer crashes Firefox */ #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /* Indexed mesh with specified range */ if(indexEnd) { glDrawRangeElements(GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset)); /* Indexed mesh */ } else #endif { glDrawElements(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset)); } } /* Instanced mesh */ } else {
void opengl_render_model_program(model_material* material_info, indexed_vertex_source *vert_source, vertex_buffer* bufferp, buffer_data *datap) { GL_state.Texture.SetShaderMode(GL_TRUE); opengl_tnl_set_model_material(material_info); GLubyte *ibuffer = reinterpret_cast<GLubyte*>(vert_source->Index_offset); GLenum element_type = (datap->flags & VB_FLAG_LARGE_INDEX) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT; Assert(vert_source); Assertion(vert_source->Vbuffer_handle >= 0, "The vertex data must be located in a GPU buffer!"); Assertion(vert_source->Ibuffer_handle >= 0, "The index values must be located in a GPU buffer!"); // basic setup of all data opengl_bind_vertex_layout(bufferp->layout, opengl_buffer_get_id(GL_ARRAY_BUFFER, vert_source->Vbuffer_handle), opengl_buffer_get_id(GL_ELEMENT_ARRAY_BUFFER, vert_source->Ibuffer_handle)); // If GL_ARB_gpu_shader5 is supprted then the instancing is handled by the geometry shader if ( !GLAD_GL_ARB_gpu_shader5 && Rendering_to_shadow_map ) { glDrawElementsInstancedBaseVertex(GL_TRIANGLES, (GLsizei) datap->n_verts, element_type, ibuffer + datap->index_offset, 4, (GLint) (vert_source->Base_vertex_offset + bufferp->vertex_num_offset)); } else { if (Cmdline_drawelements) { glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei) datap->n_verts, element_type, ibuffer + datap->index_offset, (GLint) (vert_source->Base_vertex_offset + bufferp->vertex_num_offset)); } else { glDrawRangeElementsBaseVertex(GL_TRIANGLES, datap->i_first, datap->i_last, (GLsizei) datap->n_verts, element_type, ibuffer + datap->index_offset, (GLint) (vert_source->Base_vertex_offset + bufferp->vertex_num_offset)); } } GL_state.Texture.SetShaderMode(GL_FALSE); }
void opengl_render_model_program(model_material* material_info, indexed_vertex_source *vert_source, vertex_buffer* bufferp, buffer_data *datap) { GL_state.Texture.SetShaderMode(GL_TRUE); opengl_tnl_set_model_material(material_info); GLubyte *ibuffer = NULL; size_t start = 0; size_t end = (datap->n_verts - 1); size_t count = (end - (start * 3) + 1); GLenum element_type = (datap->flags & VB_FLAG_LARGE_INDEX) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT; Assert(vert_source); // basic setup of all data opengl_init_arrays(vert_source, bufferp); if ( vert_source->Ibuffer_handle >= 0 ) { opengl_bind_buffer_object(vert_source->Ibuffer_handle); } else { ibuffer = (GLubyte*)vert_source->Index_list; } if ( Rendering_to_shadow_map ) { glDrawElementsInstancedBaseVertex(GL_TRIANGLES, (GLsizei) count, element_type, ibuffer + (datap->index_offset + start), 4, (GLint)bufferp->vertex_num_offset); } else { if ( Cmdline_drawelements ) { glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei) count, element_type, ibuffer + (datap->index_offset + start), (GLint)bufferp->vertex_num_offset); } else { glDrawRangeElementsBaseVertex(GL_TRIANGLES, datap->i_first, datap->i_last, (GLsizei) count, element_type, ibuffer + (datap->index_offset + start), (GLint)bufferp->vertex_num_offset); } } GL_state.Texture.SetShaderMode(GL_FALSE); }
void VertexArray::drawRangeElementsBaseVertex(const GLenum mode, const GLuint start, const GLuint end, const GLsizei count, const GLenum type, const void* indices, const GLint baseVertex) const { bind(); glDrawRangeElementsBaseVertex(mode, start, end, count, type, const_cast<void*>(indices), baseVertex); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL32_nglDrawRangeElementsBaseVertexBO(JNIEnv *env, jclass clazz, jint mode, jint start, jint end, jint count, jint type, jlong indices_buffer_offset, jint basevertex, jlong function_pointer) { const GLvoid *indices_address = (const GLvoid *)(intptr_t)offsetToPointer(indices_buffer_offset); glDrawRangeElementsBaseVertexPROC glDrawRangeElementsBaseVertex = (glDrawRangeElementsBaseVertexPROC)((intptr_t)function_pointer); glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices_address, basevertex); }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL32C_nglDrawRangeElementsBaseVertex(JNIEnv *__env, jclass clazz, jint mode, jint start, jint end, jint count, jint type, jlong indicesAddress, jint basevertex) { glDrawRangeElementsBaseVertexPROC glDrawRangeElementsBaseVertex = (glDrawRangeElementsBaseVertexPROC)tlsGetFunction(649); intptr_t indices = (intptr_t)indicesAddress; UNUSED_PARAM(clazz) glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, basevertex); }
void VertexArrayObject::drawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices, GLint baseVertex) { bind(); glDrawRangeElementsBaseVertex(mode, start, end, count, type, const_cast<void*>(indices), baseVertex); CheckGLError(); }