Use gl*ARB wherever possible. They are mapped onto the core gl* function if the driver's version is high enough, else onto the extension's gl*ARB function.
(Just for fun, compressed texture uploads are mapped onto a decompression function if the user's system doesn't understand S3TC textures.) Corrected (unless I'm wrong) GL version identification logic. This was SVN commit r2384.
This commit is contained in:
parent
dd3c8f6fb5
commit
d24fd1b0c9
@ -283,7 +283,7 @@ public:
|
||||
|
||||
// Texture unit 1:
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTextureARB(GL_TEXTURE1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
tex_bind(tex);
|
||||
|
||||
@ -305,7 +305,7 @@ public:
|
||||
void Unset()
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,54 +8,77 @@ typedef void* HGLRC;
|
||||
typedef void* HPBUFFERARB;
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
FUNC is used for functions that are only extensions.
|
||||
FUNC2 is used for functions that have been promoted to core features.
|
||||
|
||||
The FUNC2 call includes the version of OpenGL in which the extension was promoted,
|
||||
and the pre- and post-promotion names (e.g. "glBindBufferARB" vs "glBindBuffer").
|
||||
|
||||
If the GL driver is advertising a sufficiently high version, we load the promoted
|
||||
name; otherwise we use the *ARB name. (The spec says:
|
||||
"GL implementations of such later revisions should continue to export the name
|
||||
strings of promoted extensions in the EXTENSIONS string, and continue to support
|
||||
the ARB-affixed versions of functions and enumerants as a transition aid."
|
||||
but some drivers might be stupid/buggy and fail to do that, so we don't just use
|
||||
the ARB names unconditionally.)
|
||||
|
||||
The names are made accessible to engine code only via the ARB name, to make it
|
||||
obvious that care must be taken (i.e. by being certain that the extension is
|
||||
actually supported).
|
||||
|
||||
*/
|
||||
|
||||
// were these defined as real functions in gl.h already?
|
||||
|
||||
#ifndef REAL_GL_1_2
|
||||
FUNC(void, glMultiTexCoord2f, (int, float, float))
|
||||
FUNC(void, glDrawRangeElements,(GLenum,GLuint,GLuint,GLsizei,GLenum,GLvoid*))
|
||||
// GL_EXT_draw_range_elements / GL1.2:
|
||||
FUNC2(void, glDrawRangeElementsEXT, glDrawRangeElements, "1.2", (GLenum, GLuint, GLuint, GLsizei, GLenum, GLvoid*))
|
||||
#endif
|
||||
|
||||
#ifndef REAL_GL_1_3
|
||||
FUNC(void, glActiveTexture, (int))
|
||||
FUNC(void, glClientActiveTexture, (int))
|
||||
// GL_ARB_multitexture / GL1.3:
|
||||
FUNC2(void, glMultiTexCoord2fARB, glMultiTexCoord2f, "1.3", (int, float, float))
|
||||
FUNC2(void, glActiveTextureARB, glActiveTexture, "1.3", (int))
|
||||
FUNC2(void, glClientActiveTextureARB, glClientActiveTexture, "1.3", (int))
|
||||
#endif
|
||||
|
||||
// EXT_swap_control
|
||||
// GL_ARB_vertex_buffer_object / GL1.5:
|
||||
FUNC2(void, glBindBufferARB, glBindBuffer, "1.5", (int target, GLuint buffer))
|
||||
FUNC2(void, glDeleteBuffersARB, glDeleteBuffers, "1.5", (GLsizei n, const GLuint* buffers))
|
||||
FUNC2(void, glGenBuffersARB, glGenBuffers, "1.5", (GLsizei n, GLuint* buffers))
|
||||
FUNC2(bool, glIsBufferARB, glIsBuffer, "1.5", (GLuint buffer))
|
||||
FUNC2(void, glBufferDataARB, glBufferData, "1.5", (int target, GLsizeiptrARB size, const void* data, int usage))
|
||||
FUNC2(void, glBufferSubDataARB, glBufferSubData, "1.5", (int target, GLintptrARB offset, GLsizeiptrARB size, const void* data))
|
||||
FUNC2(void, glGetBufferSubDataARB, glGetBufferSubData, "1.5", (int target, GLintptrARB offset, GLsizeiptrARB size, void* data))
|
||||
FUNC2(void*, glMapBufferARB, glMapBuffer, "1.5", (int target, int access))
|
||||
FUNC2(bool, glUnmapBufferARB, glUnmapBuffer, "1.5", (int target))
|
||||
FUNC2(void, glGetBufferParameterivARB, glGetBufferParameteriv, "1.5", (int target, int pname, int* params))
|
||||
FUNC2(void, glGetBufferPointervARB, glGetBufferPointerv, "1.5", (int target, int pname, void** params))
|
||||
|
||||
// GL_ARB_texture_compression / GL1.3
|
||||
FUNC2(void, glCompressedTexImage3DARB, glCompressedTexImage3D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glCompressedTexImage2DARB, glCompressedTexImage2D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glCompressedTexImage1DARB, glCompressedTexImage1D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glCompressedTexSubImage3DARB, glCompressedTexSubImage3D, "1.3", (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glCompressedTexSubImage2DARB, glCompressedTexSubImage2D, "1.3", (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glCompressedTexSubImage1DARB, glCompressedTexSubImage1D, "1.3", (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC2(void, glGetCompressedTexImageARB, glGetCompressedTexImage, "1.3", (GLenum, GLint, GLvoid*))
|
||||
|
||||
#ifdef _WIN32
|
||||
// WGL_EXT_swap_control
|
||||
FUNC(int, wglSwapIntervalEXT, (int))
|
||||
|
||||
// ARB_vertex_array_object
|
||||
FUNC(void, glBindBufferARB, (int target, GLuint buffer))
|
||||
FUNC(void, glDeleteBuffersARB, (GLsizei n, const GLuint* buffers))
|
||||
FUNC(void, glGenBuffersARB, (GLsizei n, GLuint* buffers))
|
||||
FUNC(bool, glIsBufferARB, (GLuint buffer))
|
||||
FUNC(void, glBufferDataARB, (int target, GLsizeiptrARB size, const void* data, int usage))
|
||||
FUNC(void, glBufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, const void* data))
|
||||
FUNC(void, glGetBufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, void* data))
|
||||
FUNC(void*, glMapBufferARB, (int target, int access))
|
||||
FUNC(bool, glUnmapBufferARB, (int target))
|
||||
FUNC(void, glGetBufferParameterivARB, (int target, int pname, int* params))
|
||||
FUNC(void, glGetBufferPointervARB, (int target, int pname, void** params))
|
||||
|
||||
// ARB_pbuffer
|
||||
#ifdef _WIN32
|
||||
// WGL_ARB_pbuffer
|
||||
FUNC(HPBUFFERARB, wglCreatePbufferARB, (HDC, int, int, int, const int*))
|
||||
FUNC(HDC, wglGetPbufferDCARB, (HPBUFFERARB))
|
||||
FUNC(int, wglReleasePbufferDCARB, (HPBUFFERARB, HDC))
|
||||
FUNC(int, wglDestroyPbufferARB, (HPBUFFERARB))
|
||||
FUNC(int, wglQueryPbufferARB, (HPBUFFERARB, int, int*))
|
||||
|
||||
// ARB_pixel_format
|
||||
// GL_ARB_pixel_format
|
||||
FUNC(int, wglGetPixelFormatAttribivARB, (HDC, int, int, unsigned int, const int*, int*))
|
||||
FUNC(int, wglGetPixelFormatAttribfvARB, (HDC, int, int, unsigned int, const int*, float*))
|
||||
FUNC(int, wglChoosePixelFormatARB, (HDC, const int *, const float*, unsigned int, int*, unsigned int*))
|
||||
#endif // _WIN32
|
||||
|
||||
// ARB_texture_compression
|
||||
FUNC(void, glCompressedTexImage3DARB, (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC(void, glCompressedTexImage2DARB, (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC(void, glCompressedTexImage1DARB, (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid*))
|
||||
FUNC(void, glCompressedTexSubImage3DARB, (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC(void, glCompressedTexSubImage2DARB, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC(void, glCompressedTexSubImage1DARB, (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid*))
|
||||
FUNC(void, glGetCompressedTexImageARB, (GLenum, GLint, GLvoid*))
|
||||
|
@ -21,7 +21,9 @@
|
||||
extern "C"
|
||||
{
|
||||
#define FUNC(ret, name, params) ret (CALL_CONV *name) params;
|
||||
#define FUNC2(ret, nameARB, nameCore, version, params) ret (CALL_CONV *nameARB) params;
|
||||
#include "glext_funcs.h"
|
||||
#undef FUNC2
|
||||
#undef FUNC
|
||||
}
|
||||
|
||||
@ -76,7 +78,8 @@ bool oglHaveVersion(const char* desired_version)
|
||||
return false;
|
||||
}
|
||||
|
||||
return (major > desired_major || minor >= desired_minor);
|
||||
return (major > desired_major
|
||||
|| (major == desired_major && minor >= desired_minor));
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +174,8 @@ const char* oglExtList()
|
||||
}
|
||||
|
||||
|
||||
void CALL_CONV oglEmulateCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
|
||||
|
||||
// call after each video mode change
|
||||
void oglInit()
|
||||
{
|
||||
@ -182,8 +187,18 @@ void oglInit()
|
||||
|
||||
// import functions
|
||||
#define FUNC(ret, name, params) *(void**)&name = SDL_GL_GetProcAddress(#name);
|
||||
#define FUNC2(ret, nameARB, nameCore, version, params) \
|
||||
nameARB = NULL; \
|
||||
if(oglHaveVersion(version)) \
|
||||
*(void**)&nameARB = SDL_GL_GetProcAddress(#nameCore); \
|
||||
if(!nameARB) /* use the ARB name if the driver lied about what version it supports */ \
|
||||
*(void**)&nameARB = SDL_GL_GetProcAddress(#nameARB);
|
||||
#include "glext_funcs.h"
|
||||
#undef FUNC2
|
||||
#undef FUNC
|
||||
// It should be safe to load the ARB function pointers even if the
|
||||
// extension isn't advertised, since we won't actually use them without
|
||||
// checking for the extension.
|
||||
|
||||
// detect OpenGL / graphics card caps
|
||||
|
||||
@ -193,9 +208,174 @@ void oglInit()
|
||||
if(oglHaveExtension("GL_NV_vertex_array_range"))
|
||||
glGetIntegerv(GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV, &max_VAR_elements);
|
||||
|
||||
tex_compression_avail = oglHaveExtension("GL_ARB_texture_compression") &&
|
||||
(oglHaveExtension("GL_EXT_texture_compression_s3tc") || oglHaveExtension("GL_S3_s3tc"));
|
||||
tex_compression_avail = (oglHaveExtension("GL_ARB_texture_compression") || oglHaveVersion("1.3")) &&
|
||||
(oglHaveExtension("GL_EXT_texture_compression_s3tc"));
|
||||
// TODO: GL_S3_s3tc? It uses different enumerants (GL_RGB_S3TC etc), so the
|
||||
// texture loading code would need to be changed; and it is not clear whether
|
||||
// it supports the full range of DXT1/3/5. (There seems to be no specification;
|
||||
// and many header files don't have GL_RGBA_DXT5_S3TC, suggesting that the
|
||||
// drivers don't all support that.)
|
||||
|
||||
if(!tex_compression_avail)
|
||||
{
|
||||
// If there's no hardware support for compressed textures, do the
|
||||
// decompression in software (but first let the user know it's probably not
|
||||
// going to be very fast).
|
||||
wdisplay_msg(L"Performance warning", L"Your graphics card does not support compressed textures. The game will try to continue anyway, but may be slower than expected. Please try updating your graphics drivers; if that doesn't help, please try upgrading your hardware.");
|
||||
// TODO: i18n
|
||||
glCompressedTexImage2DARB = oglEmulateCompressedTexImage2D;
|
||||
|
||||
// Leave tex_compression_avail == false, so that it indicates the presence
|
||||
// of hardware-supported texture compression.
|
||||
}
|
||||
|
||||
video_mem = (SDL_GetVideoInfo()->video_mem) / 1048576; // [MiB]
|
||||
// TODO: add sizeof(FB)?
|
||||
}
|
||||
|
||||
|
||||
void CALL_CONV oglEmulateCompressedTexImage2D
|
||||
(GLenum target, GLint level, GLenum internalformat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, const GLvoid* data)
|
||||
{
|
||||
// Software emulation of compressed-texture support, for really old
|
||||
// cards/drivers that can't do it (but which do support everything else
|
||||
// we strictly require). They probably don't have enough VRAM for all the
|
||||
// textures, and are slow anyway, so it's not going to be a pleasant way
|
||||
// of playing; but at least it's better than nothing.
|
||||
|
||||
GLenum base_fmt = (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? GL_RGB : GL_RGBA);
|
||||
|
||||
// TODO: handle small (<4x4) images correctly
|
||||
GLsizei blocks_w = (GLsizei)(round_up(width, 4) / 4);
|
||||
GLsizei blocks_h = (GLsizei)(round_up(height, 4) / 4);
|
||||
GLsizei blocks = blocks_w * blocks_h;
|
||||
GLsizei size = blocks * 16 * (base_fmt == GL_RGB ? 3 : 4);
|
||||
GLsizei pitch = size / (blocks_h*4);
|
||||
void* rgb_data = malloc(size);
|
||||
|
||||
bool dxt1 = (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
|
||||
bool dxt3 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
|
||||
bool dxt5 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
|
||||
assert(dxt1 || dxt3 || dxt5);
|
||||
|
||||
assert(imageSize == blocks * (dxt1? 8 : 16));
|
||||
|
||||
// This code is inefficient, but I don't care:
|
||||
|
||||
for(GLsizei block_y = 0; block_y < blocks_h; ++block_y)
|
||||
for(GLsizei block_x = 0; block_x < blocks_w; ++block_x)
|
||||
{
|
||||
int c0_a = 255, c1_a = 255, c2_a = 255, c3_a = 255;
|
||||
u8* alpha = NULL;
|
||||
u8 dxt5alpha[8];
|
||||
|
||||
if(!dxt1)
|
||||
{
|
||||
alpha = (u8*)data;
|
||||
data = (char*)data + 8;
|
||||
|
||||
if(dxt5)
|
||||
{
|
||||
dxt5alpha[0] = alpha[0];
|
||||
dxt5alpha[1] = alpha[1];
|
||||
if(alpha[0] > alpha[1])
|
||||
{
|
||||
dxt5alpha[2] = (6*alpha[0] + 1*alpha[1] + 3)/7;
|
||||
dxt5alpha[3] = (5*alpha[0] + 2*alpha[1] + 3)/7;
|
||||
dxt5alpha[4] = (4*alpha[0] + 3*alpha[1] + 3)/7;
|
||||
dxt5alpha[5] = (3*alpha[0] + 4*alpha[1] + 3)/7;
|
||||
dxt5alpha[6] = (2*alpha[0] + 5*alpha[1] + 3)/7;
|
||||
dxt5alpha[7] = (1*alpha[0] + 6*alpha[1] + 3)/7;
|
||||
}
|
||||
else
|
||||
{
|
||||
dxt5alpha[2] = (4*alpha[0] + 1*alpha[1] + 2)/5;
|
||||
dxt5alpha[3] = (3*alpha[0] + 2*alpha[1] + 2)/5;
|
||||
dxt5alpha[4] = (2*alpha[0] + 3*alpha[1] + 2)/5;
|
||||
dxt5alpha[5] = (1*alpha[0] + 4*alpha[1] + 2)/5;
|
||||
dxt5alpha[6] = 0;
|
||||
dxt5alpha[7] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u16 c0 = *(u16*)( (char*)data + 0 );
|
||||
u16 c1 = *(u16*)( (char*)data + 2 );
|
||||
u32 bits = *(u32*)( (char*)data + 4 );
|
||||
|
||||
data = (char*)data + 8;
|
||||
|
||||
// Unpack 565, and copy high bits to low bits
|
||||
int c0_r = ((c0>>8)&0xF8) | ((c0>>13)&7);
|
||||
int c1_r = ((c1>>8)&0xF8) | ((c1>>13)&7);
|
||||
int c0_g = ((c0>>3)&0xFC) | ((c0>>9 )&3);
|
||||
int c1_g = ((c1>>3)&0xFC) | ((c1>>9 )&3);
|
||||
int c0_b = ((c0<<3)&0xF8) | ((c0>>2 )&7);
|
||||
int c1_b = ((c1<<3)&0xF8) | ((c1>>2 )&7);
|
||||
int c2_r, c2_g, c2_b;
|
||||
int c3_r, c3_g, c3_b;
|
||||
if(!dxt1 || c0 > c1)
|
||||
{
|
||||
c2_r = (c0_r*2+c1_r+1)/3; c2_g = (c0_g*2+c1_g+1)/3; c2_b = (c0_b*2+c1_b+1)/3;
|
||||
c3_r = (c0_r+2*c1_r+1)/3; c3_g = (c0_g+2*c1_g+1)/3; c3_b = (c0_b+2*c1_b+1)/3;
|
||||
}
|
||||
else
|
||||
{
|
||||
c2_r = (c0_r+c1_r)/2; c2_g = (c0_g+c1_g)/2; c2_b = (c0_b+c1_b)/2;
|
||||
c3_r = c3_g = c3_b = c3_a = 0;
|
||||
}
|
||||
|
||||
if(base_fmt == GL_RGB)
|
||||
{
|
||||
int i = 0;
|
||||
for(int y = 0; y < 4; ++y)
|
||||
{
|
||||
u8* out = (u8*)rgb_data + ((block_y*4+y)*blocks_w*4 + block_x*4) * 3;
|
||||
for(int x = 0; x < 4; ++x, ++i)
|
||||
{
|
||||
switch((bits >> (2*i)) & 3) {
|
||||
case 0: *out++ = c0_r; *out++ = c0_g; *out++ = c0_b; break;
|
||||
case 1: *out++ = c1_r; *out++ = c1_g; *out++ = c1_b; break;
|
||||
case 2: *out++ = c2_r; *out++ = c2_g; *out++ = c2_b; break;
|
||||
case 3: *out++ = c3_r; *out++ = c3_g; *out++ = c3_b; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
for(int y = 0; y < 4; ++y)
|
||||
{
|
||||
u8* out = (u8*)rgb_data + ((block_y*4+y)*blocks_w*4 + block_x*4) * 4;
|
||||
for(int x = 0; x < 4; ++x, ++i)
|
||||
{
|
||||
int a;
|
||||
switch((bits >> (2*i)) & 3) {
|
||||
case 0: *out++ = c0_r; *out++ = c0_g; *out++ = c0_b; a = c0_a; break;
|
||||
case 1: *out++ = c1_r; *out++ = c1_g; *out++ = c1_b; a = c1_a; break;
|
||||
case 2: *out++ = c2_r; *out++ = c2_g; *out++ = c2_b; a = c2_a; break;
|
||||
case 3: *out++ = c3_r; *out++ = c3_g; *out++ = c3_b; a = c3_a; break;
|
||||
}
|
||||
if(dxt3)
|
||||
{
|
||||
a = (int)((*(u64*)alpha >> (4*i)) & 0xF);
|
||||
a |= a<<4; // copy low bits to high bits
|
||||
}
|
||||
else if(dxt5)
|
||||
{
|
||||
a = dxt5alpha[(*(u64*)(alpha+2) >> (3*i)) & 0x7];
|
||||
}
|
||||
*out++ = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D(target, level, base_fmt==GL_RGB? GL_RGB8 : GL_RGBA8, width, height, border, base_fmt, GL_UNSIGNED_BYTE, rgb_data);
|
||||
|
||||
free(rgb_data);
|
||||
}
|
||||
|
@ -69,7 +69,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define FUNC(ret, name, params) extern ret (CALL_CONV *name) params;
|
||||
#define FUNC2(ret, nameARB, nameCore, version, params) extern ret (CALL_CONV *nameARB) params;
|
||||
#include "glext_funcs.h"
|
||||
#undef FUNC2
|
||||
#undef FUNC
|
||||
|
||||
// leave CALL_CONV defined for ogl.cpp
|
||||
|
@ -49,7 +49,7 @@ struct TexInfo
|
||||
size_t ofs; // offset to image data in file
|
||||
uint w : 16;
|
||||
uint h : 16;
|
||||
uint bpp : 16;
|
||||
uint bpp : 16; // average bits per pixel
|
||||
uint flags : 16;
|
||||
};
|
||||
|
||||
|
@ -201,7 +201,7 @@ static int get_ogl_drv_name(char* ogl_drv_name, const size_t max_name_len)
|
||||
|
||||
// we just use the first entry. it might be wrong on dual-graphics card
|
||||
// systems, but I don't see a better way to do it. there's no other
|
||||
// occurence of the OpenGL driver name in the registry on my system.
|
||||
// occurrence of the OpenGL driver name in the registry on my system.
|
||||
char key_name[32];
|
||||
DWORD key_name_len = sizeof(key_name);
|
||||
if(RegEnumKeyEx(hkOglDrivers, 0, key_name, &key_name_len, 0, 0, 0, 0) == 0)
|
||||
|
@ -1212,9 +1212,12 @@ sle(11340106);
|
||||
snd_disable(true);
|
||||
}
|
||||
|
||||
if(!oglHaveExtension("GL_ARB_multitexture") || !oglHaveExtension("GL_ARB_texture_env_combine") ||
|
||||
!glActiveTexture) // prevent crashing later if multitexture support is falsely
|
||||
// advertised (janwas 2004-08-25, for bug #18)
|
||||
if(!tex_compression_avail)
|
||||
{
|
||||
LOG(WARNING, LOG_CATEGORY, "S3TC compressed textures not supported; will use software version instead");
|
||||
}
|
||||
|
||||
if(!oglHaveExtension("GL_ARB_multitexture") || !oglHaveExtension("GL_ARB_texture_env_combine"))
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "Required ARB_multitexture or ARB_texture_env_combine extension not available");
|
||||
throw PSERROR_System_RequiredExtensionsMissing();
|
||||
|
@ -479,10 +479,10 @@ void CPatchRData::RenderBlends()
|
||||
glVertexPointer(3,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_Position));
|
||||
glColorPointer(4,GL_UNSIGNED_BYTE,stride,base+offsetof(SBlendVertex,m_Color));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0_ARB);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_UVs[0]));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1_ARB);
|
||||
glClientActiveTextureARB(GL_TEXTURE1);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_AlphaUVs[0]));
|
||||
|
||||
for (uint i=0;i<(uint)m_BlendSplats.size();i++) {
|
||||
@ -580,8 +580,8 @@ void CPatchRData::RenderBaseSplats()
|
||||
|
||||
// set up texture environment for base pass
|
||||
MICROLOG(L"base splat textures");
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
oglCheck();
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
@ -658,9 +658,9 @@ void CPatchRData::RenderBlendSplats()
|
||||
uint i;
|
||||
|
||||
// switch on second uv set
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glClientActiveTextureARB(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
|
||||
// switch on the composite alpha map texture
|
||||
g_Renderer.BindTexture(1,g_Renderer.m_CompositeAlphaMap);
|
||||
@ -712,10 +712,10 @@ void CPatchRData::RenderBlendSplats()
|
||||
u32 stride=sizeof(SBlendVertex);
|
||||
glVertexPointer(3,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_Position));
|
||||
glColorPointer(4,GL_UNSIGNED_BYTE,stride,base+offsetof(SBlendVertex,m_Color));
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_UVs[0]));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glClientActiveTextureARB(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_AlphaUVs[0]));
|
||||
|
||||
@ -750,17 +750,17 @@ void CPatchRData::RenderBlendSplats()
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// switch off second uv set
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glClientActiveTextureARB(GL_TEXTURE1);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
|
||||
// switch off texture unit 1, make unit 0 active texture
|
||||
g_Renderer.BindTexture(1,0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
|
||||
// tidy up client states
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0_ARB);
|
||||
glClientActiveTextureARB(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,13 +28,13 @@ void CPlayerRenderer::SetupColorRenderStates()
|
||||
// but passes alpha through inverted; the second texture unit modulates
|
||||
// with the player colour.
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTextureARB(GL_TEXTURE1);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
@ -69,7 +69,7 @@ void CPlayerRenderer::Render()
|
||||
|
||||
|
||||
// set up texture environment for base pass - modulate texture and primary color
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
|
||||
@ -115,12 +115,12 @@ void CPlayerRenderer::Render()
|
||||
|
||||
|
||||
// Restore states
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTextureARB(GL_TEXTURE1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
|
||||
// switch off client states
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
@ -654,7 +654,7 @@ void CRenderer::RenderShadowMap()
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(1,1,m_Width-2,m_Height-2);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PRIMARY_COLOR_ARB);
|
||||
@ -799,7 +799,7 @@ void CRenderer::RenderPatches()
|
||||
void CRenderer::RenderModelSubmissions()
|
||||
{
|
||||
// set up texture environment for base pass - modulate texture and primary color
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTextureARB(GL_TEXTURE0);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
|
||||
@ -1090,7 +1090,7 @@ bool CRenderer::LoadTexture(CTexture* texture,u32 wrapflags)
|
||||
void CRenderer::BindTexture(int unit,GLuint tex)
|
||||
{
|
||||
#if 0
|
||||
glActiveTexture(GL_TEXTURE0+unit);
|
||||
glActiveTextureARB(GL_TEXTURE0+unit);
|
||||
if (tex==m_ActiveTextures[unit]) return;
|
||||
|
||||
if (tex) {
|
||||
@ -1104,7 +1104,7 @@ void CRenderer::BindTexture(int unit,GLuint tex)
|
||||
m_ActiveTextures[unit]=tex;
|
||||
#endif
|
||||
|
||||
glActiveTexture(GL_TEXTURE0+unit);
|
||||
glActiveTextureARB(GL_TEXTURE0+unit);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,tex);
|
||||
if (tex) {
|
||||
|
@ -177,11 +177,8 @@ void CVertexBuffer::AppendBatch(VBChunk* UNUSEDPARAM(chunk),Handle texture,size_
|
||||
batch->m_Texture=texture;
|
||||
}
|
||||
|
||||
// resize the chunk's batch to fit it's indices
|
||||
size_t cursize=batch->m_IndexData.size();
|
||||
batch->m_IndexData.resize(cursize+1);
|
||||
// store batch
|
||||
batch->m_IndexData[cursize]=std::pair<size_t,u16*>(numIndices,indices);
|
||||
// resize the chunk's batch to fit its indices
|
||||
batch->m_IndexData.push_back(std::pair<size_t,u16*>(numIndices,indices));
|
||||
// memcpy(&batch->m_Indices[0]+cursize,indices,sizeof(u16)*numIndices);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user