// (this assumes they all use one particle font texture!)
GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
R_SetupShader_Generic(particletexture[63].texture, NULL, GL_MODULATE, 1);
- GL_LockArrays(0, numsurfaces*4);
R_Mesh_Draw(0, numsurfaces * 4, 0, numsurfaces * 2, NULL, particle_elements, 0, 0);
- GL_LockArrays(0, 0);
}
void R_DrawDecals (void)
// now render batches of particles based on blendmode and texture
blendmode = PBLEND_INVALID;
texture = NULL;
- GL_LockArrays(0, numsurfaces*4);
batchstart = 0;
batchcount = 0;
for (surfacelistindex = 0;surfacelistindex < numsurfaces;)
batchcount = surfacelistindex - batchstart;
R_Mesh_Draw(batchstart * 4, batchcount * 4, batchstart * 2, batchcount * 2, NULL, particle_elements, 0, 0);
}
- GL_LockArrays(0, 0);
}
void R_DrawParticles (void)
cvar_t r_waterwarp = {CVAR_SAVE, "r_waterwarp", "1", "warp view while underwater"};
cvar_t gl_polyblend = {CVAR_SAVE, "gl_polyblend", "1", "tints view while underwater, hurt, etc"};
cvar_t gl_dither = {CVAR_SAVE, "gl_dither", "1", "enables OpenGL dithering (16bit looks bad with this off)"};
-cvar_t gl_lockarrays = {0, "gl_lockarrays", "0", "enables use of glLockArraysEXT, may cause glitches with some broken drivers, and may be slower than normal"};
-cvar_t gl_lockarrays_minimumvertices = {0, "gl_lockarrays_minimumvertices", "1", "minimum number of vertices required for use of glLockArraysEXT, setting this too low may reduce performance"};
cvar_t gl_vbo = {CVAR_SAVE, "gl_vbo", "3", "make use of GL_ARB_vertex_buffer_object extension to store static geometry in video memory for faster rendering, 0 disables VBO allocation or use, 1 enables VBOs for vertex and triangle data, 2 only for vertex data, 3 for vertex data and triangle data of simple meshes (ones with only one surface)"};
cvar_t gl_fbo = {CVAR_SAVE, "gl_fbo", "1", "make use of GL_ARB_framebuffer_object extension to enable shadowmaps and other features using pixel formats different from the framebuffer"};
Cvar_RegisterVariable(&gl_polyblend);
Cvar_RegisterVariable(&v_flipped);
Cvar_RegisterVariable(&gl_dither);
- Cvar_RegisterVariable(&gl_lockarrays);
- Cvar_RegisterVariable(&gl_lockarrays_minimumvertices);
Cvar_RegisterVariable(&gl_vbo);
Cvar_RegisterVariable(&gl_paranoid);
Cvar_RegisterVariable(&gl_printcheckerror);
}
}
-void GL_LockArrays(int first, int count)
-{
- if (count < gl_lockarrays_minimumvertices.integer)
- {
- first = 0;
- count = 0;
- }
- if (gl_state.lockrange_count != count || gl_state.lockrange_first != first)
- {
- if (gl_state.lockrange_count)
- {
- gl_state.lockrange_count = 0;
- CHECKGLERROR
- qglUnlockArraysEXT();
- CHECKGLERROR
- }
- if (count && vid.support.ext_compiled_vertex_array && gl_lockarrays.integer)
- {
- gl_state.lockrange_first = first;
- gl_state.lockrange_count = count;
- CHECKGLERROR
- qglLockArraysEXT(first, count);
- CHECKGLERROR
- }
- }
-}
-
void GL_Scissor (int x, int y, int width, int height)
{
CHECKGLERROR
void GL_AlphaTest(int state);
void GL_ColorMask(int r, int g, int b, int a);
void GL_Color(float cr, float cg, float cb, float ca);
-void GL_LockArrays(int first, int count);
void GL_ActiveTexture(unsigned int num);
void GL_ClientActiveTexture(unsigned int num);
void GL_Scissor(int x, int y, int width, int height);
unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
void GL_Backend_FreeProgram(unsigned int prog);
-extern cvar_t gl_lockarrays;
-extern cvar_t gl_mesh_copyarrays;
extern cvar_t gl_paranoid;
extern cvar_t gl_printcheckerror;
if (batchcount)
{
// switching from freetype to non-freetype rendering
- GL_LockArrays(0, batchcount * 4);
R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
- GL_LockArrays(0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
batchcount++;
if (batchcount >= QUADELEMENTS_MAXQUADS)
{
- GL_LockArrays(0, batchcount * 4);
R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
- GL_LockArrays(0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
if (batchcount)
{
// we need a different character map, render what we currently have:
- GL_LockArrays(0, batchcount * 4);
R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
- GL_LockArrays(0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
batchcount++;
if (batchcount >= QUADELEMENTS_MAXQUADS)
{
- GL_LockArrays(0, batchcount * 4);
R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
- GL_LockArrays(0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
}
}
if (batchcount > 0)
- {
- GL_LockArrays(0, batchcount * 4);
R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
- GL_LockArrays(0, 0);
- }
if (outcolor)
*outcolor = colorindex;
R_Mesh_TexCoordPointer(0, 2, mesh->data_texcoord2f, 0, 0);
R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1);
- GL_LockArrays(0, mesh->num_vertices);
R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, mesh->data_element3i, mesh->data_element3s, 0, 0);
- GL_LockArrays(0, 0);
}
void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
int numtriangles;
// TODO: lock all array ranges before render, rather than on each surface
if (texturenumsurfaces == 1)
- {
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
- }
else if (r_batchmode.integer == 2)
{
#define MAXBATCHTRIANGLES 4096
surface2 = texturesurfacelist[j-1];
numvertices = surface2->num_firstvertex + surface2->num_vertices - surface->num_firstvertex;
numtriangles = surface2->num_firsttriangle + surface2->num_triangles - surface->num_firsttriangle;
- GL_LockArrays(surface->num_firstvertex, numvertices);
R_Mesh_Draw(surface->num_firstvertex, numvertices, surface->num_firsttriangle, numtriangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
}
for (i = 0;i < texturenumsurfaces;i++)
{
surface = texturesurfacelist[i];
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
}
surface = texturesurfacelist[i];
RSurf_BindLightmapForSurface(surface);
RSurf_BindReflectionForSurface(surface);
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
}
if (texturenumsurfaces == 1)
{
RSurf_BindLightmapForSurface(surface);
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
else if (r_batchmode.integer == 2)
surface2 = texturesurfacelist[j-1];
numvertices = surface2->num_firstvertex + surface2->num_vertices - surface->num_firstvertex;
numtriangles = surface2->num_firsttriangle + surface2->num_triangles - surface->num_firsttriangle;
- GL_LockArrays(surface->num_firstvertex, numvertices);
R_Mesh_Draw(surface->num_firstvertex, numvertices, surface->num_firsttriangle, numtriangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
#if 0
{
surface = texturesurfacelist[i];
RSurf_BindLightmapForSurface(surface);
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
}
const msurface_t *surface = texturesurfacelist[texturesurfaceindex];
int k = (int)(((size_t)surface) / sizeof(msurface_t));
GL_Color((k & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, ((k >> 4) & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, ((k >> 8) & 15) * (1.0f / 16.0f) * r_refdef.view.colorscale, 1);
- GL_LockArrays(surface->num_firstvertex, surface->num_vertices);
R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_firsttriangle, surface->num_triangles, rsurface.modelelement3i, rsurface.modelelement3s, rsurface.modelelement3i_bufferobject, rsurface.modelelement3s_bufferobject);
}
}
GL_DepthMask(true);
R_SetupShader_Surface(vec3_origin, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, prepass ? RSURFPASS_DEFERREDGEOMETRY : RSURFPASS_BASE);
RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
- GL_LockArrays(0, 0);
}
else if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION)) && !r_waterstate.renderingscene)
{
GL_DepthMask(true);
R_SetupShader_Surface(vec3_origin, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, RSURFPASS_BACKGROUND);
RSurf_DrawBatch_WithLightmapSwitching_WithWaterTextureSwitching(texturenumsurfaces, texturesurfacelist);
- GL_LockArrays(0, 0);
GL_DepthMask(false);
R_SetupShader_Surface(vec3_origin, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, prepass ? RSURFPASS_DEFERREDGEOMETRY : RSURFPASS_BASE);
RSurf_DrawBatch_WithLightmapSwitching_WithWaterTextureSwitching(texturenumsurfaces, texturesurfacelist);
- GL_LockArrays(0, 0);
}
else
{
RSurf_DrawBatch_WithLightmapSwitching(texturenumsurfaces, texturesurfacelist);
else
RSurf_DrawBatch_Simple(texturenumsurfaces, texturesurfacelist);
- GL_LockArrays(0, 0);
}
}
default:
Con_Printf("R_DrawTextureSurfaceList: unknown layer type %i\n", layer->type);
}
- GL_LockArrays(0, 0);
}
CHECKGLERROR
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
RSurf_DrawBatch_GL11_Lightmap(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false);
else
RSurf_DrawBatch_GL11_VertexColor(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false);
- GL_LockArrays(0, 0);
// then apply the texture to it
GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
R_Mesh_TexBind(0, layer->texture);
default:
Con_Printf("R_DrawTextureSurfaceList: unknown layer type %i\n", layer->type);
}
- GL_LockArrays(0, 0);
}
CHECKGLERROR
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
GL_CullFace(GL_NONE);
GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
R_SetupShader_Generic(decalskinframe->base, NULL, GL_MODULATE, 1);
- GL_LockArrays(0, numtris * 3);
R_Mesh_Draw(0, numtris * 3, 0, numtris, decalsystem->element3i, decalsystem->element3s, 0, 0);
- GL_LockArrays(0, 0);
}
}
GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back);
RSurf_PrepareVerticesForBatch(false, false, batchsize, batch);
RSurf_DrawBatch_Simple(batchsize, batch);
- GL_LockArrays(0, 0);
}
}
#define GL_TEXTURE31_ARB 0x84DF
#endif
-// GL_EXT_compiled_vertex_array
-extern void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
-extern void (GLAPIENTRY *qglUnlockArraysEXT) (void);
-
// GL_ARB_texture_env_combine
#ifndef GL_COMBINE_ARB
#define GL_COMBINE_ARB 0x8570
R_Mesh_VertexPointer(e->vert[0], 0, 0);
// FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
GL_Color(e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, 1);
- GL_LockArrays(0, numverts);
R_Mesh_Draw(0, numverts, 0, numtriangles, NULL, explosiontris[0], 0, 0);
- GL_LockArrays(0, 0);
}
}
r_refdef.stats.lights_shadowtriangles += tris;
CHECKGLERROR
R_Mesh_VertexPointer(shadowvertex3f, 0, 0);
- GL_LockArrays(0, outverts);
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_ZPASS_STENCIL)
{
// increment stencil if frontface is infront of depthbuffer
qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
}
R_Mesh_Draw(0, outverts, 0, tris, shadowelements, NULL, 0, 0);
- GL_LockArrays(0, 0);
CHECKGLERROR
}
}
{
r_refdef.stats.lights_shadowtriangles += mesh->numtriangles;
R_Mesh_VertexPointer(mesh->vertex3f, mesh->vbo, mesh->vbooffset_vertex3f);
- GL_LockArrays(0, mesh->numverts);
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_ZPASS_STENCIL)
{
// increment stencil if frontface is infront of depthbuffer
qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
}
R_Mesh_Draw(0, mesh->numverts, 0, mesh->numtriangles, mesh->element3i, mesh->element3s, mesh->ebo3i, mesh->ebo3s);
- GL_LockArrays(0, 0);
}
CHECKGLERROR
}
qboolean ati_separate_stencil;
qboolean ext_blend_minmax;
qboolean ext_blend_subtract;
- qboolean ext_compiled_vertex_array;
qboolean ext_draw_range_elements;
qboolean ext_framebuffer_object;
qboolean ext_stencil_two_side;
void (GLAPIENTRY *qglActiveTexture) (GLenum);
void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
-// GL_EXT_compiled_vertex_array
-void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
-void (GLAPIENTRY *qglUnlockArraysEXT) (void);
-
// general GL functions
void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
{NULL, NULL}
};
-static dllfunction_t compiledvertexarrayfuncs[] =
-{
- {"glLockArraysEXT", (void **) &qglLockArraysEXT},
- {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
- {NULL, NULL}
-};
-
static dllfunction_t texture3dextfuncs[] =
{
{"glTexImage3DEXT", (void **) &qglTexImage3D},
vid.support.ati_separate_stencil = GL_CheckExtension("2.0", gl2separatestencilfuncs, "-noseparatestencil", true) || GL_CheckExtension("GL_ATI_separate_stencil", atiseparatestencilfuncs, "-noseparatestencil", false);
vid.support.ext_blend_minmax = GL_CheckExtension("GL_EXT_blend_minmax", blendequationfuncs, "-noblendminmax", false);
vid.support.ext_blend_subtract = GL_CheckExtension("GL_EXT_blend_subtract", blendequationfuncs, "-noblendsubtract", false);
- vid.support.ext_compiled_vertex_array = GL_CheckExtension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva", false);
vid.support.ext_draw_range_elements = GL_CheckExtension("1.2", drawrangeelementsfuncs, "-nodrawrangeelements", true) || GL_CheckExtension("GL_EXT_draw_range_elements", drawrangeelementsextfuncs, "-nodrawrangeelements", false);
vid.support.ext_framebuffer_object = GL_CheckExtension("GL_EXT_framebuffer_object", fbofuncs, "-nofbo", false);
vid.support.ext_stencil_two_side = GL_CheckExtension("GL_EXT_stencil_two_side", stenciltwosidefuncs, "-nostenciltwoside", false);
// COMMANDLINEOPTION: GL: -noblendsubtract disables GL_EXT_blend_subtract
// COMMANDLINEOPTION: GL: -nocombine disables GL_ARB_texture_env_combine or GL_EXT_texture_env_combine (required for bumpmapping and faster map rendering)
// COMMANDLINEOPTION: GL: -nocubemap disables GL_ARB_texture_cube_map (required for bumpmapping)
-// COMMANDLINEOPTION: GL: -nocva disables GL_EXT_compiled_vertex_array (renders faster)
// COMMANDLINEOPTION: GL: -nodepthtexture disables use of GL_ARB_depth_texture (required for shadowmapping)
// COMMANDLINEOPTION: GL: -nodrawbuffers disables use of GL_ARB_draw_buffers (required for r_shadow_deferredprepass)
// COMMANDLINEOPTION: GL: -nodrawrangeelements disables GL_EXT_draw_range_elements (renders faster)