mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +08:00
Now using an explicit prefix for OpenGL extension macros, to avoid conflicts
This commit is contained in:
parent
2c259c8f49
commit
62941c4264
@ -90,7 +90,7 @@ void glCheckError(const char* file, unsigned int line)
|
||||
break;
|
||||
}
|
||||
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION :
|
||||
case GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION :
|
||||
{
|
||||
error = "GL_INVALID_FRAMEBUFFER_OPERATION";
|
||||
description = "the object bound to FRAMEBUFFER_BINDING is not \"framebuffer complete\"";
|
||||
|
@ -34,56 +34,56 @@
|
||||
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GL_blend_func_separate GL_OES_blend_func_separate
|
||||
#define glBlendFuncSeparate glBlendFuncSeparateOES
|
||||
#define GL_framebuffer_object GL_OES_framebuffer_object
|
||||
#define glGenFramebuffers glGenFramebuffersOES
|
||||
#define glGenRenderbuffers glGenRenderbuffersOES
|
||||
#define glBindFramebuffer glBindFramebufferOES
|
||||
#define glBindRenderbuffer glBindRenderbufferOES
|
||||
#define glDeleteFramebuffers glDeleteFramebuffersOES
|
||||
#define glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||
#define glRenderbufferStorage glRenderbufferStorageOES
|
||||
#define glFramebufferRenderbuffer glFramebufferRenderbufferOES
|
||||
#define glFramebufferTexture2D glFramebufferTexture2DOES
|
||||
#define glCheckFramebufferStatus glCheckFramebufferStatusOES
|
||||
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
||||
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES
|
||||
#define GL_RENDERBUFFER GL_RENDERBUFFER_OES
|
||||
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
|
||||
#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||
#define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16_OES
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
|
||||
#define GL_texture_non_power_of_two false
|
||||
#define GLEXT_blend_func_separate GL_OES_blend_func_separate
|
||||
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateOES
|
||||
#define GLEXT_framebuffer_object GL_OES_framebuffer_object
|
||||
#define GLEXT_glGenFramebuffers glGenFramebuffersOES
|
||||
#define GLEXT_glGenRenderbuffers glGenRenderbuffersOES
|
||||
#define GLEXT_glBindFramebuffer glBindFramebufferOES
|
||||
#define GLEXT_glBindRenderbuffer glBindRenderbufferOES
|
||||
#define GLEXT_glDeleteFramebuffers glDeleteFramebuffersOES
|
||||
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||
#define GLEXT_glRenderbufferStorage glRenderbufferStorageOES
|
||||
#define GLEXT_glFramebufferRenderbuffer glFramebufferRenderbufferOES
|
||||
#define GLEXT_glFramebufferTexture2D glFramebufferTexture2DOES
|
||||
#define GLEXT_glCheckFramebufferStatus glCheckFramebufferStatusOES
|
||||
#define GLEXT_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
||||
#define GLEXT_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES
|
||||
#define GLEXT_GL_RENDERBUFFER GL_RENDERBUFFER_OES
|
||||
#define GLEXT_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
|
||||
#define GLEXT_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GLEXT_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||
#define GLEXT_GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16_OES
|
||||
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
|
||||
#define GLEXT_texture_non_power_of_two false
|
||||
|
||||
#else
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GL_blend_func_separate GLEW_EXT_blend_func_separate
|
||||
#define glBlendFuncSeparate glBlendFuncSeparateEXT
|
||||
#define GL_framebuffer_object GLEW_EXT_framebuffer_object
|
||||
#define glGenFramebuffers glGenFramebuffersEXT
|
||||
#define glGenRenderbuffers glGenRenderbuffersEXT
|
||||
#define glBindFramebuffer glBindFramebufferEXT
|
||||
#define glBindRenderbuffer glBindRenderbufferEXT
|
||||
#define glDeleteFramebuffers glDeleteFramebuffersEXT
|
||||
#define glDeleteRenderbuffers glDeleteRenderbuffersEXT
|
||||
#define glRenderbufferStorage glRenderbufferStorageEXT
|
||||
#define glFramebufferRenderbuffer glRenderbufferStorageEXT
|
||||
#define glFramebufferTexture2D glFramebufferTexture2DEXT
|
||||
#define glCheckFramebufferStatus glCheckFramebufferStatusEXT
|
||||
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
|
||||
#define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
||||
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
//#define GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#define GL_texture_non_power_of_two GLEW_ARB_texture_non_power_of_two
|
||||
#define GLEXT_blend_func_separate GLEW_EXT_blend_func_separate
|
||||
#define GLEXT_glBlendFuncSeparate glBlendFuncSeparateEXT
|
||||
#define GLEXT_framebuffer_object GLEW_EXT_framebuffer_object
|
||||
#define GLEXT_glGenFramebuffers glGenFramebuffersEXT
|
||||
#define GLEXT_glGenRenderbuffers glGenRenderbuffersEXT
|
||||
#define GLEXT_glBindFramebuffer glBindFramebufferEXT
|
||||
#define GLEXT_glBindRenderbuffer glBindRenderbufferEXT
|
||||
#define GLEXT_glDeleteFramebuffers glDeleteFramebuffersEXT
|
||||
#define GLEXT_glDeleteRenderbuffers glDeleteRenderbuffersEXT
|
||||
#define GLEXT_glRenderbufferStorage glRenderbufferStorageEXT
|
||||
#define GLEXT_glFramebufferRenderbuffer glFramebufferRenderbufferEXT
|
||||
#define GLEXT_glFramebufferTexture2D glFramebufferTexture2DEXT
|
||||
#define GLEXT_glCheckFramebufferStatus glCheckFramebufferStatusEXT
|
||||
#define GLEXT_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||
#define GLEXT_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
|
||||
#define GLEXT_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
||||
#define GLEXT_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GLEXT_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GLEXT_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
#define GLEXT_GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT
|
||||
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#define GLEXT_texture_non_power_of_two GLEW_ARB_texture_non_power_of_two
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -379,9 +379,9 @@ void RenderTarget::applyBlendMode(BlendMode mode)
|
||||
// Alpha blending
|
||||
default :
|
||||
case BlendAlpha :
|
||||
if (GL_blend_func_separate)
|
||||
if (GLEXT_blend_func_separate)
|
||||
{
|
||||
glCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
||||
glCheck(GLEXT_glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -392,9 +392,9 @@ void RenderTarget::applyBlendMode(BlendMode mode)
|
||||
|
||||
// Additive blending
|
||||
case BlendAdd :
|
||||
if (GL_blend_func_separate)
|
||||
if (GLEXT_blend_func_separate)
|
||||
{
|
||||
glCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE));
|
||||
glCheck(GLEXT_glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -53,14 +53,14 @@ RenderTextureImplFBO::~RenderTextureImplFBO()
|
||||
if (m_depthBuffer)
|
||||
{
|
||||
GLuint depthBuffer = static_cast<GLuint>(m_depthBuffer);
|
||||
glCheck(glDeleteRenderbuffers(1, &depthBuffer));
|
||||
glCheck(GLEXT_glDeleteRenderbuffers(1, &depthBuffer));
|
||||
}
|
||||
|
||||
// Destroy the frame buffer
|
||||
if (m_frameBuffer)
|
||||
{
|
||||
GLuint frameBuffer = static_cast<GLuint>(m_frameBuffer);
|
||||
glCheck(glDeleteFramebuffers(1, &frameBuffer));
|
||||
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
||||
}
|
||||
|
||||
// Delete the context
|
||||
@ -76,7 +76,7 @@ bool RenderTextureImplFBO::isAvailable()
|
||||
// Make sure that extensions are initialized
|
||||
priv::ensureExtensionsInit();
|
||||
|
||||
return GL_framebuffer_object != 0;
|
||||
return GLEXT_framebuffer_object != 0;
|
||||
}
|
||||
|
||||
|
||||
@ -88,39 +88,39 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
||||
|
||||
// Create the framebuffer object
|
||||
GLuint frameBuffer = 0;
|
||||
glCheck(glGenFramebuffers(1, &frameBuffer));
|
||||
glCheck(GLEXT_glGenFramebuffers(1, &frameBuffer));
|
||||
m_frameBuffer = static_cast<unsigned int>(frameBuffer);
|
||||
if (!m_frameBuffer)
|
||||
{
|
||||
err() << "Impossible to create render texture (failed to create the frame buffer object)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
glCheck(glBindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer));
|
||||
glCheck(GLEXT_glBindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer));
|
||||
|
||||
// Create the depth buffer if requested
|
||||
if (depthBuffer)
|
||||
{
|
||||
GLuint depth = 0;
|
||||
glCheck(glGenRenderbuffers(1, &depth));
|
||||
glCheck(GLEXT_glGenRenderbuffers(1, &depth));
|
||||
m_depthBuffer = static_cast<unsigned int>(depth);
|
||||
if (!m_depthBuffer)
|
||||
{
|
||||
err() << "Impossible to create render texture (failed to create the attached depth buffer)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
glCheck(glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer));
|
||||
glCheck(glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height));
|
||||
glCheck(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer));
|
||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_depthBuffer));
|
||||
glCheck(GLEXT_glRenderbufferStorage(GLEXT_GL_RENDERBUFFER, GLEXT_GL_DEPTH_COMPONENT, width, height));
|
||||
glCheck(GLEXT_glFramebufferRenderbuffer(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_DEPTH_ATTACHMENT, GLEXT_GL_RENDERBUFFER, m_depthBuffer));
|
||||
}
|
||||
|
||||
// Link the texture to the frame buffer
|
||||
glCheck(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0));
|
||||
glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0));
|
||||
|
||||
// A final check, just to be sure...
|
||||
GLenum status = glCheck(glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
GLenum status = glCheck(GLEXT_glCheckFramebufferStatus(GLEXT_GL_FRAMEBUFFER));
|
||||
if (status != GLEXT_GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
glCheck(glBindFramebuffer(GL_FRAMEBUFFER, 0));
|
||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, 0));
|
||||
err() << "Impossible to create render texture (failed to link the target texture to the frame buffer)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -271,18 +271,18 @@ Image Texture::copyToImage() const
|
||||
// OpenGL ES doesn't have the glGetTexImage function, the only way to read
|
||||
// from a texture is to bind it to a FBO and use glReadPixels
|
||||
GLuint frameBuffer = 0;
|
||||
glCheck(glGenFramebuffers(1, &frameBuffer));
|
||||
glCheck(GLEXT_glGenFramebuffers(1, &frameBuffer));
|
||||
if (frameBuffer)
|
||||
{
|
||||
GLint previousFrameBuffer;
|
||||
glCheck(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFrameBuffer));
|
||||
glCheck(glGetIntegerv(GLEXT_GL_FRAMEBUFFER_BINDING, &previousFrameBuffer));
|
||||
|
||||
glCheck(glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer));
|
||||
glCheck(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0));
|
||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer));
|
||||
glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0));
|
||||
glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]));
|
||||
glCheck(glDeleteFramebuffers(1, &frameBuffer));
|
||||
glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer));
|
||||
|
||||
glCheck(glBindFramebuffer(GL_FRAMEBUFFER, previousFrameBuffer));
|
||||
glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer));
|
||||
}
|
||||
|
||||
#else
|
||||
@ -556,7 +556,7 @@ unsigned int Texture::getValidSize(unsigned int size)
|
||||
// Make sure that extensions are initialized
|
||||
priv::ensureExtensionsInit();
|
||||
|
||||
if (GL_texture_non_power_of_two)
|
||||
if (GLEXT_texture_non_power_of_two)
|
||||
{
|
||||
// If hardware supports NPOT textures, then just return the unmodified size
|
||||
return size;
|
||||
|
Loading…
Reference in New Issue
Block a user