Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_buffers.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_pbvh.h" | #include "BKE_pbvh.h" | ||||
| #include "GPU_buffers.h" | #include "GPU_buffers.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_basic_shader.h" | #include "GPU_basic_shader.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_legacy_stubs.h" | |||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| typedef enum { | typedef enum { | ||||
| GPU_BUFFER_VERTEX_STATE = (1 << 0), | GPU_BUFFER_VERTEX_STATE = (1 << 0), | ||||
| GPU_BUFFER_NORMAL_STATE = (1 << 1), | GPU_BUFFER_NORMAL_STATE = (1 << 1), | ||||
| GPU_BUFFER_TEXCOORD_UNIT_0_STATE = (1 << 2), | GPU_BUFFER_TEXCOORD_UNIT_0_STATE = (1 << 2), | ||||
| GPU_BUFFER_TEXCOORD_UNIT_2_STATE = (1 << 3), | GPU_BUFFER_TEXCOORD_UNIT_2_STATE = (1 << 3), | ||||
| ▲ Show 20 Lines • Show All 546 Lines • ▼ Show 20 Lines | static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type, bool update) | ||||
| return *buf; | return *buf; | ||||
| } | } | ||||
| void GPU_vertex_setup(DerivedMesh *dm) | void GPU_vertex_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id); | ||||
| glVertexPointer(3, GL_FLOAT, 0, 0); | oldVertexPointer(3, GL_FLOAT, 0, 0); | ||||
| GLStates |= GPU_BUFFER_VERTEX_STATE; | GLStates |= GPU_BUFFER_VERTEX_STATE; | ||||
| } | } | ||||
| void GPU_normal_setup(DerivedMesh *dm) | void GPU_normal_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_NORMAL_ARRAY); | oldEnableClientState(GL_NORMAL_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->normals->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->normals->id); | ||||
| glNormalPointer(GL_SHORT, 4 * sizeof(short), 0); | oldNormalPointer(GL_SHORT, 4 * sizeof(short), 0); | ||||
| GLStates |= GPU_BUFFER_NORMAL_STATE; | GLStates |= GPU_BUFFER_NORMAL_STATE; | ||||
| } | } | ||||
| void GPU_uv_setup(DerivedMesh *dm) | void GPU_uv_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_TEXTURE_COORD_ARRAY); | oldEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv->id); | ||||
| glTexCoordPointer(2, GL_FLOAT, 0, 0); | oldTexCoordPointer(2, GL_FLOAT, 0, 0); | ||||
| GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE; | GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE; | ||||
| } | } | ||||
| void GPU_texpaint_uv_setup(DerivedMesh *dm) | void GPU_texpaint_uv_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV_TEXPAINT, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV_TEXPAINT, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_TEXTURE_COORD_ARRAY); | oldEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv_tex->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uv_tex->id); | ||||
| glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0); | oldTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0); | ||||
| glClientActiveTexture(GL_TEXTURE2); | glClientActiveTexture(GL_TEXTURE2); | ||||
| glEnableClientState(GL_TEXTURE_COORD_ARRAY); | oldEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||||
| glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), BUFFER_OFFSET(2 * sizeof(float))); | oldTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), BUFFER_OFFSET(2 * sizeof(float))); | ||||
| glClientActiveTexture(GL_TEXTURE0); | glClientActiveTexture(GL_TEXTURE0); | ||||
| GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE; | GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE; | ||||
| } | } | ||||
| void GPU_color_setup(DerivedMesh *dm, int colType) | void GPU_color_setup(DerivedMesh *dm, int colType) | ||||
| { | { | ||||
| Show All 12 Lines | else if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) || (colType != dm->drawObject->colType)) { | ||||
| update = true; | update = true; | ||||
| dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW; | dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW; | ||||
| dm->drawObject->colType = colType; | dm->drawObject->colType = colType; | ||||
| } | } | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR, update)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR, update)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_COLOR_ARRAY); | oldEnableClientState(GL_COLOR_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->colors->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->colors->id); | ||||
| glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); | oldColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); | ||||
| GLStates |= GPU_BUFFER_COLOR_STATE; | GLStates |= GPU_BUFFER_COLOR_STATE; | ||||
| } | } | ||||
| void GPU_buffer_bind_as_color(GPUBuffer *buffer) | void GPU_buffer_bind_as_color(GPUBuffer *buffer) | ||||
| { | { | ||||
| glEnableClientState(GL_COLOR_ARRAY); | oldEnableClientState(GL_COLOR_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, buffer->id); | glBindBuffer(GL_ARRAY_BUFFER, buffer->id); | ||||
| glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0); | oldColorPointer(4, GL_UNSIGNED_BYTE, 0, 0); | ||||
| GLStates |= GPU_BUFFER_COLOR_STATE; | GLStates |= GPU_BUFFER_COLOR_STATE; | ||||
| } | } | ||||
| void GPU_edge_setup(DerivedMesh *dm) | void GPU_edge_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE, false)) | ||||
| return; | return; | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->points->id); | ||||
| glVertexPointer(3, GL_FLOAT, 0, 0); | oldVertexPointer(3, GL_FLOAT, 0, 0); | ||||
| glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dm->drawObject->edges->id); | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dm->drawObject->edges->id); | ||||
| GLStates |= (GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_ELEMENT_STATE); | GLStates |= (GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_ELEMENT_STATE); | ||||
| } | } | ||||
| void GPU_uvedge_setup(DerivedMesh *dm) | void GPU_uvedge_setup(DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE, false)) | ||||
| return; | return; | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uvedges->id); | glBindBuffer(GL_ARRAY_BUFFER, dm->drawObject->uvedges->id); | ||||
| glVertexPointer(2, GL_FLOAT, 0, 0); | oldVertexPointer(2, GL_FLOAT, 0, 0); | ||||
| GLStates |= GPU_BUFFER_VERTEX_STATE; | GLStates |= GPU_BUFFER_VERTEX_STATE; | ||||
| } | } | ||||
| void GPU_triangle_setup(struct DerivedMesh *dm) | void GPU_triangle_setup(struct DerivedMesh *dm) | ||||
| { | { | ||||
| if (!gpu_buffer_setup_common(dm, GPU_BUFFER_TRIANGLES, false)) | if (!gpu_buffer_setup_common(dm, GPU_BUFFER_TRIANGLES, false)) | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | void GPU_interleaved_attrib_unbind(void) | ||||
| attribData[0].index = -1; | attribData[0].index = -1; | ||||
| } | } | ||||
| void GPU_buffers_unbind(void) | void GPU_buffers_unbind(void) | ||||
| { | { | ||||
| int i; | int i; | ||||
| if (GLStates & GPU_BUFFER_VERTEX_STATE) | if (GLStates & GPU_BUFFER_VERTEX_STATE) | ||||
| glDisableClientState(GL_VERTEX_ARRAY); | oldDisableClientState(GL_VERTEX_ARRAY); | ||||
| if (GLStates & GPU_BUFFER_NORMAL_STATE) | if (GLStates & GPU_BUFFER_NORMAL_STATE) | ||||
| glDisableClientState(GL_NORMAL_ARRAY); | oldDisableClientState(GL_NORMAL_ARRAY); | ||||
| if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_0_STATE) | if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_0_STATE) | ||||
| glDisableClientState(GL_TEXTURE_COORD_ARRAY); | oldDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||||
| if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_2_STATE) { | if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_2_STATE) { | ||||
| glClientActiveTexture(GL_TEXTURE2); | glClientActiveTexture(GL_TEXTURE2); | ||||
| glDisableClientState(GL_TEXTURE_COORD_ARRAY); | oldDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||||
| glClientActiveTexture(GL_TEXTURE0); | glClientActiveTexture(GL_TEXTURE0); | ||||
| } | } | ||||
| if (GLStates & GPU_BUFFER_COLOR_STATE) | if (GLStates & GPU_BUFFER_COLOR_STATE) | ||||
| glDisableClientState(GL_COLOR_ARRAY); | oldDisableClientState(GL_COLOR_ARRAY); | ||||
| if (GLStates & GPU_BUFFER_ELEMENT_STATE) | if (GLStates & GPU_BUFFER_ELEMENT_STATE) | ||||
| glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | ||||
| GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | | GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | | ||||
| GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE | | GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE | | ||||
| GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE); | GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE); | ||||
| for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | ||||
| if (attribData[i].index != -1) { | if (attribData[i].index != -1) { | ||||
| glDisableVertexAttribArray(attribData[i].index); | glDisableVertexAttribArray(attribData[i].index); | ||||
| } | } | ||||
| else | else | ||||
| break; | break; | ||||
| } | } | ||||
| attribData[0].index = -1; | attribData[0].index = -1; | ||||
| glBindBuffer(GL_ARRAY_BUFFER, 0); | glBindBuffer(GL_ARRAY_BUFFER, 0); | ||||
| } | } | ||||
| void GPU_color_switch(int mode) | void GPU_color_switch(int mode) | ||||
| { | { | ||||
| if (mode) { | if (mode) { | ||||
| if (!(GLStates & GPU_BUFFER_COLOR_STATE)) | if (!(GLStates & GPU_BUFFER_COLOR_STATE)) | ||||
| glEnableClientState(GL_COLOR_ARRAY); | oldEnableClientState(GL_COLOR_ARRAY); | ||||
| GLStates |= GPU_BUFFER_COLOR_STATE; | GLStates |= GPU_BUFFER_COLOR_STATE; | ||||
| } | } | ||||
| else { | else { | ||||
| if (GLStates & GPU_BUFFER_COLOR_STATE) | if (GLStates & GPU_BUFFER_COLOR_STATE) | ||||
| glDisableClientState(GL_COLOR_ARRAY); | oldDisableClientState(GL_COLOR_ARRAY); | ||||
| GLStates &= ~GPU_BUFFER_COLOR_STATE; | GLStates &= ~GPU_BUFFER_COLOR_STATE; | ||||
| } | } | ||||
| } | } | ||||
| static int gpu_binding_type_gl[] = | static int gpu_binding_type_gl[] = | ||||
| { | { | ||||
| GL_ARRAY_BUFFER, | GL_ARRAY_BUFFER, | ||||
| GL_ELEMENT_ARRAY_BUFFER | GL_ELEMENT_ARRAY_BUFFER | ||||
| ▲ Show 20 Lines • Show All 958 Lines • ▼ Show 20 Lines | void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial, | ||||
| } | } | ||||
| if (buffers->vert_buf) { | if (buffers->vert_buf) { | ||||
| char *base = NULL; | char *base = NULL; | ||||
| char *index_base = NULL; | char *index_base = NULL; | ||||
| /* weak inspection of bound options, should not be necessary ideally */ | /* weak inspection of bound options, should not be necessary ideally */ | ||||
| const int bound_options_old = GPU_basic_shader_bound_options(); | const int bound_options_old = GPU_basic_shader_bound_options(); | ||||
| int bound_options_new = 0; | int bound_options_new = 0; | ||||
| glEnableClientState(GL_VERTEX_ARRAY); | oldEnableClientState(GL_VERTEX_ARRAY); | ||||
| if (!wireframe) { | if (!wireframe) { | ||||
| glEnableClientState(GL_NORMAL_ARRAY); | oldEnableClientState(GL_NORMAL_ARRAY); | ||||
| glEnableClientState(GL_COLOR_ARRAY); | oldEnableClientState(GL_COLOR_ARRAY); | ||||
| bound_options_new |= GPU_SHADER_USE_COLOR; | bound_options_new |= GPU_SHADER_USE_COLOR; | ||||
| } | } | ||||
| GPU_buffer_bind(buffers->vert_buf, GPU_BINDING_ARRAY); | GPU_buffer_bind(buffers->vert_buf, GPU_BINDING_ARRAY); | ||||
| if (do_fast) { | if (do_fast) { | ||||
| GPU_buffer_bind(buffers->index_buf_fast, GPU_BINDING_INDEX); | GPU_buffer_bind(buffers->index_buf_fast, GPU_BINDING_INDEX); | ||||
| Show All 16 Lines | if (buffers->vert_buf) { | ||||
| } | } | ||||
| if (buffers->tot_quad) { | if (buffers->tot_quad) { | ||||
| const char *offset = base; | const char *offset = base; | ||||
| const bool drawall = !(buffers->has_hidden || do_fast); | const bool drawall = !(buffers->has_hidden || do_fast); | ||||
| if (GLEW_ARB_draw_elements_base_vertex && drawall) { | if (GLEW_ARB_draw_elements_base_vertex && drawall) { | ||||
| glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | oldVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, co)); | offset + offsetof(VertexBufferFormat, co)); | ||||
| if (!wireframe) { | if (!wireframe) { | ||||
| glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | oldNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, no)); | offset + offsetof(VertexBufferFormat, no)); | ||||
| glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | oldColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, color)); | offset + offsetof(VertexBufferFormat, color)); | ||||
| } | } | ||||
| glMultiDrawElementsBaseVertex(GL_TRIANGLES, buffers->baseelemarray, buffers->index_type, | glMultiDrawElementsBaseVertex(GL_TRIANGLES, buffers->baseelemarray, buffers->index_type, | ||||
| (const void * const *)buffers->baseindex, | (const void * const *)buffers->baseindex, | ||||
| buffers->totgrid, &buffers->baseelemarray[buffers->totgrid]); | buffers->totgrid, &buffers->baseelemarray[buffers->totgrid]); | ||||
| } | } | ||||
| else { | else { | ||||
| int i, last = drawall ? buffers->totgrid : 1; | int i, last = drawall ? buffers->totgrid : 1; | ||||
| /* we could optimize this to one draw call, but it would need more memory */ | /* we could optimize this to one draw call, but it would need more memory */ | ||||
| for (i = 0; i < last; i++) { | for (i = 0; i < last; i++) { | ||||
| glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | oldVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, co)); | offset + offsetof(VertexBufferFormat, co)); | ||||
| if (!wireframe) { | if (!wireframe) { | ||||
| glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | oldNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, no)); | offset + offsetof(VertexBufferFormat, no)); | ||||
| glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | oldColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | ||||
| offset + offsetof(VertexBufferFormat, color)); | offset + offsetof(VertexBufferFormat, color)); | ||||
| } | } | ||||
| if (do_fast) | if (do_fast) | ||||
| glDrawElements(GL_TRIANGLES, buffers->totgrid * 6, buffers->index_type, index_base); | glDrawElements(GL_TRIANGLES, buffers->totgrid * 6, buffers->index_type, index_base); | ||||
| else | else | ||||
| glDrawElements(GL_TRIANGLES, buffers->tot_quad * 6, buffers->index_type, index_base); | glDrawElements(GL_TRIANGLES, buffers->tot_quad * 6, buffers->index_type, index_base); | ||||
| offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat); | offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (buffers->tot_tri) { | else if (buffers->tot_tri) { | ||||
| int totelem = buffers->tot_tri * 3; | int totelem = buffers->tot_tri * 3; | ||||
| glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | oldVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | ||||
| (void *)(base + offsetof(VertexBufferFormat, co))); | (void *)(base + offsetof(VertexBufferFormat, co))); | ||||
| if (!wireframe) { | if (!wireframe) { | ||||
| glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | oldNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | ||||
| (void *)(base + offsetof(VertexBufferFormat, no))); | (void *)(base + offsetof(VertexBufferFormat, no))); | ||||
| glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | oldColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | ||||
| (void *)(base + offsetof(VertexBufferFormat, color))); | (void *)(base + offsetof(VertexBufferFormat, color))); | ||||
| } | } | ||||
| if (buffers->index_buf) | if (buffers->index_buf) | ||||
| glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, index_base); | glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, index_base); | ||||
| else | else | ||||
| glDrawArrays(GL_TRIANGLES, 0, totelem); | glDrawArrays(GL_TRIANGLES, 0, totelem); | ||||
| } | } | ||||
| if (wireframe) | if (wireframe) | ||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||||
| GPU_buffer_unbind(buffers->vert_buf, GPU_BINDING_ARRAY); | GPU_buffer_unbind(buffers->vert_buf, GPU_BINDING_ARRAY); | ||||
| if (buffers->index_buf || do_fast) | if (buffers->index_buf || do_fast) | ||||
| GPU_buffer_unbind(do_fast ? buffers->index_buf_fast : buffers->index_buf, GPU_BINDING_INDEX); | GPU_buffer_unbind(do_fast ? buffers->index_buf_fast : buffers->index_buf, GPU_BINDING_INDEX); | ||||
| glDisableClientState(GL_VERTEX_ARRAY); | oldDisableClientState(GL_VERTEX_ARRAY); | ||||
| if (!wireframe) { | if (!wireframe) { | ||||
| glDisableClientState(GL_NORMAL_ARRAY); | oldDisableClientState(GL_NORMAL_ARRAY); | ||||
| glDisableClientState(GL_COLOR_ARRAY); | oldDisableClientState(GL_COLOR_ARRAY); | ||||
| } | } | ||||
| if (bound_options_new & ~bound_options_old) { | if (bound_options_new & ~bound_options_old) { | ||||
| GPU_basic_shader_bind(bound_options_old); | GPU_basic_shader_bind(bound_options_old); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines | |||||