cmake build system + OS X support / cleanups for Humble Release #8
|
@ -873,7 +873,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
}
|
}
|
||||||
|
|
||||||
TEX::bind(p->gl.tex);
|
TEX::bind(p->gl.tex);
|
||||||
TEX::uploadSubImage(posRect.x, posRect.y, posRect.w, posRect.h, txtSurf->pixels, GL_BGRA_EXT);
|
TEX::uploadSubImage(posRect.x, posRect.y, posRect.w, posRect.h, txtSurf->pixels, GL_BGRA);
|
||||||
|
|
||||||
PixelStore::reset();
|
PixelStore::reset();
|
||||||
}
|
}
|
||||||
|
@ -884,7 +884,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
TEXFBO &gpTF = shState->gpTexFBO(txtSurf->w, txtSurf->h);
|
TEXFBO &gpTF = shState->gpTexFBO(txtSurf->w, txtSurf->h);
|
||||||
|
|
||||||
TEX::bind(gpTF.tex);
|
TEX::bind(gpTF.tex);
|
||||||
TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA_EXT);
|
TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA);
|
||||||
|
|
||||||
FBO::bind(gpTF.fbo, FBO::Read);
|
FBO::bind(gpTF.fbo, FBO::Read);
|
||||||
p->bindFBO();
|
p->bindFBO();
|
||||||
|
@ -917,7 +917,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
shader.setOpacity(txtAlpha);
|
shader.setOpacity(txtAlpha);
|
||||||
|
|
||||||
shState->bindTex();
|
shState->bindTex();
|
||||||
TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA_EXT);
|
TEX::uploadSubImage(0, 0, txtSurf->w, txtSurf->h, txtSurf->pixels, GL_BGRA);
|
||||||
TEX::setSmooth(true);
|
TEX::setSmooth(true);
|
||||||
|
|
||||||
Quad &quad = shState->gpQuad();
|
Quad &quad = shState->gpQuad();
|
||||||
|
|
|
@ -109,19 +109,19 @@ namespace RBO
|
||||||
inline ID gen()
|
inline ID gen()
|
||||||
{
|
{
|
||||||
ID id;
|
ID id;
|
||||||
glGenRenderbuffersEXT(1, &id.gl);
|
glGenRenderbuffers(1, &id.gl);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void del(ID id)
|
inline void del(ID id)
|
||||||
{
|
{
|
||||||
glDeleteRenderbuffersEXT(1, &id.gl);
|
glDeleteRenderbuffers(1, &id.gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bind(ID id)
|
inline void bind(ID id)
|
||||||
{
|
{
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id.gl);
|
glBindRenderbuffer(GL_RENDERBUFFER, id.gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void unbind()
|
inline void unbind()
|
||||||
|
@ -131,7 +131,7 @@ namespace RBO
|
||||||
|
|
||||||
inline void allocEmpty(GLsizei width, GLsizei height)
|
inline void allocEmpty(GLsizei width, GLsizei height)
|
||||||
{
|
{
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, width, height);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,25 +155,25 @@ namespace FBO
|
||||||
inline ID gen()
|
inline ID gen()
|
||||||
{
|
{
|
||||||
ID id;
|
ID id;
|
||||||
glGenFramebuffersEXT(1, &id.gl);
|
glGenFramebuffers(1, &id.gl);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void del(ID id)
|
inline void del(ID id)
|
||||||
{
|
{
|
||||||
glDeleteFramebuffersEXT(1, &id.gl);
|
glDeleteFramebuffers(1, &id.gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bind(ID id, Mode mode)
|
inline void bind(ID id, Mode mode)
|
||||||
{
|
{
|
||||||
static const GLenum modes[] =
|
static const GLenum modes[] =
|
||||||
{
|
{
|
||||||
GL_DRAW_FRAMEBUFFER_EXT,
|
GL_DRAW_FRAMEBUFFER,
|
||||||
GL_READ_FRAMEBUFFER_EXT
|
GL_READ_FRAMEBUFFER
|
||||||
};
|
};
|
||||||
|
|
||||||
glBindFramebufferEXT(modes[mode], id.gl);
|
glBindFramebuffer(modes[mode], id.gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void unbind(Mode mode)
|
inline void unbind(Mode mode)
|
||||||
|
@ -183,12 +183,12 @@ namespace FBO
|
||||||
|
|
||||||
inline void setTarget(TEX::ID target, unsigned colorAttach = 0)
|
inline void setTarget(TEX::ID target, unsigned colorAttach = 0)
|
||||||
{
|
{
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setTarget(RBO::ID target, unsigned colorAttach = 0)
|
inline void setTarget(RBO::ID target, unsigned colorAttach = 0)
|
||||||
{
|
{
|
||||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_RENDERBUFFER, target.gl);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_RENDERBUFFER, target.gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void blit(int srcX, int srcY,
|
inline void blit(int srcX, int srcY,
|
||||||
|
@ -203,9 +203,9 @@ namespace FBO
|
||||||
GL_LINEAR
|
GL_LINEAR
|
||||||
};
|
};
|
||||||
|
|
||||||
glBlitFramebufferEXT(srcX, srcY, srcX+srcW, srcY+srcH,
|
glBlitFramebuffer(srcX, srcY, srcX+srcW, srcY+srcH,
|
||||||
dstX, dstY, dstX+dstW, dstY+dstH,
|
dstX, dstY, dstX+dstW, dstY+dstH,
|
||||||
GL_COLOR_BUFFER_BIT, modes[mode]);
|
GL_COLOR_BUFFER_BIT, modes[mode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void blit(int srcX, int srcY,
|
inline void blit(int srcX, int srcY,
|
||||||
|
|
|
@ -71,21 +71,21 @@ void GLBlendMode::apply(const BlendType &value)
|
||||||
|
|
||||||
case BlendNormal :
|
case BlendNormal :
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
|
||||||
GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BlendAddition :
|
case BlendAddition :
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE,
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE,
|
||||||
GL_ONE, GL_ONE);
|
GL_ONE, GL_ONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BlendSubstraction :
|
case BlendSubstraction :
|
||||||
// FIXME Alpha calculation is untested
|
// FIXME Alpha calculation is untested
|
||||||
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT);
|
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
||||||
glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE,
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE,
|
||||||
GL_ONE, GL_ONE);
|
GL_ONE, GL_ONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
63
src/main.cpp
63
src/main.cpp
|
@ -39,21 +39,11 @@
|
||||||
|
|
||||||
static const char *reqExt[] =
|
static const char *reqExt[] =
|
||||||
{
|
{
|
||||||
"GL_ARB_fragment_shader",
|
// Everything we are using is CORE in OpenGL 2.0 except FBOs and VAOs which we'll handle in a special function
|
||||||
"GL_ARB_shader_objects",
|
|
||||||
"GL_ARB_vertex_shader",
|
|
||||||
"GL_ARB_shading_language_100",
|
|
||||||
"GL_ARB_texture_non_power_of_two",
|
|
||||||
"GL_ARB_vertex_array_object",
|
|
||||||
"GL_ARB_vertex_buffer_object",
|
|
||||||
"GL_EXT_bgra",
|
|
||||||
"GL_EXT_blend_func_separate",
|
|
||||||
"GL_EXT_blend_subtract",
|
|
||||||
"GL_EXT_framebuffer_object",
|
|
||||||
"GL_EXT_framebuffer_blit",
|
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgssThreadError(RGSSThreadData *rtData, const std::string &msg)
|
rgssThreadError(RGSSThreadData *rtData, const std::string &msg)
|
||||||
{
|
{
|
||||||
|
@ -77,6 +67,50 @@ printGLInfo()
|
||||||
Debug() << "GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
|
Debug() << "GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
setupOptionalGLExtensions(RGSSThreadData* threadData)
|
||||||
|
{
|
||||||
|
if (!GLEW_ARB_framebuffer_object) {
|
||||||
|
if (!GLEW_EXT_framebuffer_object && !GLEW_EXT_framebuffer_blit) {
|
||||||
|
rgssThreadError(threadData, "GL extensions \"GL_ARB_framebuffer_object\" or compatible extensiosns GL_EXT_framebuffer_object and GL_EXT_framebuffer_blit are not present");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// setup compat
|
||||||
|
// From EXT_framebuffer_object
|
||||||
|
glGenRenderbuffers = glGenRenderbuffersEXT;
|
||||||
|
glDeleteRenderbuffers = glDeleteRenderbuffersEXT;
|
||||||
|
glBindRenderbuffer = glBindRenderbufferEXT;
|
||||||
|
glRenderbufferStorage = glRenderbufferStorageEXT;
|
||||||
|
|
||||||
|
glGenFramebuffers = glGenFramebuffersEXT;
|
||||||
|
glDeleteFramebuffers = glDeleteFramebuffersEXT;
|
||||||
|
glBindFramebuffer = glBindFramebufferEXT;
|
||||||
|
glFramebufferTexture2D = glFramebufferTexture2DEXT;
|
||||||
|
glFramebufferRenderbuffer = glFramebufferRenderbufferEXT;
|
||||||
|
|
||||||
|
// From EXT_framebuffer_blit
|
||||||
|
glBlitFramebuffer = glBlitFramebufferEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!GLEW_ARB_timer_query && GLEW_EXT_timer_query) {
|
||||||
|
glGetQueryObjecti64v = glGetQueryObjecti64vEXT;
|
||||||
|
glGetQueryObjectui64v = glGetQueryObjectui64vEXT;
|
||||||
|
}
|
||||||
|
if (!GLEW_ARB_vertex_array_object ) {
|
||||||
|
if (!GLEW_APPLE_vertex_array_object) {
|
||||||
|
rgssThreadError(threadData, "GL extensions \"GL_ARB_vertex_array_object\" or compatible extensiosn GL_APPLE_vertex_array_object are not present");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// setup compat
|
||||||
|
glBindVertexArray = glBindVertexArrayAPPLE;
|
||||||
|
// the cast is because apple's uses const GLuint* and ARB doesn't
|
||||||
|
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glGenVertexArraysAPPLE;
|
||||||
|
glDeleteVertexArrays = glDeleteVertexArraysAPPLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int rgssThreadFun(void *userdata)
|
int rgssThreadFun(void *userdata)
|
||||||
{
|
{
|
||||||
RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata);
|
RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata);
|
||||||
|
@ -132,6 +166,11 @@ int rgssThreadFun(void *userdata)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Setup optional GL extensions */
|
||||||
|
if (!setupOptionalGLExtensions(threadData)) {
|
||||||
|
SDL_GL_DeleteContext(glCtx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SetSwapInterval(threadData->config.vsync ? 1 : 0);
|
SDL_GL_SetSwapInterval(threadData->config.vsync ? 1 : 0);
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ PerfTimer *createCPUTimer(int iter)
|
||||||
|
|
||||||
PerfTimer *createGPUTimer(int iter)
|
PerfTimer *createGPUTimer(int iter)
|
||||||
{
|
{
|
||||||
if (GLEW_EXT_timer_query)
|
if (GLEW_ARB_timer_query || GLEW_EXT_timer_query)
|
||||||
{
|
{
|
||||||
return new GPUTimerGLQuery(iter);
|
return new GPUTimerGLQuery(iter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue