33 num_texture_units = n_units;
35 for (
unsigned int unit = 0; unit < num_texture_units; unit++) {
55 if (unit < (
GLuint)GL_supported_texture_units) {
67 if (unit < (
GLuint)GL_supported_texture_units) {
77 if (unit < (
GLuint)GL_supported_texture_units) {
111 if ( !((state == -1) || (state == units[active_texture_unit].texgen_S)) ) {
129 if ( !((state == -1) || (state == units[active_texture_unit].texgen_T)) ) {
147 if ( !((state == -1) || (state == units[active_texture_unit].texgen_R)) ) {
165 if ( !((state == -1) || (state == units[active_texture_unit].texgen_Q)) ) {
181 if (units[active_texture_unit].texture_target != tex_target) {
184 if (units[active_texture_unit].texture_id) {
190 default_values(active_texture_unit, tex_target);
197 if (
id >= num_texture_units) {
204 active_texture_unit =
id;
211 if ( units[active_texture_unit].active && (units[active_texture_unit].texture_id == tex_id) ) {
217 glEnable( units[active_texture_unit].texture_target );
221 if (units[active_texture_unit].texture_id != tex_id) {
222 glBindTexture(units[active_texture_unit].texture_target, tex_id);
223 units[active_texture_unit].
texture_id = tex_id;
231 if ( !units[active_texture_unit].active ) {
235 if ( units[active_texture_unit].
enabled ) {
237 glDisable( units[active_texture_unit].texture_target );
247 for (
unsigned int i = 0;
i < num_texture_units;
i++) {
254 for (
unsigned int i = 0;
i < num_texture_units;
i++) {
255 if (!units[
i].used) {
264 for (
unsigned int i = 0;
i < num_texture_units;
i++) {
265 if (units[
i].active) {
283 GLuint atu_save = active_texture_unit;
285 for (
unsigned int i = 0;
i < num_texture_units;
i++) {
286 if (units[
i].texture_id == tex_id) {
293 default_values(
i, units[
i].texture_target);
307 GLfloat rval = units[active_texture_unit].aniso_filter;
309 if ( (aniso > 0.0
f) ) {
311 units[active_texture_unit].aniso_filter = aniso;
318 if (units[active_texture_unit].aniso_filter > 1.0
f) {
334 if (light_Status != NULL) {
362 polygonoffsetfill_Status =
GL_FALSE;
364 polygon_offset_Factor = 0.0f;
365 polygon_offset_Unit = 0.0f;
370 for (i = 0; i < (
int)(
sizeof(clipplane_Status) /
sizeof(
GLboolean)); i++) {
376 for (i = 0; i < (
int)(
sizeof(clipdistance_Status) /
sizeof(
GLboolean)); i++) {
403 blendfunc_Value[0] =
GL_ONE;
416 color_invalid =
true;
423 if ( !((state == -1) || (state == lighting_Status)) ) {
441 if ( !((state == -1) || (state == fog_Status)) ) {
459 if ( !((state == -1) || (state == blend_Status)) ) {
479 if ( !((state == -1) || (state == alphatest_Status)) ) {
497 if ( !((state == -1) || (state == depthtest_Status)) ) {
513 GLboolean save_state = scissortest_Status;
515 if ( !((state == -1) || (state == scissortest_Status)) ) {
531 GLboolean save_state = stenciltest_Status;
533 if ( !((state == -1) || (state == stenciltest_Status)) ) {
551 if ( !((state == -1) || (state == cullface_Status)) ) {
567 if ( polygon_mode_Face != face || polygon_mode_Mode != mode ) {
570 polygon_mode_Face =
face;
571 polygon_mode_Mode =
mode;
577 if ( polygon_offset_Factor != factor || polygon_offset_Unit != units) {
580 polygon_offset_Factor =
factor;
581 polygon_offset_Unit = units;
587 GLboolean save_state = polygonoffsetfill_Status;
589 if ( !((state == -1) || (state == polygonoffsetfill_Status)) ) {
593 polygonoffsetfill_Status =
GL_TRUE;
596 polygonoffsetfill_Status =
GL_FALSE;
607 if ( !((state == -1) || (state == normalize_Status)) ) {
627 if ( !((state == -1) || (state == light_Status[num])) ) {
643 Assert( (num >= 0) || (num < (
int)(
sizeof(clipplane_Status) /
sizeof(
GLboolean))) );
647 if ( !((state == -1) || (state == clipplane_Status[num])) ) {
667 if ( !((state == -1) || (state == clipdistance_Status[num])) ) {
685 if ( !((state == -1) || (state == depthmask_Status)) ) {
705 if ( !((state == -1) || (state == colormask_Status)) ) {
750 if (ab == Current_alpha_blend_mode) {
785 Current_alpha_blend_mode = ab;
790 if (zt == Current_zbuffer_type) {
821 Current_zbuffer_type = zt;
826 if (st == Current_stencil_type) {
852 Current_stencil_type = st;
857 if ( client_texture_units != NULL ) {
866 num_client_texture_units = n_units;
867 active_client_texture_unit = 0;
869 for (
unsigned int i = 0;
i < num_client_texture_units;
i++) {
870 client_texture_units[
i].
pointer = 0;
871 client_texture_units[
i].
size = 4;
873 client_texture_units[
i].
stride = 0;
875 client_texture_units[
i].
buffer = 0;
880 color_array_Buffer = 0;
882 color_array_size = 4;
884 color_array_stride = 0;
885 color_array_pointer = 0;
886 color_array_reset_ptr =
false;
887 color_array_used_for_draw =
false;
889 normal_array_Buffer = 0;
892 normal_array_Stride = 0;
893 normal_array_Pointer = 0;
894 normal_array_reset_ptr =
false;
895 normal_array_used_for_draw =
false;
897 vertex_array_Buffer = 0;
899 vertex_array_Size = 4;
901 vertex_array_Stride = 0;
902 vertex_array_Pointer = 0;
903 vertex_array_reset_ptr =
false;
904 vertex_array_used_for_draw =
false;
907 element_array_buffer = 0;
908 texture_array_buffer = 0;
914 if (
id >= num_client_texture_units ) {
919 if ( active_client_texture_unit ==
id ) {
925 active_client_texture_unit =
id;
930 client_texture_units[active_client_texture_unit].
used_for_draw =
true;
932 if ( client_texture_units[active_client_texture_unit].status ==
GL_TRUE ) {
938 client_texture_units[active_client_texture_unit].
status =
GL_TRUE;
943 if ( client_texture_units[active_client_texture_unit].status ==
GL_FALSE ) {
949 client_texture_units[active_client_texture_unit].
status =
GL_FALSE;
959 && ct_unit->
size == size
960 && ct_unit->
type == type
961 && ct_unit->
stride == stride
962 && ct_unit->
buffer == array_buffer
973 ct_unit->
buffer = array_buffer;
979 color_array_used_for_draw =
true;
981 if ( color_array_Status ==
GL_TRUE ) {
992 if ( color_array_Status ==
GL_FALSE ) {
1004 !color_array_reset_ptr
1005 && color_array_size == size
1006 && color_array_type == type
1007 && color_array_stride == stride
1008 && color_array_pointer == pointer
1009 && color_array_Buffer == array_buffer
1016 color_array_size =
size;
1017 color_array_type =
type;
1018 color_array_stride =
stride;
1019 color_array_pointer =
pointer;
1020 color_array_Buffer = array_buffer;
1021 color_array_reset_ptr =
false;
1026 normal_array_used_for_draw =
true;
1028 if ( normal_array_Status ==
GL_TRUE ) {
1034 normal_array_Status =
GL_TRUE;
1039 if ( normal_array_Status ==
GL_FALSE ) {
1051 !normal_array_reset_ptr
1052 && normal_array_Type == type
1053 && normal_array_Stride == stride
1054 && normal_array_Pointer == pointer
1055 && normal_array_Buffer == array_buffer
1062 normal_array_Type =
type;
1063 normal_array_Stride =
stride;
1064 normal_array_Pointer =
pointer;
1065 normal_array_Buffer = array_buffer;
1066 normal_array_reset_ptr =
false;
1071 vertex_array_used_for_draw =
true;
1073 if ( vertex_array_Status ==
GL_TRUE ) {
1079 vertex_array_Status =
GL_TRUE;
1084 if ( vertex_array_Status ==
GL_FALSE ) {
1096 !vertex_array_reset_ptr
1097 && vertex_array_Size == size
1098 && vertex_array_Type == type
1099 && vertex_array_Stride == stride
1100 && vertex_array_Pointer == pointer
1101 && vertex_array_Buffer == array_buffer
1108 vertex_array_Size =
size;
1109 vertex_array_Type =
type;
1110 vertex_array_Stride =
stride;
1111 vertex_array_Pointer =
pointer;
1112 vertex_array_Buffer = array_buffer;
1113 vertex_array_reset_ptr =
false;
1152 && va_unit->
pointer == pointer
1153 && va_unit->
size == size
1154 && va_unit->
stride == stride
1155 && va_unit->
type == type
1156 && va_unit->
buffer == array_buffer
1168 va_unit->
buffer = array_buffer;
1177 vertex_array_used_for_draw =
false;
1178 color_array_used_for_draw =
false;
1179 normal_array_used_for_draw =
false;
1181 for (
unsigned int i = 0;
i < num_client_texture_units;
i++) {
1187 for (it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it) {
1188 it->second.used_for_draw =
false;
1199 for (
unsigned int i = 0;
i < num_client_texture_units;
i++) {
1200 if ( !client_texture_units[
i].used_for_draw ) {
1208 for (it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it) {
1215 if ( array_buffer ==
id ) {
1223 vertex_array_reset_ptr =
true;
1224 color_array_reset_ptr =
true;
1225 normal_array_reset_ptr =
true;
1227 for (
unsigned int i = 0;
i < num_client_texture_units;
i++) {
1233 for ( it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it ) {
1234 it->second.reset_ptr =
true;
1240 if ( element_array_buffer ==
id ) {
1246 element_array_buffer =
id;
1255 if ( texture_array_buffer ==
id ) {
1261 texture_array_buffer =
id;
1270 if ( uniform_buffer_index_bindings[index] ==
id ) {
1276 uniform_buffer_index_bindings[
index] =
id;
1285 if ( uniform_buffer ==
id ) {
1291 uniform_buffer =
id;
1302 iter = uniform_lookup.find(name);
1304 if ( iter == uniform_lookup.end() ) {
1307 return iter->second;
1313 int uniform_index = findUniform(name);
1314 bool resident =
false;
1316 if ( uniform_index >= 0) {
1317 Assert( (
size_t)uniform_index < uniforms.size() );
1322 if ( uniform_data_ints[bind_info->index] == val ) {
1326 uniform_data_ints[bind_info->index] =
val;
1333 uniform_data_ints.push_back(val);
1338 new_bind.
index = uniform_data_ints.size() - 1;
1342 uniforms.push_back(new_bind);
1344 uniform_lookup[
name] = uniforms.size()-1;
1352 int uniform_index = findUniform(name);
1353 bool resident =
false;
1355 if ( uniform_index >= 0) {
1356 Assert( (
size_t)uniform_index < uniforms.size() );
1361 if (
fl_equal(uniform_data_floats[bind_info->index], val) ) {
1365 uniform_data_floats[bind_info->index] =
val;
1372 uniform_data_floats.push_back(val);
1377 new_bind.
index = uniform_data_floats.size() - 1;
1381 uniforms.push_back(new_bind);
1383 uniform_lookup[
name] = uniforms.size()-1;
1401 int uniform_index = findUniform(name);
1402 bool resident =
false;
1404 if ( uniform_index >= 0 ) {
1405 Assert( (
size_t)uniform_index < uniforms.size() );
1410 if (
vm_vec_equal(uniform_data_vec2d[bind_info->index], val) ) {
1414 uniform_data_vec2d[bind_info->index] =
val;
1421 uniform_data_vec2d.push_back(val);
1426 new_bind.
index = uniform_data_vec2d.size() - 1;
1430 uniforms.push_back(new_bind);
1432 uniform_lookup[
name] = uniforms.size()-1;
1451 int uniform_index = findUniform(name);
1452 bool resident =
false;
1454 if ( uniform_index >= 0 ) {
1455 Assert( (
size_t)uniform_index < uniforms.size() );
1460 if (
vm_vec_equal(uniform_data_vec3d[bind_info->index], val) ) {
1464 uniform_data_vec3d[bind_info->index] =
val;
1471 uniform_data_vec3d.push_back(val);
1476 new_bind.
index = uniform_data_vec3d.size() - 1;
1480 uniforms.push_back(new_bind);
1482 uniform_lookup[
name] = uniforms.size()-1;
1490 int uniform_index = findUniform(name);
1491 bool resident =
false;
1493 if ( uniform_index >= 0 ) {
1494 Assert( (
size_t)uniform_index < uniforms.size() );
1499 if (
vm_vec_equal(uniform_data_vec4[bind_info->index], val) ) {
1504 uniform_data_vec4[bind_info->index] =
val;
1511 uniform_data_vec4.push_back(val);
1516 new_bind.
index = uniform_data_vec4.size() - 1;
1520 uniforms.push_back(new_bind);
1522 uniform_lookup[
name] = uniforms.size()-1;
1530 int uniform_index = findUniform(name);
1531 bool resident =
false;
1533 if ( uniform_index >= 0) {
1534 Assert( (
size_t)uniform_index < uniforms.size() );
1543 uniform_data_matrix4[bind_info->index] =
val;
1552 uniform_data_matrix4.push_back(val);
1557 new_bind.
index = uniform_data_matrix4.size() - 1;
1562 uniforms.push_back(new_bind);
1564 uniform_lookup[
name] = uniforms.size()-1;
1572 int uniform_index = findUniform(name);
1573 bool resident =
false;
1575 if ( uniform_index >= 0) {
1576 Assert( (
size_t)uniform_index < uniforms.size() );
1584 for (
int i = 0;
i <
count; ++
i ) {
1585 if ( !
vm_matrix_equal(val[
i], uniform_data_matrix4[bind_info->index+i]) ) {
1596 for (
int i = 0;
i <
count; ++
i ) {
1597 uniform_data_matrix4[bind_info->index+
i] = val[
i];
1604 for (
int i = 0;
i <
count; ++
i ) {
1605 uniform_data_matrix4.push_back(val[
i]);
1610 new_bind.
index = uniform_data_matrix4.size() -
count;
1615 uniforms.push_back(new_bind);
1617 uniform_lookup[
name] = uniforms.size()-1;
1627 uniform_data_ints.clear();
1628 uniform_data_floats.clear();
1629 uniform_data_vec2d.clear();
1630 uniform_data_vec3d.clear();
1631 uniform_data_vec4.clear();
1632 uniform_data_matrix4.clear();
1634 uniform_lookup.clear();
1692 if (factor >= 1.0
f) {
1706 if (factor < 1.0
f) {
1718 if (flags & TMAP_FLAG_TEXTURED) {
GLboolean ColorMask(GLint state=-1)
WINGDIAPI void APIENTRY glEnableClientState(GLenum array)
void EnableVertexAttrib(GLuint index)
void SetPolygonMode(GLenum face, GLenum mode)
WINGDIAPI void APIENTRY glCullFace(GLenum mode)
#define GL_ELEMENT_ARRAY_BUFFER_ARB
WINGDIAPI void APIENTRY glTexGeni(GLenum coord, GLenum pname, GLint param)
#define vglVertexAttribPointerARB
void init(GLuint n_units)
#define vglUniformMatrix4fvARB
bool vm_vec_equal(const vec4 &self, const vec4 &other)
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer)
void BindUniformBufferBindingIndex(GLuint id, GLuint index)
GLint opengl_shader_get_uniform(const char *uniform_text)
void opengl_setup_render_states(int &r, int &g, int &b, int &alpha, int &tmap_type, int flags, int is_scaler)
#define GL_ONE_MINUS_SRC_ALPHA
#define GL_TEXTURE_2D_ARRAY_EXT
void SetTextureSource(gr_texture_source ts)
GLboolean StencilTest(GLint state=-1)
WINGDIAPI void APIENTRY glDisable(GLenum cap)
#define GL_POLYGON_OFFSET_FILL
GLboolean ScissorTest(GLint state=-1)
WINGDIAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param)
WINGDIAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param)
GLboolean DepthTest(GLint state=-1)
GLboolean TexgenR(GLint state=-1)
WINGDIAPI void APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
struct vec3d::@225::@227 xyz
WINGDIAPI void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
#define OGL_ARB_TEXTURE_BUFFER
void SetZbufferType(gr_zbuffer_type zt)
void BindElementBuffer(GLuint id)
#define OGL_ARB_UNIFORM_BUFFER_OBJECT
void EnableClientNormal()
#define GL_ONE_MINUS_SRC_COLOR
opengl_texture_state Texture
#define GR_FILL_MODE_SOLID
void EnableClientTexture()
GLboolean CullFace(GLint state=-1)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
void DisableClientVertex()
bool fl_equal(float a, float b)
bool bm_has_alpha_channel(int handle)
Checks to see if the indexed bitmap has an alpha channel.
WINGDIAPI void APIENTRY glEnable(GLenum cap)
#define TMAP_FLAG_BW_TEXTURE
void gr_opengl_clear_states()
GLboolean TexgenQ(GLint state=-1)
GLfloat AnisoFilter(GLfloat aniso=0.0f)
GLenum GLsizei GLsizei const GLvoid * pointer
void DisableClientNormal()
#define CLAMP(x, min, max)
void SetEnvMode(GLenum mode)
void SetStencilType(gr_stencil_type st)
GLint GLenum GLboolean normalized
#define vglBindBufferBaseEXT
GLenum GLuint GLint GLenum face
#define GL_UNIFORM_BUFFER
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void DisableClientColor()
#define GR_ALPHABLEND_FILTER
GLboolean DepthMask(GLint state=-1)
GLdouble GLdouble GLdouble r
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define OGL_EXT_TEXTURE_LOD_BIAS
#define vglEnableVertexAttribArrayARB
void SetPolygonOffset(GLfloat factor, GLfloat units)
GLfloat GL_max_anisotropy
GLboolean Light(GLint num, GLint state=-1)
GLboolean AlphaTest(GLint state=-1)
WINGDIAPI void APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
#define TCACHE_TYPE_INTERFACE
GLint GL_supported_texture_units
WINGDIAPI void APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
void SetAlphaBlendMode(gr_alpha_blend ab)
#define GL_TEXTURE_MAX_ANISOTROPY_EXT
void VertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
WINGDIAPI void APIENTRY glDepthFunc(GLenum func)
WINGDIAPI void APIENTRY glFrontFace(GLenum mode)
#define GL_TEXTURE_LOD_BIAS
WINGDIAPI void APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
void TexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
#define TMAP_FLAG_INTERFACE
WINGDIAPI void APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
#define Is_Extension_Enabled(x)
void BlendFunc(GLenum s_val, GLenum d_val)
void SetTarget(GLenum tex_target)
GLint GLint GLint GLint GLint x
GLboolean Normalize(GLint state=-1)
void Enable(GLuint tex_id=0)
void NormalPointer(GLenum type, GLsizei stride, GLvoid *pointer)
GLboolean Blend(GLint state=-1)
#define TCACHE_TYPE_XPARENT
GLboolean TexgenT(GLint state=-1)
void ColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
#define vglActiveTextureARB
void init(GLuint n_units)
GLuint const GLchar * name
void BindArrayBuffer(GLuint id)
GLboolean GLboolean GLboolean b
GLboolean PolygonOffsetFill(GLint state=-1)
void DisableVertexAttrib(GLuint index)
GLboolean ClipPlane(GLint num, GLint state=-1)
void EnableClientVertex()
#define GL_ARRAY_BUFFER_ARB
#define GL_TEXTURE_ENV_MODE
GLboolean Fog(GLint state=-1)
WINGDIAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
#define GL_TEXTURE_CUBE_MAP
#define vglClientActiveTextureARB
WINGDIAPI void APIENTRY glDepthMask(GLboolean flag)
#define TCACHE_TYPE_NORMAL
void DisableClientTexture()
bool vm_matrix_equal(const matrix &self, const matrix &other)
WINGDIAPI void APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
#define GL_TEXTURE_GEN_MODE
#define OGL_EXT_TEXTURE_FILTER_ANISOTROPIC
#define TMAP_FLAG_TEXTURED
WINGDIAPI void APIENTRY glBindTexture(GLenum target, GLuint texture)
WINGDIAPI void APIENTRY glPolygonMode(GLenum face, GLenum mode)
WINGDIAPI void APIENTRY glDisableClientState(GLenum array)
int current_alphablend_mode
#define gr_reset_lighting
WINGDIAPI void APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
void Delete(GLuint tex_id)
void SetActiveClientUnit(GLuint id)
GLenum DepthFunc(GLenum new_val=GL_INVALID_ENUM)
void BindTextureBuffer(GLuint id)
void BindUniformBuffer(GLuint id)
#define vglDisableVertexAttribArrayARB
GLboolean TexgenS(GLint state=-1)
void opengl_shader_set_current(opengl_shader_t *shader_obj)
GLclampf GLclampf GLclampf alpha
gr_texture_source Current_texture_source
#define GL_TEXTURE_FILTER_CONTROL
#define GL_TEXTURE_COORD_ARRAY
#define GL_TEXTURE_BUFFER_ARB
GLboolean ClipDistance(GLint num, GLint state=-1)
void SetActiveUnit(GLuint id=0)
WINGDIAPI void APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
GLboolean Lighting(GLint state=-1)