- added FBO's for map preview rendering, which improves fps in the custom menu for video cards that support Frame Buffer Objects
This commit is contained in:
parent
dd75518af0
commit
86baa04a3b
|
@ -4391,17 +4391,20 @@ VisibleQuadContainerCache & Renderer::getQuadCache( bool updateOnDirtyFrame,
|
|||
void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
||||
int screenPosX, int screenPosY,
|
||||
Texture2D **renderToTexture) {
|
||||
float alt=0;
|
||||
float showWater=0;
|
||||
int renderMapHeight=64;
|
||||
int renderMapWidth=64;
|
||||
float cellSize=2;
|
||||
float playerCrossSize=2;
|
||||
float clientW=renderMapWidth*cellSize;
|
||||
float clientH=renderMapHeight*cellSize;;
|
||||
|
||||
static bool supportFBOs = Texture2DGl().supports_FBO_RBO();
|
||||
//static bool supportFBOs = false;
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
float alt = 0;
|
||||
float showWater = 0;
|
||||
int renderMapHeight = 64;
|
||||
int renderMapWidth = 64;
|
||||
float cellSize = 2;
|
||||
float playerCrossSize = 2;
|
||||
float clientW = renderMapWidth * cellSize;
|
||||
float clientH = renderMapHeight * cellSize;;
|
||||
|
||||
// stretch small maps to 128x128
|
||||
if(map->getW() < map->getH()) {
|
||||
cellSize = cellSize * renderMapHeight / map->getH();
|
||||
|
@ -4412,30 +4415,18 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
|
||||
assertGl();
|
||||
|
||||
/*
|
||||
if(renderToTexture != NULL) {
|
||||
if(supportFBOs == true && renderToTexture != NULL) {
|
||||
Config &config= Config::getInstance();
|
||||
Texture2D::Filter textureFilter = strToTextureFilter(config.getString("Filter"));
|
||||
int maxAnisotropy = config.getInt("FilterMaxAnisotropy");
|
||||
|
||||
*renderToTexture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
|
||||
Texture2DGl *texture = static_cast<Texture2DGl *>(*renderToTexture);
|
||||
//texture->setFormat(Texture::fAlpha);
|
||||
texture->setMipmap(false);
|
||||
Pixmap2D *pixmapScreenShot = texture->getPixmap();
|
||||
pixmapScreenShot->init(metrics.getVirtualW(), metrics.getVirtualH(), 3);
|
||||
//pixmapScreenShot->init(map->getW(),map->getH(),3);
|
||||
//pixmapScreenShot->init(200, 360, 3);
|
||||
pixmapScreenShot->init(metrics.getVirtualW(), metrics.getVirtualH(), 4);
|
||||
texture->setForceCompressionDisabled(true);
|
||||
texture->init(textureFilter,maxAnisotropy);
|
||||
|
||||
|
||||
//texture->initFrameBuffer();
|
||||
//texture->attachFrameBufferToTexture();
|
||||
|
||||
//texture->initRenderBuffer();
|
||||
//texture->attachRenderBuffer();
|
||||
|
||||
texture->setup_FBO_RBO();
|
||||
|
||||
if(texture->checkFrameBufferStatus() == false) {
|
||||
|
@ -4445,46 +4436,66 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
*renderToTexture=NULL;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if(supportFBOs == true && renderToTexture != NULL) {
|
||||
cellSize =1;
|
||||
clientW = metrics.getVirtualW();
|
||||
clientH = metrics.getVirtualH();
|
||||
int mapMaxDimensionSize = std::max(map->getW(),map->getH());
|
||||
switch(mapMaxDimensionSize) {
|
||||
case 8:
|
||||
cellSize = 96;
|
||||
break;
|
||||
case 16:
|
||||
cellSize = 48;
|
||||
break;
|
||||
case 32:
|
||||
cellSize = 24;
|
||||
break;
|
||||
case 64:
|
||||
cellSize = 12;
|
||||
break;
|
||||
case 128:
|
||||
cellSize = 6;
|
||||
break;
|
||||
case 256:
|
||||
cellSize = 3;
|
||||
break;
|
||||
case 512:
|
||||
cellSize = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
glFrontFace(GL_CW);
|
||||
glEnable(GL_CULL_FACE);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
||||
glLoadIdentity();
|
||||
//glViewport(screenPosX, screenPosY, metrics.getVirtualW(),metrics.getVirtualH());
|
||||
// glOrtho(0, clientW, 0, clientH, -1, 1);
|
||||
|
||||
//glOrtho(screenPosX, screenPosX+clientW, screenPosY+clientH, screenPosY, 0, 1);
|
||||
GLint viewport[4]; // Where The original Viewport Values Will Be Stored
|
||||
|
||||
if(supportFBOs == true && renderToTexture != NULL) {
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glOrtho(0, clientW, 0, clientH, 0, 1);
|
||||
glViewport(0, 0, clientW, clientH);
|
||||
}
|
||||
else {
|
||||
glOrtho(0, metrics.getVirtualW(), 0, metrics.getVirtualH(), 0, 1);
|
||||
//gluOrtho2D (0, metrics.getVirtualW(), 0, metrics.getVirtualH());
|
||||
|
||||
//glEnable( GL_SCISSOR_TEST );
|
||||
//glScissor(screenPosX, screenPosY,metrics.getVirtualW(), metrics.getVirtualH());
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
if(supportFBOs == false || renderToTexture == NULL) {
|
||||
glTranslatef(static_cast<float>(screenPosX),static_cast<float>(screenPosY)-clientH,0.0f);
|
||||
|
||||
//glEnable( GL_SCISSOR_TEST );
|
||||
//glScissor(screenPosX, screenPosY,screenPosX-clientW, screenPosY-clientH);
|
||||
|
||||
//int newX = screenPosX - (metrics.getVirtualW() / 2);
|
||||
//int newY = screenPosY - (metrics.getVirtualH() / 2);
|
||||
//int newX = 0;
|
||||
//int newY = 0;
|
||||
//glTranslatef(static_cast<float>(newX),static_cast<float>(newY),0.0f);
|
||||
}
|
||||
|
||||
glPushAttrib(GL_CURRENT_BIT);
|
||||
//glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
|
||||
glLineWidth(1);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
glColor3f(0, 0, 0);
|
||||
|
||||
for (int j = 0; j < map->getH(); j++) {
|
||||
|
@ -4567,10 +4578,10 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
}
|
||||
}
|
||||
|
||||
// bool found = false;
|
||||
// bool found = false;
|
||||
|
||||
//height lines
|
||||
// if (!found) {
|
||||
// if (!found) {
|
||||
|
||||
//left
|
||||
if (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j)) {
|
||||
|
@ -4605,7 +4616,7 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
glVertex2f((i + 1) * cellSize, clientH - j * cellSize);
|
||||
glEnd();
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
//resources
|
||||
if(renderAll == true) {
|
||||
|
@ -4627,12 +4638,16 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//start locations
|
||||
glLineWidth(3);
|
||||
|
||||
if(supportFBOs == true && renderToTexture != NULL) {
|
||||
glLineWidth(14);
|
||||
playerCrossSize = 24;
|
||||
}
|
||||
else {
|
||||
// force playerCrossSize to be at least of size 4
|
||||
if(cellSize < 4) {
|
||||
playerCrossSize = 4;
|
||||
|
@ -4640,17 +4655,34 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
else {
|
||||
playerCrossSize = cellSize;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < map->getMaxFactions(); i++) {
|
||||
switch (i) {
|
||||
case 0: glColor3f(1.f, 0.f, 0.f); break;
|
||||
case 1: glColor3f(0.f, 0.f, 1.f); break;
|
||||
case 2: glColor3f(0.f, 1.f, 0.f); break;
|
||||
case 3: glColor3f(1.f, 1.f, 0.f); break;
|
||||
case 4: glColor3f(1.f, 1.f, 1.f); break;
|
||||
case 5: glColor3f(0.f, 1.f, 0.8f); break;
|
||||
case 6: glColor3f(1.f, 0.5f, 0.f); break;
|
||||
case 7: glColor3f(1.f, 0.5f, 1.f); break;
|
||||
case 0:
|
||||
glColor3f(1.f, 0.f, 0.f);
|
||||
break;
|
||||
case 1:
|
||||
glColor3f(0.f, 0.f, 1.f);
|
||||
break;
|
||||
case 2:
|
||||
glColor3f(0.f, 1.f, 0.f);
|
||||
break;
|
||||
case 3:
|
||||
glColor3f(1.f, 1.f, 0.f);
|
||||
break;
|
||||
case 4:
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
break;
|
||||
case 5:
|
||||
glColor3f(0.f, 1.f, 0.8f);
|
||||
break;
|
||||
case 6:
|
||||
glColor3f(1.f, 0.5f, 0.f);
|
||||
break;
|
||||
case 7:
|
||||
glColor3f(1.f, 0.5f, 1.f);
|
||||
break;
|
||||
}
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f((map->getStartLocationX(i) - 1) * cellSize, clientH - (map->getStartLocationY(i) - 1) * cellSize);
|
||||
|
@ -4665,29 +4697,15 @@ void Renderer::renderMapPreview( const MapPreview *map, bool renderAll,
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
|
||||
//glDisable( GL_SCISSOR_TEST );
|
||||
//glViewport(0, 0, 0, 0);
|
||||
|
||||
if(renderToTexture != NULL) {
|
||||
|
||||
// *renderToTexture = saveScreenToTexture(screenPosX, screenPosY, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
// *renderToTexture = saveScreenToTexture(0, 0, metrics.getVirtualW(), metrics.getVirtualH());
|
||||
/*
|
||||
if(supportFBOs == true && renderToTexture != NULL) {
|
||||
Texture2DGl *texture = static_cast<Texture2DGl *>(*renderToTexture);
|
||||
if(texture != NULL) {
|
||||
// *renderToTexture = saveScreenToTexture(screenPosX, screenPosY, clientW, clientH);
|
||||
texture->dettachFrameBufferFromTexture();
|
||||
|
||||
// Signal the threads queue to add a screenshot save request
|
||||
// MutexSafeWrapper safeMutex(&saveScreenShotThreadAccessor);
|
||||
// saveScreenQueue.push_back(make_pair("bob.png",texture->getPixmap()));
|
||||
// *renderToTexture=NULL;
|
||||
// safeMutex.ReleaseLock();
|
||||
|
||||
// texture->teardown_FBO_RBO();
|
||||
}
|
||||
*/
|
||||
|
||||
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
|
||||
}
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
||||
|
|
|
@ -674,6 +674,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
|
||||
cleanupMapPreviewTexture();
|
||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||
needToRepublishToMasterserver = true;
|
||||
}
|
||||
|
@ -1213,8 +1214,7 @@ void MenuStateCustomGame::render() {
|
|||
renderer.renderTextureQuad(800,600,200,150,factionTexture,0.7f);
|
||||
}
|
||||
if(mapPreviewTexture != NULL) {
|
||||
//renderer.renderTextureQuad(10,350,-1,-1,mapPreviewTexture,0.7);
|
||||
renderer.renderTextureQuad(800,300,200,150,mapPreviewTexture,0.7f);
|
||||
renderer.renderTextureQuad(5,165,180,180,mapPreviewTexture,1.0f);
|
||||
//printf("=================> Rendering map preview texture\n");
|
||||
}
|
||||
|
||||
|
@ -1349,9 +1349,9 @@ void MenuStateCustomGame::render() {
|
|||
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350,&mapPreviewTexture);
|
||||
//printf("=================> Rendering map preview into a texture AFTER (%p)\n", mapPreviewTexture);
|
||||
}
|
||||
else {
|
||||
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350);
|
||||
}
|
||||
//else {
|
||||
//renderer.renderMapPreview(&mapPreview, renderAll, 10, 350);
|
||||
//}
|
||||
}
|
||||
|
||||
if(hasNetworkGameSettings() == true) {
|
||||
|
|
|
@ -28,6 +28,10 @@ protected:
|
|||
GLuint renderBufferId;
|
||||
GLuint frameBufferId;
|
||||
|
||||
void initRenderBuffer();
|
||||
void initFrameBuffer();
|
||||
void attachRenderBuffer();
|
||||
|
||||
public:
|
||||
TextureGl();
|
||||
virtual ~TextureGl();
|
||||
|
@ -36,14 +40,11 @@ public:
|
|||
GLuint getRenderBufferHandle() const {return renderBufferId;}
|
||||
GLuint getFrameBufferHandle() const {return frameBufferId;}
|
||||
|
||||
void initRenderBuffer();
|
||||
void initFrameBuffer();
|
||||
void attachRenderBuffer();
|
||||
void attachFrameBufferToTexture();
|
||||
bool checkFrameBufferStatus();
|
||||
void dettachFrameBufferFromTexture();
|
||||
|
||||
bool supports_FBO_RBO();
|
||||
void setup_FBO_RBO();
|
||||
void attachFrameBufferToTexture();
|
||||
void dettachFrameBufferFromTexture();
|
||||
bool checkFrameBufferStatus();
|
||||
void teardown_FBO_RBO();
|
||||
|
||||
virtual int getTextureWidth() const = 0;
|
||||
|
|
|
@ -21,11 +21,39 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
// Define FBO's (Frame Buffer Objects) for win32
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
|
||||
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
|
||||
PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Shared { namespace Graphics { namespace Gl {
|
||||
|
||||
using namespace Platform;
|
||||
using namespace Shared::Util;
|
||||
|
||||
void setupGLExtensionMethods() {
|
||||
#ifdef WIN32
|
||||
|
||||
static bool setupExtensions=true;
|
||||
if(setupExtensions == true) {
|
||||
setupExtensions = false;
|
||||
glGenFramebuffersEXT= (PFNGLGENFRAMEBUFFERSEXTPROC)SDL_GL_GetProcAddress("glGenFramebuffersEXT");
|
||||
glBindFramebufferEXT= (PFNGLBINDFRAMEBUFFEREXTPROC)SDL_GL_GetProcAddress("glBindFramebufferEXT");
|
||||
glFramebufferTexture2DEXT= (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
|
||||
glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)SDL_GL_GetProcAddress("glDeleteFramebuffersEXT");
|
||||
glCheckFramebufferStatusEXT= (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
const uint64 MIN_BYTES_TO_COMPRESS = 12;
|
||||
|
||||
static std::string getSupportCompressedTextureFormatString(int format) {
|
||||
|
@ -425,6 +453,11 @@ TextureGl::TextureGl() {
|
|||
handle = 0;
|
||||
renderBufferId = 0;
|
||||
frameBufferId = 0;
|
||||
setupGLExtensionMethods();
|
||||
}
|
||||
|
||||
bool TextureGl::supports_FBO_RBO() {
|
||||
return (glGenFramebuffersEXT != NULL);
|
||||
}
|
||||
|
||||
void TextureGl::setup_FBO_RBO() {
|
||||
|
@ -432,17 +465,17 @@ void TextureGl::setup_FBO_RBO() {
|
|||
throw runtime_error("getTextureWidth() < 0 || getTextureHeight() < 0");
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"getTextureWidth() = %d, getTextureHeight() = %d\n",getTextureWidth(),getTextureHeight());
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"getTextureWidth() = %d, getTextureHeight() = %d\n",getTextureWidth(),getTextureHeight());
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
// Did we successfully setup FBO's?
|
||||
if(glGenFramebuffersEXT) {
|
||||
GLint width=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&width);
|
||||
GLint height=0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&height);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"width = %d, height = %d\n",width,height);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"width = %d, height = %d\n",width,height);
|
||||
|
||||
//RGBA8 2D texture, 24 bit depth texture, 256x256
|
||||
//glGenTextures(1, &color_tex);
|
||||
|
@ -472,10 +505,10 @@ void TextureGl::setup_FBO_RBO() {
|
|||
switch(status)
|
||||
{
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"FBO attachment OK!\n");
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"FBO attachment OK!\n");
|
||||
break;
|
||||
default:
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"FBO attachment BAD!\n");
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"FBO attachment BAD!\n");
|
||||
break;
|
||||
}
|
||||
//-------------------------
|
||||
|
@ -483,14 +516,12 @@ void TextureGl::setup_FBO_RBO() {
|
|||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferId);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::teardown_FBO_RBO() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
//----------------
|
||||
//Bind 0, which means render to back buffer
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
@ -501,50 +532,48 @@ void TextureGl::teardown_FBO_RBO() {
|
|||
//Bind 0, which means render to back buffer, as a result, fb is unbound
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT(1, &frameBufferId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::initRenderBuffer() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// create a renderbuffer object to store depth info
|
||||
glGenRenderbuffersEXT(1, &renderBufferId);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderBufferId);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,getTextureWidth(), getTextureHeight());
|
||||
//glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::initFrameBuffer() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// create a framebuffer object
|
||||
glGenFramebuffersEXT(1, &frameBufferId);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::attachRenderBuffer() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// attach the renderbuffer to depth attachment point
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, renderBufferId);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TextureGl::attachFrameBufferToTexture() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// attach the texture to FBO color attachment point
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, handle, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool TextureGl::checkFrameBufferStatus() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// check FBO status
|
||||
// Does the GPU support current FBO configuration?
|
||||
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
|
@ -553,25 +582,22 @@ bool TextureGl::checkFrameBufferStatus() {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void TextureGl::dettachFrameBufferFromTexture() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
// switch back to window-system-provided framebuffer
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
TextureGl::~TextureGl() {
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
#ifndef WIN32
|
||||
|
||||
// Need some work to get extensions properly working in Windows (use Glew lib)
|
||||
if(glGenFramebuffersEXT) {
|
||||
if(renderBufferId != 0) {
|
||||
glDeleteRenderbuffersEXT(1, &renderBufferId);
|
||||
renderBufferId = 0;
|
||||
|
@ -580,10 +606,8 @@ TextureGl::~TextureGl() {
|
|||
glDeleteFramebuffersEXT(1, &frameBufferId);
|
||||
frameBufferId = 0;
|
||||
}
|
||||
|
||||
//glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
|
Loading…
Reference in New Issue
Block a user