summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2023-09-10 18:42:56 +0800
committerErik Kundiman <erik@megapahit.org>2023-09-10 18:42:56 +0800
commita4543cf3cd41a466599de61f02e6d3b3d09700c4 (patch)
tree6743beff840669800d4bdc445919bd8f09a06cd5 /indra/llrender
parent52d973e95567efcb145ed0de1f4b6f0e19663776 (diff)
parent0797257992ee7f88456d3083ebf214485b75c139 (diff)
Merge branch 'main' into DRTVWR-559
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/CMakeLists.txt1
-rw-r--r--indra/llrender/llgl.cpp22
-rw-r--r--indra/llrender/llglheaders.h13
-rw-r--r--indra/llrender/llglslshader.cpp11
-rw-r--r--indra/llrender/llglstates.h2
-rw-r--r--indra/llrender/llimagegl.cpp112
-rw-r--r--indra/llrender/llpostprocess.cpp12
-rw-r--r--indra/llrender/llrender.cpp26
-rw-r--r--indra/llrender/llrendertarget.cpp2
9 files changed, 186 insertions, 15 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt
index 9454943dc5..2bb75d3f37 100644
--- a/indra/llrender/CMakeLists.txt
+++ b/indra/llrender/CMakeLists.txt
@@ -102,3 +102,4 @@ target_link_libraries(llrender
OpenGL::GLU
)
+include(LibraryInstall)
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 4c7c8e6f5c..622e73228b 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -72,7 +72,7 @@ static const std::string HEADLESS_VERSION_STRING("1.0");
llofstream gFailLog;
-#if GL_ARB_debug_output
+#if GL_ARB_debug_output || GL_KHR_debug
#ifndef APIENTRY
#define APIENTRY
@@ -222,6 +222,8 @@ PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = nullptr;
#endif
+/*
+
// GL_VERSION_1_2
//PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements = nullptr;
//PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr;
@@ -966,6 +968,7 @@ PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC glMultiDrawArraysIndirectCount = nullpt
PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC glMultiDrawElementsIndirectCount = nullptr;
PFNGLPOLYGONOFFSETCLAMPPROC glPolygonOffsetClamp = nullptr;
+*/
#endif
LLGLManager gGLManager;
@@ -1119,6 +1122,7 @@ bool LLGLManager::initGL()
#endif
}
+#if GL_VERSION_1_3
if (mGLVersion >= 2.1f && LLImageGL::sCompressTextures)
{ //use texture compression
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
@@ -1127,6 +1131,7 @@ bool LLGLManager::initGL()
{ //GL version is < 3.0, always disable texture compression
LLImageGL::sCompressTextures = false;
}
+#endif
// Trailing space necessary to keep "nVidia Corpor_ati_on" cards
// from being recognized as ATI.
@@ -1143,7 +1148,7 @@ bool LLGLManager::initGL()
mIsNVIDIA = TRUE;
}
else if (mGLVendor.find("INTEL") != std::string::npos
-#if LL_LINUX
+#if LL_LINUX || LL_FREEBSD
// The Mesa-based drivers put this in the Renderer string,
// not the Vendor string.
|| mGLRenderer.find("INTEL") != std::string::npos
@@ -1399,6 +1404,7 @@ void LLGLManager::initExtensions()
mInited = TRUE;
+/*
#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
LL_DEBUGS("RenderInit") << "GL Probe: Getting symbols" << LL_ENDL;
@@ -2239,6 +2245,7 @@ void LLGLManager::initExtensions()
glPolygonOffsetClamp = (PFNGLPOLYGONOFFSETCLAMPPROC)GLH_EXT_GET_PROC_ADDRESS("glPolygonOffsetClamp");
#endif
+*/
}
void rotate_quat(LLQuaternion& rotation)
@@ -2265,12 +2272,14 @@ void log_glerror()
error = glGetError();
while (LL_UNLIKELY(error))
{
+#if GLU_VERSION_1_1
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
LL_WARNS() << "GL Error: " << error << " GL Error String: " << gl_error_msg << LL_ENDL ;
}
else
+#endif // GLU_VERSION_1_1
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
@@ -2289,6 +2298,7 @@ void do_assert_glerror()
if (LL_UNLIKELY(error))
{
quit = TRUE;
+#if GLU_VERSION_1_1
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
@@ -2301,6 +2311,7 @@ void do_assert_glerror()
}
}
else
+#endif // GLU_VERSION_1_1
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
@@ -2375,8 +2386,13 @@ void LLGLState::initClass()
// sStateMap[GL_TEXTURE_2D] = GL_TRUE;
//make sure multisample defaults to disabled
+#if GL_EXT_multisample || GL_EXT_multisampled_compatibility
+ sStateMap[GL_MULTISAMPLE_EXT] = GL_FALSE;
+ glDisable(GL_MULTISAMPLE_EXT);
+#else
sStateMap[GL_MULTISAMPLE] = GL_FALSE;
glDisable(GL_MULTISAMPLE);
+#endif
}
//static
@@ -2391,6 +2407,7 @@ void LLGLState::restoreGL()
void LLGLState::resetTextureStates()
{
gGL.flush();
+#if GL_VERSION_1_3
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits);
@@ -2400,6 +2417,7 @@ void LLGLState::resetTextureStates()
glClientActiveTexture(GL_TEXTURE0+j);
j == 0 ? gGL.getTexUnit(j)->enable(LLTexUnit::TT_TEXTURE) : gGL.getTexUnit(j)->disable();
}
+#endif
}
void LLGLState::dumpStates()
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index b80680a3d2..915a7de50d 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -825,8 +825,12 @@ extern PFNGLPOLYGONOFFSETCLAMPPROC glPolygonOffsetClamp;
#define GL_GLEXT_PROTOTYPES
#include "GL/glext.h"
+#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
+#include <OpenGL/gl3.h>
+
#include "GL/glh_extensions.h"
+/*
// These symbols don't exist on 10.3.9, so they have to be declared weak. Redeclaring them here fixes the problem.
// Note that they also must not be called on 10.3.9. This should be taken care of by a runtime check for the existence of the GL extension.
#include <AvailabilityMacros.h>
@@ -941,7 +945,7 @@ extern "C" {
#ifndef GL_ARB_vertex_buffer_object
-/* GL types for handling large vertex buffer objects */
+// GL types for handling large vertex buffer objects
typedef intptr_t GLintptr;
typedef intptr_t GLsizeiptr;
#endif
@@ -957,7 +961,7 @@ typedef GLboolean (* glIsBufferARBProcPtr) (GLuint buffer);
typedef void (* glBufferDataARBProcPtr) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
typedef void (* glBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
typedef void (* glGetBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
-typedef GLvoid* (* glMapBufferARBProcPtr) (GLenum target, GLenum access); /* Flawfinder: ignore */
+typedef GLvoid* (* glMapBufferARBProcPtr) (GLenum target, GLenum access); // Flawfinder: ignore
typedef GLboolean (* glUnmapBufferARBProcPtr) (GLenum target);
typedef void (* glGetBufferParameterivARBProcPtr) (GLenum target, GLenum pname, GLint *params);
typedef void (* glGetBufferPointervARBProcPtr) (GLenum target, GLenum pname, GLvoid* *params);
@@ -973,7 +977,7 @@ extern GLvoid* glMapBufferARB (GLenum, GLenum);
extern GLboolean glUnmapBufferARB (GLenum);
extern void glGetBufferParameterivARB (GLenum, GLenum, GLint *);
extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
-#endif /* GL_GLEXT_FUNCTION_POINTERS */
+#endif // GL_GLEXT_FUNCTION_POINTERS
#endif
#ifndef GL_ARB_texture_rg
@@ -1020,7 +1024,7 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
// extern void glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
// extern void glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*);
// extern void glGetCompressedTexImage (GLenum, GLint, GLvoid*);
-// #endif /* GL_GLEXT_FUNCTION_POINTERS */
+// #endif // GL_GLEXT_FUNCTION_POINTERS
// #endif
#ifdef __cplusplus
@@ -1028,6 +1032,7 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
#endif
#include <OpenGL/gl.h>
+*/
#endif // LL_MESA / LL_WINDOWS / LL_DARWIN
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index ccfb8f69be..28f248367f 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -693,10 +693,14 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString>* u
case GL_FLOAT_VEC2: size *= 2; break;
case GL_FLOAT_VEC3: size *= 3; break;
case GL_FLOAT_VEC4: size *= 4; break;
+#if GL_VERSION_1_1
case GL_DOUBLE: size *= 2; break;
+#if GL_VERSION_4_0
case GL_DOUBLE_VEC2: size *= 2; break;
case GL_DOUBLE_VEC3: size *= 6; break;
case GL_DOUBLE_VEC4: size *= 8; break;
+#endif // GL_VERSION_4_0
+#endif // GL_VERSION_1_1
case GL_INT_VEC2: size *= 2; break;
case GL_INT_VEC3: size *= 3; break;
case GL_INT_VEC4: size *= 4; break;
@@ -715,6 +719,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString>* u
case GL_FLOAT_MAT3x4: size *= 12; break;
case GL_FLOAT_MAT4x2: size *= 8; break;
case GL_FLOAT_MAT4x3: size *= 12; break;
+#if GL_VERSION_4_0
case GL_DOUBLE_MAT2: size *= 8; break;
case GL_DOUBLE_MAT3: size *= 18; break;
case GL_DOUBLE_MAT4: size *= 32; break;
@@ -724,6 +729,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString>* u
case GL_DOUBLE_MAT3x4: size *= 24; break;
case GL_DOUBLE_MAT4x2: size *= 16; break;
case GL_DOUBLE_MAT4x3: size *= 24; break;
+#endif // GL_VERSION_4_0
}
mTotalUniformSize += size;
}
@@ -798,7 +804,10 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
- if ((type >= GL_SAMPLER_1D && type <= GL_SAMPLER_2D_RECT_SHADOW) ||
+ if (
+#if GL_VERSION_2_0
+ (type >= GL_SAMPLER_1D && type <= GL_SAMPLER_2D_RECT_SHADOW) ||
+#endif
type == GL_SAMPLER_2D_MULTISAMPLE ||
type == GL_SAMPLER_CUBE_MAP_ARRAY)
{ //this here is a texture
diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h
index 930c5e3ed7..bef8556348 100644
--- a/indra/llrender/llglstates.h
+++ b/indra/llrender/llglstates.h
@@ -166,6 +166,7 @@ public:
//----------------------------------------------------------------------------
+#if GL_VERSION_1_1
class LLGLSSpecular
{
public:
@@ -190,6 +191,7 @@ public:
}
}
};
+#endif
//----------------------------------------------------------------------------
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index b77f98d65e..11facef9c5 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -271,23 +271,31 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
{
switch (dataformat)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 4;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 8;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 8;
+#endif
+#if GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 4;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 8;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 8;
+#endif
case GL_LUMINANCE: return 8;
case GL_ALPHA: return 8;
case GL_RED: return 8;
+#if GL_VERSION_1_1
case GL_COLOR_INDEX: return 8;
+#endif
case GL_LUMINANCE_ALPHA: return 16;
case GL_RGB: return 24;
case GL_SRGB: return 24;
case GL_RGB8: return 24;
case GL_RGBA: return 32;
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA: return 32;
case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac
+#endif
case GL_DEPTH_COMPONENT: return 24;
default:
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
@@ -300,6 +308,8 @@ S32 LLImageGL::dataFormatBytes(S32 dataformat, S32 width, S32 height)
{
switch (dataformat)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1 \
+ || GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
@@ -309,6 +319,7 @@ S32 LLImageGL::dataFormatBytes(S32 dataformat, S32 width, S32 height)
if (width < 4) width = 4;
if (height < 4) height = 4;
break;
+#endif
default:
break;
}
@@ -322,22 +333,30 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
{
switch (dataformat)
{
+#if GL_EXT_texture_compression_s3tc || GL_EXT_texture_compression_dxt1
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return 3;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 3;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return 4;
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 4;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return 4;
+#endif
+#if GL_EXT_texture_sRGB || GL_EXT_texture_compression_s3tc_srgb
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return 3;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return 4;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return 4;
+#endif
case GL_LUMINANCE: return 1;
case GL_ALPHA: return 1;
case GL_RED: return 1;
+#if GL_VERSION_1_1
case GL_COLOR_INDEX: return 1;
+#endif
case GL_LUMINANCE_ALPHA: return 2;
case GL_RGB: return 3;
case GL_SRGB: return 3;
case GL_RGBA: return 4;
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA: return 4;
case GL_BGRA: return 4; // Used for QuickTime media textures on the Mac
+#endif
default:
LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL;
return 0;
@@ -791,11 +810,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
}
else
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in, mAllowCompression);
if (gl_level == 0)
@@ -804,11 +825,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
}
updatePickMask(w, h, data_in);
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
stop_glerror();
}
@@ -821,11 +844,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
{
stop_glerror();
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
S32 w = getWidth(mCurrentDiscardLevel);
S32 h = getHeight(mCurrentDiscardLevel);
@@ -835,10 +860,12 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
//use legacy mipmap generation mode (note: making this condional can cause rendering issues)
// -- but making it not conditional triggers deprecation warnings when core profile is enabled
// (some rendering issues while core profile is enabled are acceptable at this point in time)
+#if GL_VERSION_1_4
if (!LLRender::sGLCoreProfile)
{
glTexParameteri(mTarget, GL_GENERATE_MIPMAP, GL_TRUE);
}
+#endif
LLImageGL::setManualImage(mTarget, 0, mFormatInternal,
w, h,
@@ -849,11 +876,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
updatePickMask(w, h, data_in);
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
if (LLRender::sGLCoreProfile)
{
@@ -938,11 +967,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
llassert(w > 0 && h > 0 && cur_mip_data);
(void)cur_mip_data;
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data, mAllowCompression);
if (m == 0)
@@ -955,11 +986,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
updatePickMask(w, h, cur_mip_data);
}
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
}
if (prev_mip_data && prev_mip_data != data_in)
{
@@ -994,11 +1027,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
}
else
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h,
mFormatPrimary, mFormatType, (GLvoid *)data_in, mAllowCompression);
@@ -1008,11 +1043,13 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
}
}
@@ -1057,13 +1094,17 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image)
{
case 1:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8;
+#endif
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8_ALPHA8;
+#endif
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
@@ -1091,22 +1132,26 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image)
glPixelStorei(GL_UNPACK_ROW_LENGTH, raw_image->getWidth());
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
return TRUE ;
}
void LLImageGL::postAddToAtlas()
{
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
gGL.getTexUnit(0)->setTextureFilteringOption(mFilterOption);
@@ -1235,11 +1280,13 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
glPixelStorei(GL_UNPACK_ROW_LENGTH, data_width);
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
stop_glerror();
}
+#endif
const U8* sub_datap = datap + (y_pos * data_width + x_pos) * getComponents();
// Update the GL texture
@@ -1263,11 +1310,13 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
gGL.getTexUnit(0)->disable();
stop_glerror();
+#if GL_VERSION_1_1
if(mFormatSwapBytes)
{
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
stop_glerror();
}
+#endif
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
stop_glerror();
@@ -1432,35 +1481,57 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
{
case GL_RGB:
case GL_RGB8:
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_RGB;
+#endif
break;
case GL_SRGB:
case GL_SRGB8:
+#if GL_VERSION_2_1
intformat = GL_COMPRESSED_SRGB;
+#endif
break;
case GL_RGBA:
case GL_RGBA8:
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_RGBA;
+#endif
break;
- case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
+#if GL_VERSION_2_1
+ case GL_SRGB_ALPHA:
intformat = GL_COMPRESSED_SRGB_ALPHA;
+#endif
break;
case GL_LUMINANCE:
+#if GL_VERSION_1_1
case GL_LUMINANCE8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_LUMINANCE;
+#endif
break;
case GL_LUMINANCE_ALPHA:
+#if GL_VERSION_1_1
case GL_LUMINANCE8_ALPHA8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_LUMINANCE_ALPHA;
+#endif
break;
case GL_ALPHA:
+#if GL_VERSION_1_1
case GL_ALPHA8:
+#endif
+#if GL_VERSION_1_3
intformat = GL_COMPRESSED_ALPHA;
+#endif
break;
case GL_RED:
case GL_R8:
+#if GL_VERSION_3_0
intformat = GL_COMPRESSED_RED;
+#endif
break;
default:
LL_WARNS() << "Could not compress format: " << std::hex << intformat << LL_ENDL;
@@ -1599,13 +1670,21 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
{
case 1:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8;
+#else
+ mFormatInternal = GL_LUMINANCE;
+#endif
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
+#if GL_VERSION_1_1
mFormatInternal = GL_LUMINANCE8_ALPHA8;
+#else
+ mFormatInternal = GL_LUMINANCE_ALPHA;
+#endif
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
@@ -1887,6 +1966,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
}
//-----------------------------------------------------------------------------------------------
+#if GL_VERSION_1_3
if (is_compressed)
{
LLGLint glbytes;
@@ -1913,6 +1993,7 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre
glGetTexImage(GL_TEXTURE_2D, gl_discard, mFormatPrimary, mFormatType, (GLvoid*)(imageraw->getData()));
//stop_glerror();
}
+#endif // GL_VERSION_1_3
//-----------------------------------------------------------------------------------------------
if((error = glGetError()) != GL_NO_ERROR)
@@ -2001,11 +2082,13 @@ BOOL LLImageGL::getIsResident(BOOL test_now)
{
if (test_now)
{
+#if GL_VERSION_1_1
if (mTexName != 0)
{
glAreTexturesResident(1, (GLuint*)&mTexName, &mIsResident);
}
else
+#endif
{
mIsResident = FALSE;
}
@@ -2135,12 +2218,16 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
mIsMask = FALSE;
return; //no alpha channel.
case GL_RGBA:
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA:
+#endif
mAlphaStride = 4;
break;
+#if GL_EXT_bgra
case GL_BGRA_EXT:
mAlphaStride = 4;
break;
+#endif
default:
break;
}
@@ -2150,6 +2237,7 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
{
mAlphaOffset = mAlphaStride - 1 ;
}
+#if GL_VERSION_1_2
else if(is_little_endian())
{
if (mFormatType == GL_UNSIGNED_INT_8_8_8_8)
@@ -2172,10 +2260,15 @@ void LLImageGL::calcAlphaChannelOffsetAndStride()
mAlphaOffset = 0 ;
}
}
+#endif // GL_VERSION_1_2
if( mAlphaStride < 1 || //unsupported format
- mAlphaOffset < 0 || //unsupported type
- (mFormatPrimary == GL_BGRA_EXT && mFormatType != GL_UNSIGNED_BYTE)) //unknown situation
+ mAlphaOffset < 0 //unsupported type
+#if GL_EXT_bgra
+ ||
+ (mFormatPrimary == GL_BGRA_EXT && mFormatType != GL_UNSIGNED_BYTE) //unknown situation
+#endif
+ )
{
LL_WARNS() << "Cannot analyze alpha for image with format type " << std::hex << mFormatType << std::dec << LL_ENDL;
@@ -2347,7 +2440,10 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
if (mFormatType != GL_UNSIGNED_BYTE ||
((mFormatPrimary != GL_RGBA)
- && (mFormatPrimary != GL_SRGB_ALPHA)))
+#if GL_VERSION_2_1
+ && (mFormatPrimary != GL_SRGB_ALPHA)
+#endif
+ ))
{
//cannot generate a pick mask for this texture
return;
diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp
index 0f8655132b..aea82e9414 100644
--- a/indra/llrender/llpostprocess.cpp
+++ b/indra/llrender/llpostprocess.cpp
@@ -296,8 +296,10 @@ void LLPostProcess::getShaderUniforms(glslUniforms & uniforms, GLuint & prog)
void LLPostProcess::doEffects(void)
{
/// Save GL State
+#if GL_VERSION_1_1
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushClientAttrib(GL_ALL_ATTRIB_BITS);
+#endif
/// Copy the screen buffer to the render texture
{
@@ -322,15 +324,19 @@ void LLPostProcess::doEffects(void)
viewPerspective();
/// Reset GL State
+#if GL_VERSION_1_1
glPopClientAttrib();
glPopAttrib();
+#endif
checkError();
}
void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height)
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture);
+#if GL_VERSION_3_1
glCopyTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 0, 0, width, height, 0);
+#endif
}
void LLPostProcess::drawOrthoQuad(unsigned int width, unsigned int height, QuadType type)
@@ -371,7 +377,9 @@ void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int wi
if(texture->createGLTexture())
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName());
+#if GL_VERSION_3_1
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, 4, width, height, 0,
+#endif
GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
@@ -406,18 +414,22 @@ bool LLPostProcess::checkError(void)
while (glErr != GL_NO_ERROR)
{
// shaderErrorLog << (const char *) gluErrorString(glErr) << std::endl;
+#if GLU_VERSION_1_1
char const * err_str_raw = (const char *) gluErrorString(glErr);
if(err_str_raw == NULL)
{
+#endif
std::ostringstream err_builder;
err_builder << "unknown error number " << glErr;
mShaderErrorString = err_builder.str();
+#if GLU_VERSION_1_1
}
else
{
mShaderErrorString = err_str_raw;
}
+#endif
retCode = true;
glErr = glGetError();
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 8430d13093..f67d17cf6c 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -81,10 +81,14 @@ static std::unordered_map<U64, LLVBCache> sVBCache;
static const GLenum sGLTextureType[] =
{
GL_TEXTURE_2D,
+#if GL_VERSION_3_1
GL_TEXTURE_RECTANGLE,
+#endif
GL_TEXTURE_CUBE_MAP,
GL_TEXTURE_CUBE_MAP_ARRAY,
+#if GL_VERSION_3_2
GL_TEXTURE_2D_MULTISAMPLE,
+#endif
GL_TEXTURE_3D
};
@@ -518,6 +522,7 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
}
}
+#if GL_EXT_texture_filter_anisotropic
if (gGLManager.mGLVersion >= 4.59f)
{
if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC)
@@ -529,10 +534,12 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f);
}
}
+#endif
}
GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
{
+#if GL_VERSION_1_3
switch(src)
{
// All four cases should return the same value.
@@ -547,8 +554,10 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
case TBS_TEX_ALPHA:
case TBS_ONE_MINUS_TEX_COLOR:
case TBS_ONE_MINUS_TEX_ALPHA:
+#endif
return GL_TEXTURE;
+#if GL_VERSION_1_3
// All four cases should return the same value.
case TBS_VERT_COLOR:
case TBS_VERT_ALPHA:
@@ -567,6 +576,7 @@ GLint LLTexUnit::getTextureSource(eTextureBlendSrc src)
LL_WARNS() << "Unknown eTextureBlendSrc: " << src << ". Using Vertex Color instead." << LL_ENDL;
return GL_PRIMARY_COLOR;
}
+#endif
}
GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
@@ -613,7 +623,9 @@ void LLTexUnit::setColorScale(S32 scale)
{
mCurrColorScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale );
+#endif
}
}
@@ -623,7 +635,9 @@ void LLTexUnit::setAlphaScale(S32 scale)
{
mCurrAlphaScale = scale;
gGL.flush();
+#if GL_VERSION_1_1
glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale );
+#endif
}
}
@@ -2060,10 +2074,12 @@ void LLRender::diffuseColor3f(F32 r, F32 g, F32 b)
{
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r,g,b,1.f);
}
+#if GL_VERSION_1_1
else
{
glColor3f(r,g,b);
}
+#endif
}
void LLRender::diffuseColor3fv(const F32* c)
@@ -2075,10 +2091,12 @@ void LLRender::diffuseColor3fv(const F32* c)
{
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, c[0], c[1], c[2], 1.f);
}
+#if GL_VERSION_1_1
else
{
glColor3fv(c);
}
+#endif
}
void LLRender::diffuseColor4f(F32 r, F32 g, F32 b, F32 a)
@@ -2090,10 +2108,12 @@ void LLRender::diffuseColor4f(F32 r, F32 g, F32 b, F32 a)
{
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r,g,b,a);
}
+#if GL_VERSION_1_1
else
{
glColor4f(r,g,b,a);
}
+#endif
}
void LLRender::diffuseColor4fv(const F32* c)
@@ -2105,10 +2125,12 @@ void LLRender::diffuseColor4fv(const F32* c)
{
shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, c);
}
+#if GL_VERSION_1_1
else
{
glColor4fv(c);
}
+#endif
}
void LLRender::diffuseColor4ubv(const U8* c)
@@ -2120,10 +2142,12 @@ void LLRender::diffuseColor4ubv(const U8* c)
{
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, c[0]/255.f, c[1]/255.f, c[2]/255.f, c[3]/255.f);
}
+#if GL_VERSION_1_1
else
{
glColor4ubv(c);
}
+#endif
}
void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a)
@@ -2135,10 +2159,12 @@ void LLRender::diffuseColor4ub(U8 r, U8 g, U8 b, U8 a)
{
shader->uniform4f(LLShaderMgr::DIFFUSE_COLOR, r/255.f, g/255.f, b/255.f, a/255.f);
}
+#if GL_VERSION_1_1
else
{
glColor4ub(r,g,b,a);
}
+#endif
}
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 88c48e5166..6144342c86 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -498,7 +498,9 @@ void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilt
{
case GL_SRGB:
case GL_SRGB8:
+#if GL_VERSION_2_1
case GL_SRGB_ALPHA:
+#endif
case GL_SRGB8_ALPHA8:
isSRGB = true;
break;