2017-04-26 10:23:36 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64-video - A Nintendo 64 gfx plugin. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2017 Project64. All rights reserved. *
|
|
|
|
* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski *
|
|
|
|
* Copyright (C) 2002 Dave2001 *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2016-12-20 07:19:21 +00:00
|
|
|
#include <GLES2/gl2.h>
|
2016-03-10 18:29:41 +00:00
|
|
|
#include "glitchmain.h"
|
|
|
|
|
|
|
|
#undef glActiveTexture
|
|
|
|
#undef glBindTexture
|
|
|
|
#undef glBlendEquation
|
|
|
|
#undef glBlendEquationSeparate
|
|
|
|
#undef glBlendFunc
|
|
|
|
#undef glBlendFuncSeparate
|
|
|
|
#undef glClearColor
|
|
|
|
#undef glClearDepthf
|
|
|
|
#undef glCullFace
|
|
|
|
#undef glDepthFunc
|
|
|
|
#undef glDepthMask
|
|
|
|
#undef glDepthRangef
|
|
|
|
#undef glDisable
|
|
|
|
#undef glEnable
|
|
|
|
#undef glFrontFace
|
|
|
|
#undef glPolygonOffset
|
|
|
|
#undef glScissor
|
|
|
|
#undef glUseProgram
|
|
|
|
#undef glViewport
|
|
|
|
|
|
|
|
void vbo_draw();
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
GLenum GLCache::m_cached_texture;
|
|
|
|
GLenum GLCache::m_cached_mode;
|
|
|
|
GLenum GLCache::m_cached_modeRGB;
|
|
|
|
GLenum GLCache::m_cached_modeAlpha;
|
|
|
|
GLenum GLCache::m_cached_sfactor;
|
|
|
|
GLenum GLCache::m_cached_dfactor;
|
|
|
|
GLenum GLCache::m_cached_BlendFuncSeparate_srcRGB;
|
|
|
|
GLenum GLCache::m_cached_BlendFuncSeparate_dstRGB;
|
|
|
|
GLenum GLCache::m_cached_BlendFuncSeparate_srcAlpha;
|
|
|
|
GLenum GLCache::m_cached_BlendFuncSeparate_dstAlpha;
|
|
|
|
GLclampf GLCache::m_cached_depth;
|
|
|
|
GLenum GLCache::m_cached_CullFace_mode;
|
|
|
|
GLenum GLCache::m_cached_func;
|
|
|
|
GLboolean GLCache::m_cached_DepthMask_flag;
|
|
|
|
GLclampf GLCache::m_cached_zNear;
|
|
|
|
GLclampf GLCache::m_cached_zFar;
|
|
|
|
bool GLCache::m_cached_BLEND = false;
|
|
|
|
bool GLCache::m_cached_CULL_FACE = false;
|
|
|
|
bool GLCache::m_cached_DEPTH_TEST = false;
|
|
|
|
bool GLCache::m_cached_DITHER = false;
|
|
|
|
bool GLCache::m_cached_POLYGON_OFFSET_FILL = false;
|
|
|
|
bool GLCache::m_cached_SAMPLE_ALPHA_TO_COVERAGE = false;
|
|
|
|
bool GLCache::m_cached_SAMPLE_COVERAGE = false;
|
|
|
|
bool GLCache::m_cached_SCISSOR_TEST = false;
|
|
|
|
bool GLCache::m_cached_STENCIL_TEST = false;
|
|
|
|
GLenum GLCache::m_cached_FrontFace_mode;
|
|
|
|
GLfloat GLCache::m_cached_factor;
|
|
|
|
GLfloat GLCache::m_cached_units;
|
|
|
|
GLclampf GLCache::m_cached_red, GLCache::m_cached_green, GLCache::m_cached_blue, GLCache::m_cached_alpha;
|
|
|
|
GLint GLCache::m_cached_x, GLCache::m_cached_y;
|
|
|
|
GLsizei GLCache::m_cached_width, GLCache::m_cached_height;
|
|
|
|
GLuint GLCache::m_cached_program;
|
|
|
|
GLint GLCache::m_Viewport_cached_x = 0, GLCache::m_Viewport_cached_y = 0;
|
|
|
|
GLsizei GLCache::m_Viewport_cached_width = 0, GLCache::m_Viewport_cached_height = 0;
|
|
|
|
|
|
|
|
void GLCache::ResetCache(void)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
m_cached_texture = 0;
|
|
|
|
m_cached_mode = 0;
|
|
|
|
m_cached_modeRGB = 0;
|
|
|
|
m_cached_modeAlpha = 0;
|
|
|
|
m_cached_sfactor = 0;
|
|
|
|
m_cached_dfactor = 0;
|
|
|
|
m_cached_BlendFuncSeparate_srcRGB = 0;
|
|
|
|
m_cached_BlendFuncSeparate_dstRGB = 0;
|
|
|
|
m_cached_BlendFuncSeparate_srcAlpha = 0;
|
|
|
|
m_cached_BlendFuncSeparate_dstAlpha = 0;
|
|
|
|
m_cached_depth = 0;
|
|
|
|
m_cached_CullFace_mode = 0;
|
|
|
|
m_cached_func = 0;
|
|
|
|
m_cached_DepthMask_flag = 0;
|
|
|
|
m_cached_zNear = 0;
|
|
|
|
m_cached_zFar = 0;
|
|
|
|
m_cached_BLEND = false;
|
|
|
|
m_cached_CULL_FACE = false;
|
|
|
|
m_cached_DEPTH_TEST = false;
|
|
|
|
m_cached_DITHER = false;
|
|
|
|
m_cached_POLYGON_OFFSET_FILL = false;
|
|
|
|
m_cached_SAMPLE_ALPHA_TO_COVERAGE = false;
|
|
|
|
m_cached_SAMPLE_COVERAGE = false;
|
|
|
|
m_cached_SCISSOR_TEST = false;
|
|
|
|
m_cached_STENCIL_TEST = false;
|
|
|
|
m_cached_FrontFace_mode = 0;
|
|
|
|
m_cached_factor = 0;
|
|
|
|
m_cached_units = 0;
|
|
|
|
m_cached_red = 0;
|
|
|
|
m_cached_green = 0;
|
|
|
|
m_cached_blue = 0;
|
|
|
|
m_cached_alpha = 0;
|
|
|
|
m_cached_x = 0;
|
|
|
|
m_cached_y = 0;
|
|
|
|
m_cached_width = 0;
|
|
|
|
m_cached_height = 0;
|
|
|
|
m_cached_program = 0;
|
|
|
|
m_Viewport_cached_x = 0;
|
|
|
|
m_Viewport_cached_y = 0;
|
|
|
|
m_Viewport_cached_width = 0;
|
|
|
|
m_Viewport_cached_height = 0;
|
|
|
|
}
|
2016-03-10 18:29:41 +00:00
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glActiveTexture(GLenum texture)
|
|
|
|
{
|
|
|
|
if (texture != m_cached_texture)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "texture: %d", texture);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glActiveTexture(texture);
|
|
|
|
m_cached_texture = texture;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - texture: %d", texture);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glBindTexture(GLenum target, GLuint texture)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "target: %d texture: %d", target, texture);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glBindTexture(target, texture);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glBlendEquation(GLenum mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (mode != m_cached_mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glBlendEquation(mode);
|
|
|
|
m_cached_mode = mode;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (modeRGB != m_cached_modeRGB || modeAlpha != m_cached_modeAlpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "modeRGB: %d cached_modeAlpha: %d", modeRGB, m_cached_modeAlpha);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glBlendEquationSeparate(modeRGB, modeAlpha);
|
|
|
|
m_cached_modeRGB = modeRGB;
|
|
|
|
m_cached_modeAlpha = modeAlpha;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - modeRGB: %d cached_modeAlpha: %d", modeRGB, m_cached_modeAlpha);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glBlendFunc(GLenum sfactor, GLenum dfactor)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (sfactor != m_cached_sfactor || dfactor != m_cached_dfactor)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "sfactor: %d dfactor: %d", sfactor, dfactor);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glBlendFunc(sfactor, dfactor);
|
|
|
|
m_cached_sfactor = sfactor;
|
|
|
|
m_cached_dfactor = dfactor;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - sfactor: %d dfactor: %d", sfactor, dfactor);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (srcRGB != m_cached_BlendFuncSeparate_srcRGB || dstRGB != m_cached_BlendFuncSeparate_dstRGB || srcAlpha != m_cached_BlendFuncSeparate_srcAlpha || dstAlpha != m_cached_BlendFuncSeparate_dstAlpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d", srcRGB, dstRGB, srcAlpha, dstAlpha);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
|
|
|
m_cached_BlendFuncSeparate_srcRGB = srcRGB;
|
|
|
|
m_cached_BlendFuncSeparate_dstRGB = dstRGB;
|
|
|
|
m_cached_BlendFuncSeparate_srcAlpha = srcAlpha;
|
|
|
|
m_cached_BlendFuncSeparate_dstAlpha = dstAlpha;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - srcRGB: %d dstRGB: %d srcAlpha: %d dstAlpha: %d", srcRGB, dstRGB, srcAlpha, dstAlpha);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glClearDepthf(GLclampf depth)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (depth != m_cached_depth)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "depth: %d", depth);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glClearDepthf(depth);
|
|
|
|
m_cached_depth = depth;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - depth: %d", depth);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glCullFace(GLenum mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (mode != m_cached_CullFace_mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glCullFace(mode);
|
|
|
|
m_cached_CullFace_mode = mode;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glDepthFunc(GLenum func)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (func != m_cached_func)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "func: %d", func);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glDepthFunc(func);
|
|
|
|
m_cached_func = func;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - func: %d", func);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glDepthMask(GLboolean flag)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (flag != m_cached_DepthMask_flag)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "flag: %d", (int)flag);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glDepthMask(flag);
|
|
|
|
m_cached_DepthMask_flag = flag;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - flag: %d", (int)flag);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glDepthRangef(GLclampf zNear, GLclampf zFar)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (zNear != m_cached_zNear || zFar != m_cached_zFar)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "zNear: %d zFar: %d", zNear, zFar);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glDepthRangef(zNear, zFar);
|
|
|
|
m_cached_zNear = zNear;
|
|
|
|
m_cached_zFar = zFar;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - zNear: %d zFar: %d", zNear, zFar);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glEnableDisableItem(GLenum cap, bool enable, bool & cached_state, const char * StateName)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
if (enable)
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (!cached_state)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%s)", StateName);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glEnable(cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
cached_state = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)", StateName);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cached_state)
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%s)", StateName);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glDisable(cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
cached_state = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - glEnable(%s)", StateName);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glEnableDisable(GLenum cap, bool enable)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (cap == GL_BLEND) { GLCache::glEnableDisableItem(cap, enable, m_cached_BLEND, "GL_BLEND"); }
|
|
|
|
else if (cap == GL_CULL_FACE) { GLCache::glEnableDisableItem(cap, enable, m_cached_CULL_FACE, "GL_CULL_FACE"); }
|
|
|
|
else if (cap == GL_DEPTH_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_DEPTH_TEST, "GL_DEPTH_TEST"); }
|
|
|
|
else if (cap == GL_DITHER) { GLCache::glEnableDisableItem(cap, enable, m_cached_DITHER, "GL_DITHER"); }
|
|
|
|
else if (cap == GL_POLYGON_OFFSET_FILL) { GLCache::glEnableDisableItem(cap, enable, m_cached_POLYGON_OFFSET_FILL, "GL_POLYGON_OFFSET_FILL"); }
|
|
|
|
else if (cap == GL_SAMPLE_ALPHA_TO_COVERAGE) { GLCache::glEnableDisableItem(cap, enable, m_cached_SAMPLE_ALPHA_TO_COVERAGE, "GL_SAMPLE_ALPHA_TO_COVERAGE"); }
|
|
|
|
else if (cap == GL_SAMPLE_COVERAGE) { GLCache::glEnableDisableItem(cap, enable, m_cached_SAMPLE_COVERAGE, "GL_SAMPLE_COVERAGE"); }
|
|
|
|
else if (cap == GL_SCISSOR_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_SCISSOR_TEST, "GL_SCISSOR_TEST"); }
|
|
|
|
else if (cap == GL_STENCIL_TEST) { GLCache::glEnableDisableItem(cap, enable, m_cached_STENCIL_TEST, "GL_STENCIL_TEST"); }
|
2016-03-10 18:29:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (enable)
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glEnable(%d)", cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glEnable(cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "glDisable(%d)", cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glDisable(cap);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glFrontFace(GLenum mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (mode != m_cached_FrontFace_mode)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glFrontFace(mode);
|
|
|
|
m_cached_FrontFace_mode = mode;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - mode: %d", mode);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glPolygonOffset(GLfloat factor, GLfloat units)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (factor != m_cached_factor || units != m_cached_units)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "factor: %f units: %f", factor, units);
|
|
|
|
::glPolygonOffset(factor, units);
|
|
|
|
m_cached_factor = factor;
|
|
|
|
m_cached_units = units;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - factor: %f units: %f", factor, units);
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (red != m_cached_red || green != m_cached_green || blue != m_cached_blue || alpha != m_cached_alpha)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha);
|
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glClearColor(red, green, blue, alpha);
|
|
|
|
m_cached_red = red;
|
|
|
|
m_cached_green = green;
|
|
|
|
m_cached_blue = blue;
|
|
|
|
m_cached_alpha = alpha;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - red: %f, green: %f, blue: %f, alpha: %f", red, green, blue, alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (x != m_cached_x || y != m_cached_y || width != m_cached_width || height != m_cached_height)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glScissor(x, y, width, height);
|
|
|
|
m_cached_x = x;
|
|
|
|
m_cached_y = y;
|
|
|
|
m_cached_width = width;
|
|
|
|
m_cached_height = height;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glUseProgram(GLuint program)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (program != m_cached_program)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "program: %d", program);
|
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glUseProgram(program);
|
|
|
|
m_cached_program = program;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "Ignored - program: %d", program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 08:13:55 +00:00
|
|
|
void GLCache::glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
2017-04-26 08:13:55 +00:00
|
|
|
if (x != m_Viewport_cached_x || y != m_Viewport_cached_y || width != m_Viewport_cached_width || height != m_Viewport_cached_height)
|
2016-03-10 18:29:41 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
|
|
|
vbo_draw();
|
2017-04-26 08:13:55 +00:00
|
|
|
::glViewport(x, y, width, height);
|
|
|
|
m_Viewport_cached_x = x;
|
|
|
|
m_Viewport_cached_y = y;
|
|
|
|
m_Viewport_cached_width = width;
|
|
|
|
m_Viewport_cached_height = height;
|
2016-03-10 18:29:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTrace(TraceOGLWrapper, TraceDebug, "ignored x: %d, y: %d, width: %d, height: %d", x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|