int vertexbufferobject;
int elementbufferobject;
int framebufferobject;
+ int defaultframebufferobject; // RENDERPATH_GLES2 has a non-zero fbo provided by the OS
qboolean pointer_color_enabled;
int pointer_vertex_components;
gl_state.usevbo_dynamicvertex = false;
gl_state.usevbo_dynamicindex = false;
break;
+ case RENDERPATH_GLES2:
+ gl_state.usevbo_staticvertex = (vid.support.arb_vertex_buffer_object && gl_vbo.integer) || vid.forcevbo;
+ gl_state.usevbo_staticindex = false;
+ gl_state.usevbo_dynamicvertex = (vid.support.arb_vertex_buffer_object && gl_vbo_dynamicvertex.integer) || vid.forcevbo;
+ gl_state.usevbo_dynamicindex = false;
+ break;
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
+ // fetch current fbo here (default fbo is not 0 on some GLES devices)
+ if (vid.support.ext_framebuffer_object)
+ qglGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &gl_state.defaultframebufferobject);
break;
case RENDERPATH_D3D9:
#ifdef SUPPORTD3D
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
#ifdef SUPPORTD3D
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
- case RENDERPATH_SOFT:
- break;
}
if (gl_state.preparevertices_tempdata)
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
#ifdef SUPPORTD3D
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
- case RENDERPATH_SOFT:
- break;
}
endindex = Mem_ExpandableArray_IndexRange(&gl_state.meshbufferarray);
for (i = 0;i < endindex;i++)
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
#ifdef SUPPORTD3D
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
- case RENDERPATH_SOFT:
- break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
#ifdef SUPPORTD3D
case RENDERPATH_D3D11:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
- case RENDERPATH_SOFT:
- break;
}
}
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
}
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
case RENDERPATH_D3D10:
case RENDERPATH_GL13:
case RENDERPATH_GL11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
m[5] *= -1;
case RENDERPATH_SOFT:
DPSOFTRAST_Viewport(v->x, v->y, v->width, v->height);
break;
+ case RENDERPATH_GLES2:
+ CHECKGLERROR
+ qglViewport(v->x, v->y, v->width, v->height);CHECKGLERROR
+ break;
}
// force an update of the derived matrices
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (!vid.support.ext_framebuffer_object)
return 0;
qglGenFramebuffersEXT(1, (GLuint*)&temp);CHECKGLERROR
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (fbo)
qglDeleteFramebuffersEXT(1, (GLuint*)&fbo);
break;
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (gl_state.framebufferobject)
{
gl_state.framebufferobject = 0;
- qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.framebufferobject);
+ qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.defaultframebufferobject);
}
break;
case RENDERPATH_D3D9:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (gl_state.framebufferobject != fbo)
{
gl_state.framebufferobject = fbo;
- qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.framebufferobject);
+ qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.framebufferobject ? gl_state.framebufferobject : gl_state.defaultframebufferobject);
}
break;
case RENDERPATH_D3D9:
DPSOFTRAST_SetRenderTargets(vid.width, vid.height, vid.softdepthpixels, vid.softpixels, NULL, NULL, NULL);
DPSOFTRAST_Viewport(0, 0, vid.width, vid.height);
break;
+ case RENDERPATH_GLES2:
+ CHECKGLERROR
+ qglColorMask(1, 1, 1, 1);CHECKGLERROR
+ qglBlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);CHECKGLERROR
+ qglDisable(GL_BLEND);CHECKGLERROR
+ qglCullFace(gl_state.cullface);CHECKGLERROR
+ qglDisable(GL_CULL_FACE);CHECKGLERROR
+ qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+ qglEnable(GL_DEPTH_TEST);CHECKGLERROR
+ qglDepthMask(gl_state.depthmask);CHECKGLERROR
+ qglPolygonOffset(gl_state.polygonoffset[0], gl_state.polygonoffset[1]);
+ qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
+ qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+ qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.defaultframebufferobject);
+ qglEnableVertexAttribArray(GLES2ATTRIB_POSITION);
+ qglVertexAttribPointer(GLES2ATTRIB_POSITION, 3, GL_FLOAT, false, sizeof(float[3]), NULL);CHECKGLERROR
+ qglDisableVertexAttribArray(GLES2ATTRIB_COLOR);
+ qglVertexAttribPointer(GLES2ATTRIB_COLOR, 4, GL_FLOAT, false, sizeof(float[4]), NULL);CHECKGLERROR
+ qglVertexAttrib4f(GLES2ATTRIB_COLOR, 1, 1, 1, 1);
+ gl_state.unit = MAX_TEXTUREUNITS;
+ gl_state.clientunit = MAX_TEXTUREUNITS;
+ for (i = 0;i < vid.teximageunits;i++)
+ {
+ GL_ActiveTexture(i);
+ qglBindTexture(GL_TEXTURE_2D, 0);CHECKGLERROR
+ if (vid.support.ext_texture_3d)
+ {
+ qglBindTexture(GL_TEXTURE_3D, 0);CHECKGLERROR
+ }
+ if (vid.support.arb_texture_cube_map)
+ {
+ qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0);CHECKGLERROR
+ }
+ }
+ for (i = 0;i < vid.texarrayunits;i++)
+ {
+ GL_BindVBO(0);
+ qglVertexAttribPointer(i+GLES2ATTRIB_TEXCOORD0, 2, GL_FLOAT, false, sizeof(float[2]), NULL);CHECKGLERROR
+ qglDisableVertexAttribArray(i+GLES2ATTRIB_TEXCOORD0);CHECKGLERROR
+ }
+ CHECKGLERROR
+ break;
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (qglActiveTexture)
{
CHECKGLERROR
break;
case RENDERPATH_SOFT:
break;
+ case RENDERPATH_GLES2:
+ break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglBlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);CHECKGLERROR
if (gl_state.blend != blendenable)
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglDepthMask(gl_state.depthmask);CHECKGLERROR
break;
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
if (gl_state.depthtest)
{
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglDepthFunc(gl_state.depthfunc);CHECKGLERROR
break;
case RENDERPATH_SOFT:
DPSOFTRAST_DepthRange(gl_state.depthrange[0], gl_state.depthrange[1]);
break;
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ // FIXME: qglDepthRangef instead... faster...
+ qglDepthRange(gl_state.depthrange[0], gl_state.depthrange[1]);
+ break;
}
}
}
case RENDERPATH_SOFT:
//Con_DPrintf("FIXME SOFT %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
if (enable)
{
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
qglPolygonOffset(gl_state.polygonoffset[0], gl_state.polygonoffset[1]);
break;
case RENDERPATH_D3D9:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
qglCullFace(gl_state.cullface);
break;
case RENDERPATH_D3D9:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
if (state != GL_NONE)
case RENDERPATH_SOFT:
DPSOFTRAST_AlphaTest(gl_state.alphatest);
break;
+ case RENDERPATH_GLES2:
+ break;
}
}
}
case RENDERPATH_SOFT:
DPSOFTRAST_AlphaFunc(gl_state.alphafunc, gl_state.alphafuncvalue);
break;
+ case RENDERPATH_GLES2:
+ break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglColorMask((GLboolean)r, (GLboolean)g, (GLboolean)b, (GLboolean)a);CHECKGLERROR
break;
case RENDERPATH_SOFT:
DPSOFTRAST_Color4f(cr, cg, cb, ca);
break;
+ case RENDERPATH_GLES2:
+ qglVertexAttrib4f(GLES2ATTRIB_COLOR, cr, cg, cb, ca);
+ break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglScissor(x, y,width,height);
CHECKGLERROR
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
if(gl_state.scissortest)
qglEnable(GL_SCISSOR_TEST);
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
if (mask & GL_COLOR_BUFFER_BIT)
{
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
CHECKGLERROR
qglReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, outpixels);CHECKGLERROR
break;
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
// check if the user specified to ignore static index buffers
if (!gl_state.usevbo_staticindex || (gl_vbo.integer == 3 && !vid.forcevbo && (element3i_bufferoffset || element3s_bufferoffset)))
{
case RENDERPATH_SOFT:
DPSOFTRAST_DrawTriangles(firstvertex, numvertices, numtriangles, element3i, element3s);
break;
+ case RENDERPATH_GLES2:
+ // GLES does not have glDrawRangeElements, and generally
+ // underperforms with index buffers, so this code path is
+ // relatively straightforward...
+ if (element3s)
+ {
+ qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_SHORT, element3s);
+ CHECKGLERROR
+ }
+ else if (element3i)
+ {
+ qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_INT, element3i);
+ CHECKGLERROR
+ }
+ else
+ {
+ qglDrawArrays(GL_TRIANGLES, firstvertex, numvertices);
+ CHECKGLERROR
+ }
+ break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (!buffer->bufferobject)
qglGenBuffersARB(1, (GLuint *)&buffer->bufferobject);
if (buffer->isindexbuffer)
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
qglDeleteBuffersARB(1, (GLuint *)&buffer->bufferobject);
break;
case RENDERPATH_D3D9:
void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
{
- int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
- if (gl_state.pointer_vertex_components != components || gl_state.pointer_vertex_gltype != gltype || gl_state.pointer_vertex_stride != stride || gl_state.pointer_vertex_pointer != pointer || gl_state.pointer_vertex_vertexbuffer != vertexbuffer || gl_state.pointer_vertex_offset != bufferoffset)
+ switch(vid.renderpath)
{
- gl_state.pointer_vertex_components = components;
- gl_state.pointer_vertex_gltype = gltype;
- gl_state.pointer_vertex_stride = stride;
- gl_state.pointer_vertex_pointer = pointer;
- gl_state.pointer_vertex_vertexbuffer = vertexbuffer;
- gl_state.pointer_vertex_offset = bufferoffset;
- CHECKGLERROR
- GL_BindVBO(bufferobject);
- qglVertexPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GL20:
+ case RENDERPATH_CGGL:
+ if (gl_state.pointer_vertex_components != components || gl_state.pointer_vertex_gltype != gltype || gl_state.pointer_vertex_stride != stride || gl_state.pointer_vertex_pointer != pointer || gl_state.pointer_vertex_vertexbuffer != vertexbuffer || gl_state.pointer_vertex_offset != bufferoffset)
+ {
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ gl_state.pointer_vertex_components = components;
+ gl_state.pointer_vertex_gltype = gltype;
+ gl_state.pointer_vertex_stride = stride;
+ gl_state.pointer_vertex_pointer = pointer;
+ gl_state.pointer_vertex_vertexbuffer = vertexbuffer;
+ gl_state.pointer_vertex_offset = bufferoffset;
+ CHECKGLERROR
+ GL_BindVBO(bufferobject);
+ qglVertexPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
+ break;
+ case RENDERPATH_GLES2:
+ if (gl_state.pointer_vertex_components != components || gl_state.pointer_vertex_gltype != gltype || gl_state.pointer_vertex_stride != stride || gl_state.pointer_vertex_pointer != pointer || gl_state.pointer_vertex_vertexbuffer != vertexbuffer || gl_state.pointer_vertex_offset != bufferoffset)
+ {
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ gl_state.pointer_vertex_components = components;
+ gl_state.pointer_vertex_gltype = gltype;
+ gl_state.pointer_vertex_stride = stride;
+ gl_state.pointer_vertex_pointer = pointer;
+ gl_state.pointer_vertex_vertexbuffer = vertexbuffer;
+ gl_state.pointer_vertex_offset = bufferoffset;
+ CHECKGLERROR
+ GL_BindVBO(bufferobject);
+ qglVertexAttribPointer(GLES2ATTRIB_POSITION, components, gltype, false, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
+ break;
+ case RENDERPATH_D3D9:
+ case RENDERPATH_D3D10:
+ case RENDERPATH_D3D11:
+ case RENDERPATH_SOFT:
+ break;
}
}
{
// note: vertexbuffer may be non-NULL even if pointer is NULL, so check
// the pointer only.
- if (pointer)
+ switch(vid.renderpath)
{
- int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
- // caller wants color array enabled
- if (!gl_state.pointer_color_enabled)
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GL20:
+ case RENDERPATH_CGGL:
+ CHECKGLERROR
+ if (pointer)
{
- gl_state.pointer_color_enabled = true;
- CHECKGLERROR
- qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ // caller wants color array enabled
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ if (!gl_state.pointer_color_enabled)
+ {
+ gl_state.pointer_color_enabled = true;
+ CHECKGLERROR
+ qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ }
+ if (gl_state.pointer_color_components != components || gl_state.pointer_color_gltype != gltype || gl_state.pointer_color_stride != stride || gl_state.pointer_color_pointer != pointer || gl_state.pointer_color_vertexbuffer != vertexbuffer || gl_state.pointer_color_offset != bufferoffset)
+ {
+ gl_state.pointer_color_components = components;
+ gl_state.pointer_color_gltype = gltype;
+ gl_state.pointer_color_stride = stride;
+ gl_state.pointer_color_pointer = pointer;
+ gl_state.pointer_color_vertexbuffer = vertexbuffer;
+ gl_state.pointer_color_offset = bufferoffset;
+ CHECKGLERROR
+ GL_BindVBO(bufferobject);
+ qglColorPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
}
- if (gl_state.pointer_color_components != components || gl_state.pointer_color_gltype != gltype || gl_state.pointer_color_stride != stride || gl_state.pointer_color_pointer != pointer || gl_state.pointer_color_vertexbuffer != vertexbuffer || gl_state.pointer_color_offset != bufferoffset)
+ else
{
- gl_state.pointer_color_components = components;
- gl_state.pointer_color_gltype = gltype;
- gl_state.pointer_color_stride = stride;
- gl_state.pointer_color_pointer = pointer;
- gl_state.pointer_color_vertexbuffer = vertexbuffer;
- gl_state.pointer_color_offset = bufferoffset;
- CHECKGLERROR
- GL_BindVBO(bufferobject);
- qglColorPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ // caller wants color array disabled
+ if (gl_state.pointer_color_enabled)
+ {
+ gl_state.pointer_color_enabled = false;
+ CHECKGLERROR
+ qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ // when color array is on the glColor gets trashed, set it again
+ qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);CHECKGLERROR
+ }
}
- }
- else
- {
- // caller wants color array disabled
- if (gl_state.pointer_color_enabled)
+ break;
+ case RENDERPATH_GLES2:
+ CHECKGLERROR
+ if (pointer)
{
- gl_state.pointer_color_enabled = false;
- CHECKGLERROR
- qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
- // when color array is on the glColor gets trashed, set it again
- qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);CHECKGLERROR
+ // caller wants color array enabled
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ if (!gl_state.pointer_color_enabled)
+ {
+ gl_state.pointer_color_enabled = true;
+ CHECKGLERROR
+ qglEnableVertexAttribArray(GLES2ATTRIB_COLOR);CHECKGLERROR
+ }
+ if (gl_state.pointer_color_components != components || gl_state.pointer_color_gltype != gltype || gl_state.pointer_color_stride != stride || gl_state.pointer_color_pointer != pointer || gl_state.pointer_color_vertexbuffer != vertexbuffer || gl_state.pointer_color_offset != bufferoffset)
+ {
+ gl_state.pointer_color_components = components;
+ gl_state.pointer_color_gltype = gltype;
+ gl_state.pointer_color_stride = stride;
+ gl_state.pointer_color_pointer = pointer;
+ gl_state.pointer_color_vertexbuffer = vertexbuffer;
+ gl_state.pointer_color_offset = bufferoffset;
+ CHECKGLERROR
+ GL_BindVBO(bufferobject);
+ qglVertexAttribPointer(GLES2ATTRIB_COLOR, components, gltype, false, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
}
+ else
+ {
+ // caller wants color array disabled
+ if (gl_state.pointer_color_enabled)
+ {
+ gl_state.pointer_color_enabled = false;
+ CHECKGLERROR
+ qglDisableVertexAttribArray(GLES2ATTRIB_COLOR);CHECKGLERROR
+ // when color array is on the glColor gets trashed, set it again
+ qglVertexAttrib4f(GLES2ATTRIB_COLOR, gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);CHECKGLERROR
+ }
+ }
+ break;
+ case RENDERPATH_D3D9:
+ case RENDERPATH_D3D10:
+ case RENDERPATH_D3D11:
+ case RENDERPATH_SOFT:
+ break;
}
}
{
gltextureunit_t *unit = gl_state.units + unitnum;
// update array settings
- CHECKGLERROR
// note: there is no need to check bufferobject here because all cases
// that involve a valid bufferobject also supply a texcoord array
- if (pointer)
+ switch(vid.renderpath)
{
- int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
- // texture array unit is enabled, enable the array
- if (!unit->arrayenabled)
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GL20:
+ case RENDERPATH_CGGL:
+ CHECKGLERROR
+ if (pointer)
{
- unit->arrayenabled = true;
- GL_ClientActiveTexture(unitnum);
- qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ // texture array unit is enabled, enable the array
+ if (!unit->arrayenabled)
+ {
+ unit->arrayenabled = true;
+ GL_ClientActiveTexture(unitnum);
+ qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
+ // texcoord array
+ if (unit->pointer_texcoord_components != components || unit->pointer_texcoord_gltype != gltype || unit->pointer_texcoord_stride != stride || unit->pointer_texcoord_pointer != pointer || unit->pointer_texcoord_vertexbuffer != vertexbuffer || unit->pointer_texcoord_offset != bufferoffset)
+ {
+ unit->pointer_texcoord_components = components;
+ unit->pointer_texcoord_gltype = gltype;
+ unit->pointer_texcoord_stride = stride;
+ unit->pointer_texcoord_pointer = pointer;
+ unit->pointer_texcoord_vertexbuffer = vertexbuffer;
+ unit->pointer_texcoord_offset = bufferoffset;
+ GL_ClientActiveTexture(unitnum);
+ GL_BindVBO(bufferobject);
+ qglTexCoordPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
}
- // texcoord array
- if (unit->pointer_texcoord_components != components || unit->pointer_texcoord_gltype != gltype || unit->pointer_texcoord_stride != stride || unit->pointer_texcoord_pointer != pointer || unit->pointer_texcoord_vertexbuffer != vertexbuffer || unit->pointer_texcoord_offset != bufferoffset)
+ else
{
- unit->pointer_texcoord_components = components;
- unit->pointer_texcoord_gltype = gltype;
- unit->pointer_texcoord_stride = stride;
- unit->pointer_texcoord_pointer = pointer;
- unit->pointer_texcoord_vertexbuffer = vertexbuffer;
- unit->pointer_texcoord_offset = bufferoffset;
- GL_ClientActiveTexture(unitnum);
- GL_BindVBO(bufferobject);
- qglTexCoordPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ // texture array unit is disabled, disable the array
+ if (unit->arrayenabled)
+ {
+ unit->arrayenabled = false;
+ GL_ClientActiveTexture(unitnum);
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ }
}
- }
- else
- {
- // texture array unit is disabled, disable the array
- if (unit->arrayenabled)
+ break;
+ case RENDERPATH_GLES2:
+ CHECKGLERROR
+ if (pointer)
{
- unit->arrayenabled = false;
- GL_ClientActiveTexture(unitnum);
- qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ int bufferobject = vertexbuffer ? vertexbuffer->bufferobject : 0;
+ // texture array unit is enabled, enable the array
+ if (!unit->arrayenabled)
+ {
+ unit->arrayenabled = true;
+ qglEnableVertexAttribArray(unitnum+GLES2ATTRIB_TEXCOORD0);CHECKGLERROR
+ }
+ // texcoord array
+ if (unit->pointer_texcoord_components != components || unit->pointer_texcoord_gltype != gltype || unit->pointer_texcoord_stride != stride || unit->pointer_texcoord_pointer != pointer || unit->pointer_texcoord_vertexbuffer != vertexbuffer || unit->pointer_texcoord_offset != bufferoffset)
+ {
+ unit->pointer_texcoord_components = components;
+ unit->pointer_texcoord_gltype = gltype;
+ unit->pointer_texcoord_stride = stride;
+ unit->pointer_texcoord_pointer = pointer;
+ unit->pointer_texcoord_vertexbuffer = vertexbuffer;
+ unit->pointer_texcoord_offset = bufferoffset;
+ GL_BindVBO(bufferobject);
+ qglVertexAttribPointer(unitnum+GLES2ATTRIB_TEXCOORD0, components, gltype, false, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR
+ }
}
+ else
+ {
+ // texture array unit is disabled, disable the array
+ if (unit->arrayenabled)
+ {
+ unit->arrayenabled = false;
+ qglDisableVertexAttribArray(unitnum+GLES2ATTRIB_TEXCOORD0);CHECKGLERROR
+ }
+ }
+ break;
+ case RENDERPATH_D3D9:
+ case RENDERPATH_D3D10:
+ case RENDERPATH_D3D11:
+ case RENDERPATH_SOFT:
+ break;
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
R_Mesh_TexBind(0, tex);
GL_ActiveTexture(0);CHECKGLERROR
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, tx, ty, sx, sy, width, height);CHECKGLERROR
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (!tex)
{
tex = r_texture_white;
break;
case RENDERPATH_SOFT:
break;
+ case RENDERPATH_GLES2:
+ break;
}
}
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
// do nothing
break;
case RENDERPATH_GL13:
break;
case RENDERPATH_SOFT:
break;
+ case RENDERPATH_GLES2:
+ break;
}
}
case RENDERPATH_CGGL:
case RENDERPATH_GL13:
case RENDERPATH_GL11:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
IDirect3DDevice9_CreateVertexDeclaration(vid_d3d9dev, r_vertex3f_d3d9elements, &r_vertex3f_d3d9decl);
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (vertexbuffer)
{
R_Mesh_VertexPointer(3, GL_FLOAT, sizeof(float[3]), vertex3f, vertexbuffer, 0);
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (!vid.useinterleavedarrays)
{
R_Mesh_VertexPointer(3, GL_FLOAT, sizeof(float[3]), vertex3f, NULL, 0);
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (vertexbuffer)
{
R_Mesh_VertexPointer( 3, GL_FLOAT , sizeof(*vertex), vertex->vertex3f , vertexbuffer, (int)((unsigned char *)vertex->vertex3f - (unsigned char *)vertex));
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (!vid.useinterleavedarrays)
{
R_Mesh_VertexPointer(3, GL_FLOAT, sizeof(float[3]), vertex3f, NULL, 0);
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
if (vertexbuffer)
{
R_Mesh_VertexPointer( 3, GL_FLOAT , sizeof(*vertex), vertex->vertex3f , vertexbuffer, (int)((unsigned char *)vertex->vertex3f - (unsigned char *)vertex));
"#endif // !MODE_DEPTH_OR_SHADOW\n"
;
+/*
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+
+
+
+=========================================================================================================================================================
+*/
+
+const char *builtingles2shaderstring = ""; // FIXME GLES2
+
char *glslshaderstring = NULL;
char *cgshaderstring = NULL;
char *hlslshaderstring = NULL;
};
#endif
-#ifdef SUPPORTD3D
shadermodeinfo_t hlslshadermodeinfo[SHADERMODE_COUNT] =
{
{"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_GENERIC\n", " generic"},
{"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
{"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
};
-#endif
+
+shadermodeinfo_t gles2shadermodeinfo[SHADERMODE_COUNT] =
+{
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_GENERIC\n", " generic"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_POSTPROCESS\n", " postprocess"},
+ {"gles2/default.glsl", NULL, NULL , "#define MODE_DEPTH_OR_SHADOW\n", " depth/shadow"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_FLATCOLOR\n", " flatcolor"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_LIGHTMAP\n", " lightmap"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_FAKELIGHT\n", " fakelight"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_LIGHTSOURCE\n", " lightsource"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_REFRACTION\n", " refraction"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_WATER\n", " water"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_SHOWDEPTH\n", " showdepth"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_DEFERREDGEOMETRY\n", " deferredgeometry"},
+ {"gles2/default.glsl", NULL, "gles2/default.glsl", "#define MODE_DEFERREDLIGHTSOURCE\n", " deferredlightsource"},
+};
struct r_glsl_permutation_s;
typedef struct r_glsl_permutation_s
qboolean compiled;
/// 0 if compilation failed
int program;
+ // texture units assigned to each detected uniform
+ int tex_Texture_First;
+ int tex_Texture_Second;
+ int tex_Texture_GammaRamps;
+ int tex_Texture_Normal;
+ int tex_Texture_Color;
+ int tex_Texture_Gloss;
+ int tex_Texture_Glow;
+ int tex_Texture_SecondaryNormal;
+ int tex_Texture_SecondaryColor;
+ int tex_Texture_SecondaryGloss;
+ int tex_Texture_SecondaryGlow;
+ int tex_Texture_Pants;
+ int tex_Texture_Shirt;
+ int tex_Texture_FogHeightTexture;
+ int tex_Texture_FogMask;
+ int tex_Texture_Lightmap;
+ int tex_Texture_Deluxemap;
+ int tex_Texture_Attenuation;
+ int tex_Texture_Cube;
+ int tex_Texture_Refraction;
+ int tex_Texture_Reflection;
+ int tex_Texture_ShadowMap2D;
+ int tex_Texture_CubeProjection;
+ int tex_Texture_ScreenDepth;
+ int tex_Texture_ScreenNormalMap;
+ int tex_Texture_ScreenDiffuse;
+ int tex_Texture_ScreenSpecular;
+ int tex_Texture_ReflectMask;
+ int tex_Texture_ReflectCube;
/// locations of detected uniforms in program object, or -1 if not found
int loc_Texture_First;
int loc_Texture_Second;
memcpy(shaderstring, glslshaderstring, strlen(glslshaderstring) + 1);
return shaderstring;
}
+ if (!strcmp(filename, "gles2/default.glsl"))
+ {
+ if (!glslshaderstring)
+ {
+ glslshaderstring = (char *)FS_LoadFile(filename, r_main_mempool, false, NULL);
+ if (glslshaderstring)
+ Con_DPrintf("Loading shaders from file %s...\n", filename);
+ else
+ glslshaderstring = (char *)builtingles2shaderstring;
+ }
+ shaderstring = (char *) Mem_Alloc(r_main_mempool, strlen(glslshaderstring) + 1);
+ memcpy(shaderstring, glslshaderstring, strlen(glslshaderstring) + 1);
+ return shaderstring;
+ }
shaderstring = (char *)FS_LoadFile(filename, r_main_mempool, false, NULL);
if (shaderstring)
{
static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, unsigned int permutation)
{
int i;
- shadermodeinfo_t *modeinfo = glslshadermodeinfo + mode;
+ int sampler;
+ shadermodeinfo_t *modeinfo = vid.renderpath == RENDERPATH_GLES2 ? gles2shadermodeinfo + mode : glslshadermodeinfo + mode;
char *vertexstring, *geometrystring, *fragmentstring;
char permutationname[256];
int vertstrings_count = 0;
p->loc_BloomColorSubtract = qglGetUniformLocation(p->program, "BloomColorSubtract");
p->loc_NormalmapScrollBlend = qglGetUniformLocation(p->program, "NormalmapScrollBlend");
// initialize the samplers to refer to the texture units we use
- if (p->loc_Texture_First >= 0) qglUniform1i(p->loc_Texture_First , GL20TU_FIRST);
- if (p->loc_Texture_Second >= 0) qglUniform1i(p->loc_Texture_Second , GL20TU_SECOND);
- if (p->loc_Texture_GammaRamps >= 0) qglUniform1i(p->loc_Texture_GammaRamps , GL20TU_GAMMARAMPS);
- if (p->loc_Texture_Normal >= 0) qglUniform1i(p->loc_Texture_Normal , GL20TU_NORMAL);
- if (p->loc_Texture_Color >= 0) qglUniform1i(p->loc_Texture_Color , GL20TU_COLOR);
- if (p->loc_Texture_Gloss >= 0) qglUniform1i(p->loc_Texture_Gloss , GL20TU_GLOSS);
- if (p->loc_Texture_Glow >= 0) qglUniform1i(p->loc_Texture_Glow , GL20TU_GLOW);
- if (p->loc_Texture_SecondaryNormal >= 0) qglUniform1i(p->loc_Texture_SecondaryNormal, GL20TU_SECONDARY_NORMAL);
- if (p->loc_Texture_SecondaryColor >= 0) qglUniform1i(p->loc_Texture_SecondaryColor , GL20TU_SECONDARY_COLOR);
- if (p->loc_Texture_SecondaryGloss >= 0) qglUniform1i(p->loc_Texture_SecondaryGloss , GL20TU_SECONDARY_GLOSS);
- if (p->loc_Texture_SecondaryGlow >= 0) qglUniform1i(p->loc_Texture_SecondaryGlow , GL20TU_SECONDARY_GLOW);
- if (p->loc_Texture_Pants >= 0) qglUniform1i(p->loc_Texture_Pants , GL20TU_PANTS);
- if (p->loc_Texture_Shirt >= 0) qglUniform1i(p->loc_Texture_Shirt , GL20TU_SHIRT);
- if (p->loc_Texture_FogHeightTexture>= 0) qglUniform1i(p->loc_Texture_FogHeightTexture, GL20TU_FOGHEIGHTTEXTURE);
- if (p->loc_Texture_FogMask >= 0) qglUniform1i(p->loc_Texture_FogMask , GL20TU_FOGMASK);
- if (p->loc_Texture_Lightmap >= 0) qglUniform1i(p->loc_Texture_Lightmap , GL20TU_LIGHTMAP);
- if (p->loc_Texture_Deluxemap >= 0) qglUniform1i(p->loc_Texture_Deluxemap , GL20TU_DELUXEMAP);
- if (p->loc_Texture_Attenuation >= 0) qglUniform1i(p->loc_Texture_Attenuation , GL20TU_ATTENUATION);
- if (p->loc_Texture_Cube >= 0) qglUniform1i(p->loc_Texture_Cube , GL20TU_CUBE);
- if (p->loc_Texture_Refraction >= 0) qglUniform1i(p->loc_Texture_Refraction , GL20TU_REFRACTION);
- if (p->loc_Texture_Reflection >= 0) qglUniform1i(p->loc_Texture_Reflection , GL20TU_REFLECTION);
- if (p->loc_Texture_ShadowMap2D >= 0) qglUniform1i(p->loc_Texture_ShadowMap2D , GL20TU_SHADOWMAP2D);
- if (p->loc_Texture_CubeProjection >= 0) qglUniform1i(p->loc_Texture_CubeProjection , GL20TU_CUBEPROJECTION);
- if (p->loc_Texture_ScreenDepth >= 0) qglUniform1i(p->loc_Texture_ScreenDepth , GL20TU_SCREENDEPTH);
- if (p->loc_Texture_ScreenNormalMap >= 0) qglUniform1i(p->loc_Texture_ScreenNormalMap, GL20TU_SCREENNORMALMAP);
- if (p->loc_Texture_ScreenDiffuse >= 0) qglUniform1i(p->loc_Texture_ScreenDiffuse , GL20TU_SCREENDIFFUSE);
- if (p->loc_Texture_ScreenSpecular >= 0) qglUniform1i(p->loc_Texture_ScreenSpecular , GL20TU_SCREENSPECULAR);
- if (p->loc_Texture_ReflectMask >= 0) qglUniform1i(p->loc_Texture_ReflectMask , GL20TU_REFLECTMASK);
- if (p->loc_Texture_ReflectCube >= 0) qglUniform1i(p->loc_Texture_ReflectCube , GL20TU_REFLECTCUBE);
+ p->tex_Texture_First = -1;
+ p->tex_Texture_Second = -1;
+ p->tex_Texture_GammaRamps = -1;
+ p->tex_Texture_Normal = -1;
+ p->tex_Texture_Color = -1;
+ p->tex_Texture_Gloss = -1;
+ p->tex_Texture_Glow = -1;
+ p->tex_Texture_SecondaryNormal = -1;
+ p->tex_Texture_SecondaryColor = -1;
+ p->tex_Texture_SecondaryGloss = -1;
+ p->tex_Texture_SecondaryGlow = -1;
+ p->tex_Texture_Pants = -1;
+ p->tex_Texture_Shirt = -1;
+ p->tex_Texture_FogHeightTexture = -1;
+ p->tex_Texture_FogMask = -1;
+ p->tex_Texture_Lightmap = -1;
+ p->tex_Texture_Deluxemap = -1;
+ p->tex_Texture_Attenuation = -1;
+ p->tex_Texture_Cube = -1;
+ p->tex_Texture_Refraction = -1;
+ p->tex_Texture_Reflection = -1;
+ p->tex_Texture_ShadowMap2D = -1;
+ p->tex_Texture_CubeProjection = -1;
+ p->tex_Texture_ScreenDepth = -1;
+ p->tex_Texture_ScreenNormalMap = -1;
+ p->tex_Texture_ScreenDiffuse = -1;
+ p->tex_Texture_ScreenSpecular = -1;
+ p->tex_Texture_ReflectMask = -1;
+ p->tex_Texture_ReflectCube = -1;
+ sampler = 0;
+ if (p->loc_Texture_First >= 0) {p->tex_Texture_First = sampler;qglUniform1i(p->loc_Texture_First , sampler);sampler++;}
+ if (p->loc_Texture_Second >= 0) {p->tex_Texture_Second = sampler;qglUniform1i(p->loc_Texture_Second , sampler);sampler++;}
+ if (p->loc_Texture_GammaRamps >= 0) {p->tex_Texture_GammaRamps = sampler;qglUniform1i(p->loc_Texture_GammaRamps , sampler);sampler++;}
+ if (p->loc_Texture_Normal >= 0) {p->tex_Texture_Normal = sampler;qglUniform1i(p->loc_Texture_Normal , sampler);sampler++;}
+ if (p->loc_Texture_Color >= 0) {p->tex_Texture_Color = sampler;qglUniform1i(p->loc_Texture_Color , sampler);sampler++;}
+ if (p->loc_Texture_Gloss >= 0) {p->tex_Texture_Gloss = sampler;qglUniform1i(p->loc_Texture_Gloss , sampler);sampler++;}
+ if (p->loc_Texture_Glow >= 0) {p->tex_Texture_Glow = sampler;qglUniform1i(p->loc_Texture_Glow , sampler);sampler++;}
+ if (p->loc_Texture_SecondaryNormal >= 0) {p->tex_Texture_SecondaryNormal = sampler;qglUniform1i(p->loc_Texture_SecondaryNormal , sampler);sampler++;}
+ if (p->loc_Texture_SecondaryColor >= 0) {p->tex_Texture_SecondaryColor = sampler;qglUniform1i(p->loc_Texture_SecondaryColor , sampler);sampler++;}
+ if (p->loc_Texture_SecondaryGloss >= 0) {p->tex_Texture_SecondaryGloss = sampler;qglUniform1i(p->loc_Texture_SecondaryGloss , sampler);sampler++;}
+ if (p->loc_Texture_SecondaryGlow >= 0) {p->tex_Texture_SecondaryGlow = sampler;qglUniform1i(p->loc_Texture_SecondaryGlow , sampler);sampler++;}
+ if (p->loc_Texture_Pants >= 0) {p->tex_Texture_Pants = sampler;qglUniform1i(p->loc_Texture_Pants , sampler);sampler++;}
+ if (p->loc_Texture_Shirt >= 0) {p->tex_Texture_Shirt = sampler;qglUniform1i(p->loc_Texture_Shirt , sampler);sampler++;}
+ if (p->loc_Texture_FogHeightTexture>= 0) {p->tex_Texture_FogHeightTexture = sampler;qglUniform1i(p->loc_Texture_FogHeightTexture, sampler);sampler++;}
+ if (p->loc_Texture_FogMask >= 0) {p->tex_Texture_FogMask = sampler;qglUniform1i(p->loc_Texture_FogMask , sampler);sampler++;}
+ if (p->loc_Texture_Lightmap >= 0) {p->tex_Texture_Lightmap = sampler;qglUniform1i(p->loc_Texture_Lightmap , sampler);sampler++;}
+ if (p->loc_Texture_Deluxemap >= 0) {p->tex_Texture_Deluxemap = sampler;qglUniform1i(p->loc_Texture_Deluxemap , sampler);sampler++;}
+ if (p->loc_Texture_Attenuation >= 0) {p->tex_Texture_Attenuation = sampler;qglUniform1i(p->loc_Texture_Attenuation , sampler);sampler++;}
+ if (p->loc_Texture_Cube >= 0) {p->tex_Texture_Cube = sampler;qglUniform1i(p->loc_Texture_Cube , sampler);sampler++;}
+ if (p->loc_Texture_Refraction >= 0) {p->tex_Texture_Refraction = sampler;qglUniform1i(p->loc_Texture_Refraction , sampler);sampler++;}
+ if (p->loc_Texture_Reflection >= 0) {p->tex_Texture_Reflection = sampler;qglUniform1i(p->loc_Texture_Reflection , sampler);sampler++;}
+ if (p->loc_Texture_ShadowMap2D >= 0) {p->tex_Texture_ShadowMap2D = sampler;qglUniform1i(p->loc_Texture_ShadowMap2D , sampler);sampler++;}
+ if (p->loc_Texture_CubeProjection >= 0) {p->tex_Texture_CubeProjection = sampler;qglUniform1i(p->loc_Texture_CubeProjection , sampler);sampler++;}
+ if (p->loc_Texture_ScreenDepth >= 0) {p->tex_Texture_ScreenDepth = sampler;qglUniform1i(p->loc_Texture_ScreenDepth , sampler);sampler++;}
+ if (p->loc_Texture_ScreenNormalMap >= 0) {p->tex_Texture_ScreenNormalMap = sampler;qglUniform1i(p->loc_Texture_ScreenNormalMap , sampler);sampler++;}
+ if (p->loc_Texture_ScreenDiffuse >= 0) {p->tex_Texture_ScreenDiffuse = sampler;qglUniform1i(p->loc_Texture_ScreenDiffuse , sampler);sampler++;}
+ if (p->loc_Texture_ScreenSpecular >= 0) {p->tex_Texture_ScreenSpecular = sampler;qglUniform1i(p->loc_Texture_ScreenSpecular , sampler);sampler++;}
+ if (p->loc_Texture_ReflectMask >= 0) {p->tex_Texture_ReflectMask = sampler;qglUniform1i(p->loc_Texture_ReflectMask , sampler);sampler++;}
+ if (p->loc_Texture_ReflectCube >= 0) {p->tex_Texture_ReflectCube = sampler;qglUniform1i(p->loc_Texture_ReflectCube , sampler);sampler++;}
+ if (vid.renderpath == RENDERPATH_GLES2)
+ {
+ qglBindAttribLocation(p->program, GLES2ATTRIB_POSITION , "Attrib_Position" );
+ qglBindAttribLocation(p->program, GLES2ATTRIB_COLOR , "Attrib_Color" );
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD0, "Attrib_TexCoord0");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD1, "Attrib_TexCoord1");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD2, "Attrib_TexCoord2");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD3, "Attrib_TexCoord3");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD4, "Attrib_TexCoord4");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD5, "Attrib_TexCoord5");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD6, "Attrib_TexCoord6");
+ qglBindAttribLocation(p->program, GLES2ATTRIB_TEXCOORD7, "Attrib_TexCoord7");
+ }
CHECKGLERROR
- Con_DPrintf("^5GLSL shader %s compiled.\n", permutationname);
+ Con_DPrintf("^5GLSL shader %s compiled (%i textures).\n", permutationname, sampler);
}
else
Con_Printf("^1GLSL shader %s failed! some features may not work properly.\n", permutationname);
void R_GLSL_Restart_f(void)
{
unsigned int i, limit;
- if (glslshaderstring && glslshaderstring != builtinshaderstring)
+ if (glslshaderstring && glslshaderstring != builtinshaderstring && glslshaderstring != builtingles2shaderstring)
Mem_Free(glslshaderstring);
glslshaderstring = NULL;
if (cgshaderstring && cgshaderstring != builtincgshaderstring)
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
{
r_glsl_permutation_t *p;
r_glsl_permutation = NULL;
else
Con_Printf("failed to write to glsl/default.glsl\n");
+ file = FS_OpenRealFile("gles2/default.glsl", "w", false);
+ if (file)
+ {
+ FS_Print(file, "/* The engine may define the following macros:\n");
+ FS_Print(file, "#define VERTEX_SHADER\n#define GEOMETRY_SHADER\n#define FRAGMENT_SHADER\n");
+ for (i = 0;i < SHADERMODE_COUNT;i++)
+ FS_Print(file, glslshadermodeinfo[i].pretext);
+ for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
+ FS_Print(file, shaderpermutationinfo[i].pretext);
+ FS_Print(file, "*/\n");
+ FS_Print(file, builtingles2shaderstring);
+ FS_Close(file);
+ Con_Printf("gles2/default.glsl written\n");
+ }
+ else
+ Con_Printf("failed to write to glsl/default.glsl\n");
+
#ifdef SUPPORTCG
file = FS_OpenRealFile("cg/default.cg", "w", false);
if (file)
Con_Printf("failed to write to cg/default.cg\n");
#endif
-#ifdef SUPPORTD3D
file = FS_OpenRealFile("hlsl/default.hlsl", "w", false);
if (file)
{
}
else
Con_Printf("failed to write to hlsl/default.hlsl\n");
-#endif
}
void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemode, int rgbscale)
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
R_SetupShader_SetPermutationGLSL(SHADERMODE_GENERIC, SHADERPERMUTATION_VIEWTINT | (first ? SHADERPERMUTATION_DIFFUSE : 0) | (second ? SHADERPERMUTATION_SPECULAR : 0) | (texturemode == GL_MODULATE ? SHADERPERMUTATION_COLORMAPPING : (texturemode == GL_ADD ? SHADERPERMUTATION_GLOW : (texturemode == GL_DECAL ? SHADERPERMUTATION_VERTEXTEXTUREBLEND : 0))));
- R_Mesh_TexBind(GL20TU_FIRST , first );
- R_Mesh_TexBind(GL20TU_SECOND, second);
+ R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , first );
+ R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Second, second);
break;
case RENDERPATH_CGGL:
#ifdef SUPPORTCG
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
R_SetupShader_SetPermutationGLSL(SHADERMODE_DEPTH_OR_SHADOW, 0);
break;
case RENDERPATH_CGGL:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
R_SetupShader_SetPermutationGLSL(SHADERMODE_SHOWDEPTH, 0);
break;
case RENDERPATH_CGGL:
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
if (!vid.useinterleavedarrays)
{
RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_ARRAY_NORMAL | BATCHNEED_ARRAY_VECTOR | (rsurface.modellightmapcolor4f ? BATCHNEED_ARRAY_VERTEXCOLOR : 0) | BATCHNEED_ARRAY_TEXCOORD | (rsurface.uselightmaptexture ? BATCHNEED_ARRAY_LIGHTMAP : 0), texturenumsurfaces, texturesurfacelist);
if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2f(r_glsl_permutation->loc_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]);
if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height);
- // if (r_glsl_permutation->loc_Texture_First >= 0) R_Mesh_TexBind(GL20TU_FIRST , r_texture_white );
- // if (r_glsl_permutation->loc_Texture_Second >= 0) R_Mesh_TexBind(GL20TU_SECOND , r_texture_white );
- // if (r_glsl_permutation->loc_Texture_GammaRamps >= 0) R_Mesh_TexBind(GL20TU_GAMMARAMPS , r_texture_gammaramps );
- if (r_glsl_permutation->loc_Texture_Normal >= 0) R_Mesh_TexBind(GL20TU_NORMAL , rsurface.texture->nmaptexture );
- if (r_glsl_permutation->loc_Texture_Color >= 0) R_Mesh_TexBind(GL20TU_COLOR , rsurface.texture->basetexture );
- if (r_glsl_permutation->loc_Texture_Gloss >= 0) R_Mesh_TexBind(GL20TU_GLOSS , rsurface.texture->glosstexture );
- if (r_glsl_permutation->loc_Texture_Glow >= 0) R_Mesh_TexBind(GL20TU_GLOW , rsurface.texture->glowtexture );
- if (r_glsl_permutation->loc_Texture_SecondaryNormal >= 0) R_Mesh_TexBind(GL20TU_SECONDARY_NORMAL , rsurface.texture->backgroundnmaptexture );
- if (r_glsl_permutation->loc_Texture_SecondaryColor >= 0) R_Mesh_TexBind(GL20TU_SECONDARY_COLOR , rsurface.texture->backgroundbasetexture );
- if (r_glsl_permutation->loc_Texture_SecondaryGloss >= 0) R_Mesh_TexBind(GL20TU_SECONDARY_GLOSS , rsurface.texture->backgroundglosstexture );
- if (r_glsl_permutation->loc_Texture_SecondaryGlow >= 0) R_Mesh_TexBind(GL20TU_SECONDARY_GLOW , rsurface.texture->backgroundglowtexture );
- if (r_glsl_permutation->loc_Texture_Pants >= 0) R_Mesh_TexBind(GL20TU_PANTS , rsurface.texture->pantstexture );
- if (r_glsl_permutation->loc_Texture_Shirt >= 0) R_Mesh_TexBind(GL20TU_SHIRT , rsurface.texture->shirttexture );
- if (r_glsl_permutation->loc_Texture_ReflectMask >= 0) R_Mesh_TexBind(GL20TU_REFLECTMASK , rsurface.texture->reflectmasktexture );
- if (r_glsl_permutation->loc_Texture_ReflectCube >= 0) R_Mesh_TexBind(GL20TU_REFLECTCUBE , rsurface.texture->reflectcubetexture ? rsurface.texture->reflectcubetexture : r_texture_whitecube);
- if (r_glsl_permutation->loc_Texture_FogHeightTexture>= 0) R_Mesh_TexBind(GL20TU_FOGHEIGHTTEXTURE , r_texture_fogheighttexture );
- if (r_glsl_permutation->loc_Texture_FogMask >= 0) R_Mesh_TexBind(GL20TU_FOGMASK , r_texture_fogattenuation );
- if (r_glsl_permutation->loc_Texture_Lightmap >= 0) R_Mesh_TexBind(GL20TU_LIGHTMAP , rsurface.lightmaptexture ? rsurface.lightmaptexture : r_texture_white);
- if (r_glsl_permutation->loc_Texture_Deluxemap >= 0) R_Mesh_TexBind(GL20TU_DELUXEMAP , rsurface.deluxemaptexture ? rsurface.deluxemaptexture : r_texture_blanknormalmap);
- if (r_glsl_permutation->loc_Texture_Attenuation >= 0) R_Mesh_TexBind(GL20TU_ATTENUATION , r_shadow_attenuationgradienttexture );
+ if (r_glsl_permutation->tex_Texture_First >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , r_texture_white );
+ if (r_glsl_permutation->tex_Texture_Second >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Second , r_texture_white );
+ if (r_glsl_permutation->tex_Texture_GammaRamps >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps , r_texture_gammaramps );
+ if (r_glsl_permutation->tex_Texture_Normal >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Normal , rsurface.texture->nmaptexture );
+ if (r_glsl_permutation->tex_Texture_Color >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Color , rsurface.texture->basetexture );
+ if (r_glsl_permutation->tex_Texture_Gloss >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Gloss , rsurface.texture->glosstexture );
+ if (r_glsl_permutation->tex_Texture_Glow >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Glow , rsurface.texture->glowtexture );
+ if (r_glsl_permutation->tex_Texture_SecondaryNormal >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryNormal , rsurface.texture->backgroundnmaptexture );
+ if (r_glsl_permutation->tex_Texture_SecondaryColor >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryColor , rsurface.texture->backgroundbasetexture );
+ if (r_glsl_permutation->tex_Texture_SecondaryGloss >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryGloss , rsurface.texture->backgroundglosstexture );
+ if (r_glsl_permutation->tex_Texture_SecondaryGlow >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryGlow , rsurface.texture->backgroundglowtexture );
+ if (r_glsl_permutation->tex_Texture_Pants >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Pants , rsurface.texture->pantstexture );
+ if (r_glsl_permutation->tex_Texture_Shirt >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Shirt , rsurface.texture->shirttexture );
+ if (r_glsl_permutation->tex_Texture_ReflectMask >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ReflectMask , rsurface.texture->reflectmasktexture );
+ if (r_glsl_permutation->tex_Texture_ReflectCube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ReflectCube , rsurface.texture->reflectcubetexture ? rsurface.texture->reflectcubetexture : r_texture_whitecube);
+ if (r_glsl_permutation->tex_Texture_FogHeightTexture>= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_FogHeightTexture , r_texture_fogheighttexture );
+ if (r_glsl_permutation->tex_Texture_FogMask >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_FogMask , r_texture_fogattenuation );
+ if (r_glsl_permutation->tex_Texture_Lightmap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Lightmap , rsurface.lightmaptexture ? rsurface.lightmaptexture : r_texture_white);
+ if (r_glsl_permutation->tex_Texture_Deluxemap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Deluxemap , rsurface.deluxemaptexture ? rsurface.deluxemaptexture : r_texture_blanknormalmap);
+ if (r_glsl_permutation->tex_Texture_Attenuation >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Attenuation , r_shadow_attenuationgradienttexture );
if (rsurfacepass == RSURFPASS_BACKGROUND)
{
- if(r_glsl_permutation->loc_Texture_Refraction >= 0) R_Mesh_TexBind(GL20TU_REFRACTION , waterplane->texture_refraction ? waterplane->texture_refraction : r_texture_black);
- else if(r_glsl_permutation->loc_Texture_First >= 0) R_Mesh_TexBind(GL20TU_FIRST , waterplane->texture_camera ? waterplane->texture_camera : r_texture_black);
- if(r_glsl_permutation->loc_Texture_Reflection >= 0) R_Mesh_TexBind(GL20TU_REFLECTION , waterplane->texture_reflection ? waterplane->texture_reflection : r_texture_black);
+ if (r_glsl_permutation->tex_Texture_Refraction >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Refraction , waterplane->texture_refraction ? waterplane->texture_refraction : r_texture_black);
+ if (r_glsl_permutation->tex_Texture_First >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , waterplane->texture_camera ? waterplane->texture_camera : r_texture_black);
+ if (r_glsl_permutation->tex_Texture_Reflection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Reflection , waterplane->texture_reflection ? waterplane->texture_reflection : r_texture_black);
}
else
{
- if (permutation & SHADERPERMUTATION_REFLECTION ) R_Mesh_TexBind(GL20TU_REFLECTION , waterplane->texture_reflection ? waterplane->texture_reflection : r_texture_black);
+ if (r_glsl_permutation->tex_Texture_Reflection >= 0 && waterplane) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Reflection , waterplane->texture_reflection ? waterplane->texture_reflection : r_texture_black);
}
-// if (r_glsl_permutation->loc_Texture_ScreenDepth >= 0) R_Mesh_TexBind(GL20TU_SCREENDEPTH , r_shadow_prepassgeometrydepthtexture );
-// if (r_glsl_permutation->loc_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(GL20TU_SCREENNORMALMAP , r_shadow_prepassgeometrynormalmaptexture );
- if (r_glsl_permutation->loc_Texture_ScreenDiffuse >= 0) R_Mesh_TexBind(GL20TU_SCREENDIFFUSE , r_shadow_prepasslightingdiffusetexture );
- if (r_glsl_permutation->loc_Texture_ScreenSpecular >= 0) R_Mesh_TexBind(GL20TU_SCREENSPECULAR , r_shadow_prepasslightingspeculartexture );
+ if (r_glsl_permutation->tex_Texture_ScreenDepth >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenDepth , r_shadow_prepassgeometrydepthtexture );
+ if (r_glsl_permutation->tex_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenNormalMap , r_shadow_prepassgeometrynormalmaptexture );
+ if (r_glsl_permutation->tex_Texture_ScreenDiffuse >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenDiffuse , r_shadow_prepasslightingdiffusetexture );
+ if (r_glsl_permutation->tex_Texture_ScreenSpecular >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenSpecular , r_shadow_prepasslightingspeculartexture );
if (rsurface.rtlight || (r_shadow_usingshadowmaportho && !(rsurface.ent_flags & RENDER_NOSELFSHADOW)))
{
- if (r_glsl_permutation->loc_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(GL20TU_SHADOWMAP2D, r_shadow_shadowmap2dtexture );
+ if (r_glsl_permutation->tex_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ShadowMap2D, r_shadow_shadowmap2dtexture );
if (rsurface.rtlight)
{
- if (r_glsl_permutation->loc_Texture_Cube >= 0) R_Mesh_TexBind(GL20TU_CUBE , rsurface.rtlight->currentcubemap );
- if (r_glsl_permutation->loc_Texture_CubeProjection >= 0) R_Mesh_TexBind(GL20TU_CUBEPROJECTION , r_shadow_shadowmapvsdcttexture );
+ if (r_glsl_permutation->tex_Texture_Cube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Cube , rsurface.rtlight->currentcubemap );
+ if (r_glsl_permutation->tex_Texture_CubeProjection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_CubeProjection , r_shadow_shadowmapvsdcttexture );
}
}
CHECKGLERROR
Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
break;
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
R_SetupShader_SetPermutationGLSL(mode, permutation);
if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3f( r_glsl_permutation->loc_LightPosition , viewlightorigin[0], viewlightorigin[1], viewlightorigin[2]);
if (r_glsl_permutation->loc_ViewToLight >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ViewToLight , 1, false, viewtolight16f);
if (r_glsl_permutation->loc_ShadowMap_Parameters >= 0) qglUniform4f( r_glsl_permutation->loc_ShadowMap_Parameters , r_shadow_shadowmap_parameters[0], r_shadow_shadowmap_parameters[1], r_shadow_shadowmap_parameters[2], r_shadow_shadowmap_parameters[3]);
if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1f( r_glsl_permutation->loc_SpecularPower , (r_shadow_gloss.integer == 2 ? r_shadow_gloss2exponent.value : r_shadow_glossexponent.value) * (r_shadow_glossexact.integer ? 0.25f : 1.0f));
if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2f( r_glsl_permutation->loc_ScreenToDepth , r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]);
- if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height);
-
- if (r_glsl_permutation->loc_Texture_Attenuation >= 0) R_Mesh_TexBind(GL20TU_ATTENUATION , r_shadow_attenuationgradienttexture );
- if (r_glsl_permutation->loc_Texture_ScreenDepth >= 0) R_Mesh_TexBind(GL20TU_SCREENDEPTH , r_shadow_prepassgeometrydepthtexture );
- if (r_glsl_permutation->loc_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(GL20TU_SCREENNORMALMAP , r_shadow_prepassgeometrynormalmaptexture );
- if (r_glsl_permutation->loc_Texture_Cube >= 0) R_Mesh_TexBind(GL20TU_CUBE , rsurface.rtlight->currentcubemap );
- if (r_glsl_permutation->loc_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(GL20TU_SHADOWMAP2D , r_shadow_shadowmap2dtexture );
- if (r_glsl_permutation->loc_Texture_CubeProjection >= 0) R_Mesh_TexBind(GL20TU_CUBEPROJECTION , r_shadow_shadowmapvsdcttexture );
+ if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f( r_glsl_permutation->loc_PixelToScreenTexCoord , 1.0f/vid.width, 1.0f/vid.height);
+
+ if (r_glsl_permutation->tex_Texture_Attenuation >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Attenuation , r_shadow_attenuationgradienttexture );
+ if (r_glsl_permutation->tex_Texture_ScreenDepth >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenDepth , r_shadow_prepassgeometrydepthtexture );
+ if (r_glsl_permutation->tex_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenNormalMap , r_shadow_prepassgeometrynormalmaptexture );
+ if (r_glsl_permutation->tex_Texture_Cube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Cube , rsurface.rtlight->currentcubemap );
+ if (r_glsl_permutation->tex_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ShadowMap2D , r_shadow_shadowmap2dtexture );
+ if (r_glsl_permutation->tex_Texture_CubeProjection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_CubeProjection , r_shadow_shadowmapvsdcttexture );
break;
case RENDERPATH_CGGL:
#ifdef SUPPORTCG
r_loadgloss = false;
r_loadfog = true;
break;
+ case RENDERPATH_GLES2:
+ Cvar_SetValueQuick(&r_textureunits, 1);
+ Cvar_SetValueQuick(&gl_combine, 1);
+ Cvar_SetValueQuick(&r_glsl, 1);
+ r_loadnormalmap = true;
+ r_loadgloss = false;
+ r_loadfog = false;
+ break;
}
R_AnimCache_Free();
break;
case RENDERPATH_SOFT:
break;
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
}
r_numqueries = 0;
case RENDERPATH_D3D9:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_GL13:
case RENDERPATH_GL11:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
// non-flipped y coordinates
fny = -1.0 + 2.0 * (scissor[1] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
fpy = -1.0 + 2.0 * (scissor[1] + scissor[3] - r_refdef.view.viewport.y) / (double) (r_refdef.view.viewport.height);
DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM1, 1, false, gl_modelviewprojection16f);
DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM_ModelViewMatrixM1, 1, false, gl_modelview16f);
break;
+ case RENDERPATH_GLES2:
+ if (r_glsl_permutation && r_glsl_permutation->loc_ModelViewProjectionMatrix >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ModelViewProjectionMatrix, 1, false, gl_modelviewprojection16f);
+ if (r_glsl_permutation && r_glsl_permutation->loc_ModelViewMatrix >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ModelViewMatrix, 1, false, gl_modelview16f);
+ break;
}
}
}
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
qglEnable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
break;
case RENDERPATH_D3D9:
case RENDERPATH_GL13:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
+ case RENDERPATH_GLES2:
qglEnable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
break;
case RENDERPATH_D3D9:
break;
case RENDERPATH_GL13:
case RENDERPATH_GL11:
+ case RENDERPATH_GLES2:
return;
}
break;
case RENDERPATH_GL13:
case RENDERPATH_GL11:
+ case RENDERPATH_GLES2:
return;
}
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
break;
case RENDERPATH_D3D9:
case RENDERPATH_D3D10:
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, r_bloomstate.screentexcoord2f);
break;
case RENDERPATH_D3D9:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
permutation =
(r_bloomstate.texture_bloom ? SHADERPERMUTATION_BLOOM : 0)
| (r_refdef.viewblend[3] > 0 ? SHADERPERMUTATION_VIEWTINT : 0)
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, r_bloomstate.screentexcoord2f);
break;
case RENDERPATH_D3D9:
switch(vid.renderpath)
{
case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
R_Mesh_PrepareVertices_Mesh_Arrays(4, r_screenvertex3f, NULL, NULL, NULL, NULL, r_bloomstate.screentexcoord2f, r_bloomstate.bloomtexcoord2f);
R_SetupShader_SetPermutationGLSL(SHADERMODE_POSTPROCESS, permutation);
- if (r_glsl_permutation->loc_Texture_First >= 0) R_Mesh_TexBind(GL20TU_FIRST , r_bloomstate.texture_screen);
- if (r_glsl_permutation->loc_Texture_Second >= 0) R_Mesh_TexBind(GL20TU_SECOND , r_bloomstate.texture_bloom );
- if (r_glsl_permutation->loc_Texture_GammaRamps >= 0) R_Mesh_TexBind(GL20TU_GAMMARAMPS, r_texture_gammaramps );
- if (r_glsl_permutation->loc_ViewTintColor >= 0) qglUniform4f(r_glsl_permutation->loc_ViewTintColor , r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
- if (r_glsl_permutation->loc_PixelSize >= 0) qglUniform2f(r_glsl_permutation->loc_PixelSize , 1.0/r_bloomstate.screentexturewidth, 1.0/r_bloomstate.screentextureheight);
- if (r_glsl_permutation->loc_UserVec1 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec1 , uservecs[0][0], uservecs[0][1], uservecs[0][2], uservecs[0][3]);
- if (r_glsl_permutation->loc_UserVec2 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec2 , uservecs[1][0], uservecs[1][1], uservecs[1][2], uservecs[1][3]);
- if (r_glsl_permutation->loc_UserVec3 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec3 , uservecs[2][0], uservecs[2][1], uservecs[2][2], uservecs[2][3]);
- if (r_glsl_permutation->loc_UserVec4 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec4 , uservecs[3][0], uservecs[3][1], uservecs[3][2], uservecs[3][3]);
- if (r_glsl_permutation->loc_Saturation >= 0) qglUniform1f(r_glsl_permutation->loc_Saturation , r_glsl_saturation.value);
- if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height);
- if (r_glsl_permutation->loc_BloomColorSubtract >= 0) qglUniform4f(r_glsl_permutation->loc_BloomColorSubtract , r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, 0.0f);
+ if (r_glsl_permutation->tex_Texture_First >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , r_bloomstate.texture_screen);
+ if (r_glsl_permutation->tex_Texture_Second >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Second , r_bloomstate.texture_bloom );
+ if (r_glsl_permutation->tex_Texture_GammaRamps >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps, r_texture_gammaramps );
+ if (r_glsl_permutation->loc_ViewTintColor >= 0) qglUniform4f(r_glsl_permutation->loc_ViewTintColor , r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
+ if (r_glsl_permutation->loc_PixelSize >= 0) qglUniform2f(r_glsl_permutation->loc_PixelSize , 1.0/r_bloomstate.screentexturewidth, 1.0/r_bloomstate.screentextureheight);
+ if (r_glsl_permutation->loc_UserVec1 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec1 , uservecs[0][0], uservecs[0][1], uservecs[0][2], uservecs[0][3]);
+ if (r_glsl_permutation->loc_UserVec2 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec2 , uservecs[1][0], uservecs[1][1], uservecs[1][2], uservecs[1][3]);
+ if (r_glsl_permutation->loc_UserVec3 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec3 , uservecs[2][0], uservecs[2][1], uservecs[2][2], uservecs[2][3]);
+ if (r_glsl_permutation->loc_UserVec4 >= 0) qglUniform4f(r_glsl_permutation->loc_UserVec4 , uservecs[3][0], uservecs[3][1], uservecs[3][2], uservecs[3][3]);
+ if (r_glsl_permutation->loc_Saturation >= 0) qglUniform1f(r_glsl_permutation->loc_Saturation , r_glsl_saturation.value);
+ if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/vid.width, 1.0f/vid.height);
+ if (r_glsl_permutation->loc_BloomColorSubtract >= 0) qglUniform4f(r_glsl_permutation->loc_BloomColorSubtract , r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, 0.0f);
break;
case RENDERPATH_CGGL:
#ifdef SUPPORTCG
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
if(v_glslgamma.integer && !vid_gammatables_trivial)
{
if(!r_texture_gammaramps || vid_gammatables_serial != r_texture_gammaramps_serial)
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
break;
case RENDERPATH_GL13:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
break;
case RENDERPATH_GL13:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
RSurf_ActiveModelEntity(ent, true, true, false);
break;
case RENDERPATH_GL13:
case RENDERPATH_SOFT:
//Con_DPrintf("FIXME SOFT %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
return;
+ case RENDERPATH_GLES2:
+ //Con_DPrintf("FIXME GLES2 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
+ break;
}
flagsmask = MATERIALFLAG_SKY | MATERIALFLAG_WALL;
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
RSurf_ActiveModelEntity(ent, model->wantnormals, model->wanttangents, false);
break;
case RENDERPATH_GL13:
case RENDERPATH_D3D10:
case RENDERPATH_D3D11:
case RENDERPATH_SOFT:
+ case RENDERPATH_GLES2:
RSurf_ActiveModelEntity(ent, true, true, false);
break;
case RENDERPATH_GL13: