Corrected OpenGL extension detection
- corrected multitexture and VBO detection - GLEW is now a required library - minor CMakeLists refactoringdev-ui
parent
d1942e1216
commit
8818a8e5db
|
@ -20,14 +20,14 @@ set(COLOBOT_VERSION_UNRELEASED "~pre-alpha")
|
||||||
|
|
||||||
# Append git characteristics to version
|
# Append git characteristics to version
|
||||||
if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||||
OUTPUT_VARIABLE GIT_BRANCH
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||||
OUTPUT_VARIABLE GIT_REVISION
|
OUTPUT_VARIABLE GIT_REVISION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
|
set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}")
|
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}")
|
||||||
|
@ -67,6 +67,7 @@ option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
||||||
# Build openal sound support
|
# Build openal sound support
|
||||||
option(OPENAL_SOUND "Build openal sound support" OFF)
|
option(OPENAL_SOUND "Build openal sound support" OFF)
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Required packages
|
# Required packages
|
||||||
##
|
##
|
||||||
|
@ -85,17 +86,11 @@ set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
|
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
|
||||||
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
|
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
|
||||||
|
|
||||||
# GLEW requirement depends on platform
|
|
||||||
# By default it is auto detected
|
|
||||||
# This setting may be used to override
|
|
||||||
# Possible values:
|
|
||||||
# - auto -> determine automatically
|
|
||||||
# - 1 -> always enable
|
|
||||||
# - 0 -> always disable
|
|
||||||
set(USE_GLEW auto)
|
|
||||||
# This is useful on Windows, if linking against standard GLEW dll fails
|
# This is useful on Windows, if linking against standard GLEW dll fails
|
||||||
option(GLEW_STATIC "Link statically with GLEW" OFF)
|
option(GLEW_STATIC "Link statically with GLEW" OFF)
|
||||||
|
|
||||||
|
find_package(GLEW REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Additional settings to use when cross-compiling with MXE (http://mxe.cc/)
|
# Additional settings to use when cross-compiling with MXE (http://mxe.cc/)
|
||||||
|
@ -113,38 +108,19 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
set(PLATFORM_WINDOWS 1)
|
set(PLATFORM_WINDOWS 1)
|
||||||
set(PLATFORM_LINUX 0)
|
set(PLATFORM_LINUX 0)
|
||||||
set(PLATFORM_OTHER 0)
|
set(PLATFORM_OTHER 0)
|
||||||
|
|
||||||
# On Windows, GLEW is required
|
|
||||||
if (${USE_GLEW} MATCHES "auto")
|
|
||||||
set(USE_GLEW 1)
|
|
||||||
endif()
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
message(STATUS "Linux system detected")
|
message(STATUS "Linux system detected")
|
||||||
set(PLATFORM_WINDOWS 0)
|
set(PLATFORM_WINDOWS 0)
|
||||||
set(PLATFORM_LINUX 1)
|
set(PLATFORM_LINUX 1)
|
||||||
set(PLATFORM_OTHER 0)
|
set(PLATFORM_OTHER 0)
|
||||||
|
|
||||||
# On Linux, we should be fine without GLEW
|
|
||||||
if (${USE_GLEW} MATCHES "auto")
|
|
||||||
set(USE_GLEW 0)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Other system detected")
|
message(STATUS "Other system detected")
|
||||||
set(PLATFORM_WINDOWS 0)
|
set(PLATFORM_WINDOWS 0)
|
||||||
set(PLATFORM_LINUX 0)
|
set(PLATFORM_LINUX 0)
|
||||||
set(PLATFORM_OTHER 1)
|
set(PLATFORM_OTHER 1)
|
||||||
|
|
||||||
# Use GLEW to be safe
|
|
||||||
if (${USE_GLEW} MATCHES "auto")
|
|
||||||
set(USE_GLEW 1)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(${USE_GLEW})
|
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${ASSERTS})
|
if(NOT ${ASSERTS})
|
||||||
add_definitions(-DNDEBUG)
|
add_definitions(-DNDEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -19,32 +19,24 @@ endif()
|
||||||
|
|
||||||
# Optional libraries
|
# Optional libraries
|
||||||
set(OPTIONAL_LIBS "")
|
set(OPTIONAL_LIBS "")
|
||||||
set(OPTIONAL_INCLUDE_DIRS "")
|
|
||||||
|
|
||||||
if(${USE_GLEW} AND NOT ${MXE})
|
|
||||||
set(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${GLEW_LIBRARY})
|
|
||||||
set(OPTIONAL_INCLUDE_DIRS ${OPTIONAL_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# Additional libraries per platform
|
|
||||||
set(PLATFORM_LIBS "")
|
|
||||||
set(OPENAL_LIBS "")
|
|
||||||
|
|
||||||
if (${OPENAL_SOUND})
|
if (${OPENAL_SOUND})
|
||||||
if (${MXE})
|
if (${MXE})
|
||||||
set(OPENAL_LIBS
|
set(OPTIONAL_LIBS
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
set(OPENAL_LIBS
|
set(OPTIONAL_LIBS
|
||||||
openal
|
openal
|
||||||
alut
|
alut
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Additional libraries per platform
|
||||||
|
set(PLATFORM_LIBS "")
|
||||||
|
|
||||||
if (${MXE}) # MXE requires special treatment
|
if (${MXE}) # MXE requires special treatment
|
||||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||||
elseif (${PLATFORM_WINDOWS})
|
elseif (${PLATFORM_WINDOWS})
|
||||||
|
@ -63,9 +55,9 @@ set(OPENAL_SRC "")
|
||||||
|
|
||||||
if (${OPENAL_SOUND})
|
if (${OPENAL_SOUND})
|
||||||
set(OPENAL_SRC
|
set(OPENAL_SRC
|
||||||
sound/oalsound/alsound.cpp
|
sound/oalsound/alsound.cpp
|
||||||
sound/oalsound/buffer.cpp
|
sound/oalsound/buffer.cpp
|
||||||
sound/oalsound/channel.cpp
|
sound/oalsound/channel.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -192,16 +184,16 @@ ${OPENAL_SRC}
|
||||||
|
|
||||||
|
|
||||||
set(LIBS
|
set(LIBS
|
||||||
|
CBot
|
||||||
${SDL_LIBRARY}
|
${SDL_LIBRARY}
|
||||||
${SDLIMAGE_LIBRARY}
|
${SDLIMAGE_LIBRARY}
|
||||||
${SDLTTF_LIBRARY}
|
${SDLTTF_LIBRARY}
|
||||||
${OPENGL_LIBRARY}
|
${OPENGL_LIBRARY}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
|
${GLEW_LIBRARY}
|
||||||
|
${Boost_LIBRARIES}
|
||||||
${OPTIONAL_LIBS}
|
${OPTIONAL_LIBS}
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
${Boost_LIBRARIES}
|
|
||||||
CBot
|
|
||||||
${OPENAL_LIBS}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -212,8 +204,9 @@ ${SDL_INCLUDE_DIR}
|
||||||
${SDLIMAGE_INCLUDE_DIR}
|
${SDLIMAGE_INCLUDE_DIR}
|
||||||
${SDLTTF_INCLUDE_DIR}
|
${SDLTTF_INCLUDE_DIR}
|
||||||
${PNG_INCLUDE_DIRS}
|
${PNG_INCLUDE_DIRS}
|
||||||
${OPTIONAL_INCLUDE_DIRS}
|
${GLEW_INCLUDE_PATH}
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
|
${OPTIONAL_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
|
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
|
||||||
|
|
|
@ -264,7 +264,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
|
||||||
GetLogger()->Message("\n");
|
GetLogger()->Message("\n");
|
||||||
GetLogger()->Message("List of available options:\n");
|
GetLogger()->Message("List of available options:\n");
|
||||||
GetLogger()->Message(" -help this help\n");
|
GetLogger()->Message(" -help this help\n");
|
||||||
GetLogger()->Message(" -vbo enable OpenGL VBOs\n");
|
|
||||||
GetLogger()->Message(" -datadir path set custom data directory path\n");
|
GetLogger()->Message(" -datadir path set custom data directory path\n");
|
||||||
GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
|
GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
|
||||||
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
|
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
|
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
|
||||||
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
|
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
|
||||||
|
|
||||||
#cmakedefine USE_GLEW @USE_GLEW@
|
|
||||||
#cmakedefine GLEW_STATIC
|
#cmakedefine GLEW_STATIC
|
||||||
|
|
||||||
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
|
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
|
||||||
|
|
|
@ -104,8 +104,7 @@ enum RenderState
|
||||||
RENDER_STATE_DEPTH_TEST,
|
RENDER_STATE_DEPTH_TEST,
|
||||||
RENDER_STATE_DEPTH_WRITE,
|
RENDER_STATE_DEPTH_WRITE,
|
||||||
RENDER_STATE_ALPHA_TEST,
|
RENDER_STATE_ALPHA_TEST,
|
||||||
RENDER_STATE_CULLING,
|
RENDER_STATE_CULLING
|
||||||
RENDER_STATE_DITHERING
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,7 +286,7 @@ public:
|
||||||
virtual void DestroyAllTextures() = 0;
|
virtual void DestroyAllTextures() = 0;
|
||||||
|
|
||||||
//! Returns the maximum number of multitexture stages
|
//! Returns the maximum number of multitexture stages
|
||||||
virtual int GetMaxTextureCount() = 0;
|
virtual int GetMaxTextureStageCount() = 0;
|
||||||
//! Sets the texture at given texture stage
|
//! Sets the texture at given texture stage
|
||||||
virtual void SetTexture(int index, const Texture &texture) = 0;
|
virtual void SetTexture(int index, const Texture &texture) = 0;
|
||||||
//! Sets the texture image by ID at given texture stage
|
//! Sets the texture image by ID at given texture stage
|
||||||
|
|
|
@ -24,22 +24,9 @@
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_GLEW)
|
// Using GLEW so only glew.h is needed
|
||||||
|
|
||||||
// When using GLEW, only glew.h is needed
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Should define prototypes of used extensions as OpenGL functions
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
|
||||||
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <GL/glext.h>
|
|
||||||
|
|
||||||
#endif // if defined(GLEW)
|
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -74,7 +61,8 @@ CGLDevice::CGLDevice(const GLDeviceConfig &config)
|
||||||
m_config = config;
|
m_config = config;
|
||||||
m_lighting = false;
|
m_lighting = false;
|
||||||
m_lastVboId = 0;
|
m_lastVboId = 0;
|
||||||
m_useVbo = false;
|
m_multitextureAvailable = false;
|
||||||
|
m_vboAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +81,6 @@ bool CGLDevice::Create()
|
||||||
{
|
{
|
||||||
GetLogger()->Info("Creating CDevice\n");
|
GetLogger()->Info("Creating CDevice\n");
|
||||||
|
|
||||||
#if defined(USE_GLEW)
|
|
||||||
static bool glewInited = false;
|
static bool glewInited = false;
|
||||||
|
|
||||||
if (!glewInited)
|
if (!glewInited)
|
||||||
|
@ -106,26 +93,16 @@ bool CGLDevice::Create()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (! GLEW_ARB_multitexture) || (! GLEW_EXT_texture_env_combine) )
|
m_multitextureAvailable = glewIsSupported("GL_ARB_multitexture GL_ARB_texture_env_combine");
|
||||||
{
|
if (!m_multitextureAvailable)
|
||||||
GetLogger()->Error("GLEW reports required extensions not supported\n");
|
GetLogger()->Error("GLEW reports multitexturing not supported - graphics quality will be degraded!\n");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GLEW_ARB_vertex_buffer_object)
|
m_vboAvailable = glewIsSupported("GL_ARB_vertex_buffer_object");
|
||||||
{
|
if (m_vboAvailable)
|
||||||
GetLogger()->Info("Detected ARB_vertex_buffer_object extension - using VBOs\n");
|
GetLogger()->Info("Detected ARB_vertex_buffer_object extension - using VBOs\n");
|
||||||
m_useVbo = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
GetLogger()->Info("No ARB_vertex_buffer_object extension present - using display lists\n");
|
GetLogger()->Info("No ARB_vertex_buffer_object extension present - using display lists\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* NOTE: when not using GLEW, extension testing is not performed, as it is assumed that
|
|
||||||
glext.h is up-to-date and the OpenGL shared library has the required functions present. */
|
|
||||||
|
|
||||||
// This is mostly done in all modern hardware by default
|
// This is mostly done in all modern hardware by default
|
||||||
// DirectX doesn't even allow the option to turn off perspective correction anymore
|
// DirectX doesn't even allow the option to turn off perspective correction anymore
|
||||||
|
@ -135,6 +112,9 @@ bool CGLDevice::Create()
|
||||||
// To avoid problems with scaling & lighting
|
// To avoid problems with scaling & lighting
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
glEnable(GL_RESCALE_NORMAL);
|
||||||
|
|
||||||
|
// Minimal depth bias to avoid Z-fighting
|
||||||
|
SetDepthBias(0.001f);
|
||||||
|
|
||||||
// Set just to be sure
|
// Set just to be sure
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
@ -186,14 +166,14 @@ void CGLDevice::ConfigChanged(const GLDeviceConfig& newConfig)
|
||||||
Create();
|
Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::SetUseVbo(bool useVbo)
|
void CGLDevice::SetUseVbo(bool vboAvailable)
|
||||||
{
|
{
|
||||||
m_useVbo = useVbo;
|
m_vboAvailable = vboAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGLDevice::GetUseVbo()
|
bool CGLDevice::GetUseVbo()
|
||||||
{
|
{
|
||||||
return m_useVbo;
|
return m_vboAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::BeginScene()
|
void CGLDevice::BeginScene()
|
||||||
|
@ -610,7 +590,7 @@ void CGLDevice::DestroyAllTextures()
|
||||||
m_allTextures.clear();
|
m_allTextures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGLDevice::GetMaxTextureCount()
|
int CGLDevice::GetMaxTextureStageCount()
|
||||||
{
|
{
|
||||||
return m_currentTextures.size();
|
return m_currentTextures.size();
|
||||||
}
|
}
|
||||||
|
@ -621,17 +601,21 @@ int CGLDevice::GetMaxTextureCount()
|
||||||
The setting is remembered, even if texturing is disabled at the moment. */
|
The setting is remembered, even if texturing is disabled at the moment. */
|
||||||
void CGLDevice::SetTexture(int index, const Texture &texture)
|
void CGLDevice::SetTexture(int index, const Texture &texture)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
bool same = m_currentTextures[index].id == texture.id;
|
bool same = m_currentTextures[index].id == texture.id;
|
||||||
|
|
||||||
m_currentTextures[index] = texture; // remember the new value
|
m_currentTextures[index] = texture; // remember the new value
|
||||||
|
|
||||||
|
if (!m_multitextureAvailable && index != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (same)
|
if (same)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + index);
|
if (m_multitextureAvailable)
|
||||||
|
glActiveTexture(GL_TEXTURE0 + index);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture.id);
|
glBindTexture(GL_TEXTURE_2D, texture.id);
|
||||||
|
|
||||||
// Params need to be updated for the new bound texture
|
// Params need to be updated for the new bound texture
|
||||||
|
@ -640,15 +624,19 @@ void CGLDevice::SetTexture(int index, const Texture &texture)
|
||||||
|
|
||||||
void CGLDevice::SetTexture(int index, unsigned int textureId)
|
void CGLDevice::SetTexture(int index, unsigned int textureId)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
if (m_currentTextures[index].id == textureId)
|
if (m_currentTextures[index].id == textureId)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
m_currentTextures[index].id = textureId;
|
m_currentTextures[index].id = textureId;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + index);
|
if (!m_multitextureAvailable && index != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_multitextureAvailable)
|
||||||
|
glActiveTexture(GL_TEXTURE0 + index);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||||
|
|
||||||
// Params need to be updated for the new bound texture
|
// Params need to be updated for the new bound texture
|
||||||
|
@ -659,16 +647,14 @@ void CGLDevice::SetTexture(int index, unsigned int textureId)
|
||||||
Returns the previously assigned texture or invalid texture if the given stage is not enabled. */
|
Returns the previously assigned texture or invalid texture if the given stage is not enabled. */
|
||||||
Texture CGLDevice::GetTexture(int index)
|
Texture CGLDevice::GetTexture(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
return m_currentTextures[index];
|
return m_currentTextures[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::SetTextureEnabled(int index, bool enabled)
|
void CGLDevice::SetTextureEnabled(int index, bool enabled)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
bool same = m_texturesEnabled[index] == enabled;
|
bool same = m_texturesEnabled[index] == enabled;
|
||||||
|
|
||||||
|
@ -677,7 +663,12 @@ void CGLDevice::SetTextureEnabled(int index, bool enabled)
|
||||||
if (same)
|
if (same)
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + index);
|
if (!m_multitextureAvailable && index != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_multitextureAvailable)
|
||||||
|
glActiveTexture(GL_TEXTURE0 + index);
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
else
|
else
|
||||||
|
@ -686,8 +677,7 @@ void CGLDevice::SetTextureEnabled(int index, bool enabled)
|
||||||
|
|
||||||
bool CGLDevice::GetTextureEnabled(int index)
|
bool CGLDevice::GetTextureEnabled(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
return m_texturesEnabled[index];
|
return m_texturesEnabled[index];
|
||||||
}
|
}
|
||||||
|
@ -698,17 +688,36 @@ bool CGLDevice::GetTextureEnabled(int index)
|
||||||
The settings are remembered, even if texturing is disabled at the moment. */
|
The settings are remembered, even if texturing is disabled at the moment. */
|
||||||
void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶ms)
|
void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶ms)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
// Remember the settings
|
// Remember the settings
|
||||||
m_textureStageParams[index] = params;
|
m_textureStageParams[index] = params;
|
||||||
|
|
||||||
|
if (!m_multitextureAvailable && index != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// Don't actually do anything if texture not set
|
// Don't actually do anything if texture not set
|
||||||
if (! m_currentTextures[index].Valid())
|
if (! m_currentTextures[index].Valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + index);
|
if (m_multitextureAvailable)
|
||||||
|
glActiveTexture(GL_TEXTURE0 + index);
|
||||||
|
|
||||||
|
if (params.wrapS == TEX_WRAP_CLAMP)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
|
else if (params.wrapS == TEX_WRAP_REPEAT)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
else assert(false);
|
||||||
|
|
||||||
|
if (params.wrapT == TEX_WRAP_CLAMP)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
|
else if (params.wrapT == TEX_WRAP_REPEAT)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
else assert(false);
|
||||||
|
|
||||||
|
// Texture env setting is silly without multitexturing
|
||||||
|
if (!m_multitextureAvailable)
|
||||||
|
return;
|
||||||
|
|
||||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, params.factor.Array());
|
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, params.factor.Array());
|
||||||
|
|
||||||
|
@ -812,26 +821,12 @@ after_tex_color:
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
|
||||||
else assert(false);
|
else assert(false);
|
||||||
|
|
||||||
|
after_tex_operations: ;
|
||||||
after_tex_operations:
|
|
||||||
|
|
||||||
if (params.wrapS == TEX_WRAP_CLAMP)
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
|
||||||
else if (params.wrapS == TEX_WRAP_REPEAT)
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
else assert(false);
|
|
||||||
|
|
||||||
if (params.wrapT == TEX_WRAP_CLAMP)
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
|
||||||
else if (params.wrapT == TEX_WRAP_REPEAT)
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
else assert(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT)
|
void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
// Remember the settings
|
// Remember the settings
|
||||||
m_textureStageParams[index].wrapS = wrapS;
|
m_textureStageParams[index].wrapS = wrapS;
|
||||||
|
@ -841,7 +836,11 @@ void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wr
|
||||||
if (! m_currentTextures[index].Valid())
|
if (! m_currentTextures[index].Valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + index);
|
if (!m_multitextureAvailable && index != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_multitextureAvailable)
|
||||||
|
glActiveTexture(GL_TEXTURE0 + index);
|
||||||
|
|
||||||
if (wrapS == TEX_WRAP_CLAMP)
|
if (wrapS == TEX_WRAP_CLAMP)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
|
@ -858,8 +857,7 @@ void CGLDevice::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wr
|
||||||
|
|
||||||
TextureStageParams CGLDevice::GetTextureStageParams(int index)
|
TextureStageParams CGLDevice::GetTextureStageParams(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0);
|
assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
|
||||||
assert(index < static_cast<int>( m_currentTextures.size() ));
|
|
||||||
|
|
||||||
return m_textureStageParams[index];
|
return m_textureStageParams[index];
|
||||||
}
|
}
|
||||||
|
@ -890,7 +888,9 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int ve
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||||
|
|
||||||
|
@ -914,13 +914,18 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE1);
|
if (m_multitextureAvailable)
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
{
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
glClientActiveTexture(GL_TEXTURE1);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
||||||
|
}
|
||||||
|
|
||||||
glColor4fv(color.Array());
|
glColor4fv(color.Array());
|
||||||
|
|
||||||
|
@ -929,8 +934,11 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
||||||
|
@ -952,7 +960,7 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int
|
||||||
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
id = ++m_lastVboId;
|
id = ++m_lastVboId;
|
||||||
|
|
||||||
|
@ -986,7 +994,7 @@ unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Ve
|
||||||
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
id = ++m_lastVboId;
|
id = ++m_lastVboId;
|
||||||
|
|
||||||
|
@ -1020,7 +1028,7 @@ unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Ve
|
||||||
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
id = ++m_lastVboId;
|
id = ++m_lastVboId;
|
||||||
|
|
||||||
|
@ -1053,7 +1061,7 @@ unsigned int CGLDevice::CreateStaticBuffer(PrimitiveType primitiveType, const Ve
|
||||||
|
|
||||||
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1080,7 +1088,7 @@ void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiv
|
||||||
|
|
||||||
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1107,7 +1115,7 @@ void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiv
|
||||||
|
|
||||||
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1134,7 +1142,7 @@ void CGLDevice::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiv
|
||||||
|
|
||||||
void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1151,7 +1159,9 @@ void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, normal));
|
glNormalPointer(GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, normal));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, texCoord));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, texCoord));
|
||||||
}
|
}
|
||||||
|
@ -1163,13 +1173,18 @@ void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, normal));
|
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, normal));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord));
|
||||||
|
|
||||||
glClientActiveTexture(GL_TEXTURE1);
|
if (m_multitextureAvailable)
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
{
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord2));
|
glClientActiveTexture(GL_TEXTURE1);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||||
{
|
{
|
||||||
|
@ -1194,8 +1209,11 @@ void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||||
glClientActiveTexture(GL_TEXTURE0);
|
if (m_multitextureAvailable)
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||||
{
|
{
|
||||||
|
@ -1214,7 +1232,7 @@ void CGLDevice::DrawStaticBuffer(unsigned int bufferId)
|
||||||
|
|
||||||
void CGLDevice::DestroyStaticBuffer(unsigned int bufferId)
|
void CGLDevice::DestroyStaticBuffer(unsigned int bufferId)
|
||||||
{
|
{
|
||||||
if (m_useVbo)
|
if (m_vboAvailable)
|
||||||
{
|
{
|
||||||
auto it = m_vboObjects.find(bufferId);
|
auto it = m_vboObjects.find(bufferId);
|
||||||
if (it == m_vboObjects.end())
|
if (it == m_vboObjects.end())
|
||||||
|
@ -1355,7 +1373,6 @@ void CGLDevice::SetRenderState(RenderState state, bool enabled)
|
||||||
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
|
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
|
||||||
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
|
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
|
||||||
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
|
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
|
||||||
case RENDER_STATE_DITHERING: flag = GL_DITHER; break;
|
|
||||||
default: assert(false); break;
|
default: assert(false); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1397,6 @@ bool CGLDevice::GetRenderState(RenderState state)
|
||||||
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
|
case RENDER_STATE_DEPTH_TEST: flag = GL_DEPTH_TEST; break;
|
||||||
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
|
case RENDER_STATE_ALPHA_TEST: flag = GL_ALPHA_TEST; break;
|
||||||
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
|
case RENDER_STATE_CULLING: flag = GL_CULL_FACE; break;
|
||||||
case RENDER_STATE_DITHERING: flag = GL_DITHER; break;
|
|
||||||
default: assert(false); break;
|
default: assert(false); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public:
|
||||||
virtual void DestroyTexture(const Texture &texture);
|
virtual void DestroyTexture(const Texture &texture);
|
||||||
virtual void DestroyAllTextures();
|
virtual void DestroyAllTextures();
|
||||||
|
|
||||||
virtual int GetMaxTextureCount();
|
virtual int GetMaxTextureStageCount();
|
||||||
virtual void SetTexture(int index, const Texture &texture);
|
virtual void SetTexture(int index, const Texture &texture);
|
||||||
virtual void SetTexture(int index, unsigned int textureId);
|
virtual void SetTexture(int index, unsigned int textureId);
|
||||||
virtual Texture GetTexture(int index);
|
virtual Texture GetTexture(int index);
|
||||||
|
@ -229,8 +229,10 @@ private:
|
||||||
int vertexCount;
|
int vertexCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Whether to use multitexturing
|
||||||
|
bool m_multitextureAvailable;
|
||||||
//! Whether to use VBOs or display lists
|
//! Whether to use VBOs or display lists
|
||||||
bool m_useVbo;
|
bool m_vboAvailable;
|
||||||
//! Map of saved VBO objects
|
//! Map of saved VBO objects
|
||||||
std::map<unsigned int, VboObjectInfo> m_vboObjects;
|
std::map<unsigned int, VboObjectInfo> m_vboObjects;
|
||||||
//! Last ID of VBO object
|
//! Last ID of VBO object
|
||||||
|
|
Loading…
Reference in New Issue