mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-01 21:16:01 +00:00
Added USE_FBO for OpenGL ES functionality
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@969 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -2,6 +2,8 @@ PROJECT(projectM)
|
||||
|
||||
OPTION (USE_DEVIL "Use devIL for image loading rather than the builtin SOIL library" OFF)
|
||||
|
||||
OPTION (USE_FBO "Use Framebuffer Objects for increased rendering quality. Disable this for OpenGL ES 1.x or if you are experiencing problems on older or note well supported hardware." ON)
|
||||
|
||||
SET(SOIL_SOURCES image_DXT.c image_helper.c SOIL.c stb_image_aug.c)
|
||||
|
||||
SET(projectM_SOURCES projectM.cpp FBO.cpp InitCond.cpp
|
||||
@ -20,14 +22,17 @@ SET (projectM_SOURCES ${projectM_SOURCES} ${SOIL_SOURCES})
|
||||
SET (IMAGE_LOADING_LIBS )
|
||||
endif (USE_DEVIL)
|
||||
|
||||
if(USE_FBO)
|
||||
ADD_DEFINITIONS(-DUSE_FBO)
|
||||
endif(USE_FBO)
|
||||
|
||||
ADD_LIBRARY(projectM SHARED ${projectM_SOURCES})
|
||||
SET_TARGET_PROPERTIES(projectM PROPERTIES VERSION 2.00 SOVERSION 2)
|
||||
|
||||
if (APPLE)
|
||||
ADD_DEFINITIONS(-DMACOS -DUSE_FBO -DSTBI_NO_DDS)
|
||||
ADD_DEFINITIONS(-DMACOS -DSTBI_NO_DDS)
|
||||
else (APPLE)
|
||||
ADD_DEFINITIONS(-DLINUX -DUSE_FBO -DSTBI_NO_DDS -DUSE_THREADS)
|
||||
ADD_DEFINITIONS(-DLINUX -DSTBI_NO_DDS -DUSE_THREADS)
|
||||
endif(APPLE)
|
||||
|
||||
ADD_DEFINITIONS(-DCMAKE_INSTALL_PREFIX="\\\"${CMAKE_INSTALL_PREFIX}\\\"")
|
||||
|
||||
@ -39,6 +39,7 @@ RenderTarget::~RenderTarget() {
|
||||
|
||||
glDeleteTextures( 1, &this->textureID[0]);
|
||||
|
||||
#ifdef USE_FBO
|
||||
if (useFBO)
|
||||
{
|
||||
glDeleteTextures( 1, &this->textureID[1] );
|
||||
@ -51,11 +52,14 @@ RenderTarget::~RenderTarget() {
|
||||
glDeleteFramebuffersEXT(1, &this->fbuffer[1]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
GLuint RenderTarget::initRenderToTexture()
|
||||
{
|
||||
#ifdef USE_FBO
|
||||
|
||||
if (this->useFBO==1)
|
||||
{
|
||||
this->renderToTexture=1;
|
||||
@ -80,7 +84,8 @@ GLuint RenderTarget::initRenderToTexture()
|
||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, this->textureID[2], 0 );
|
||||
return this->textureID[2];
|
||||
}
|
||||
else return -1;
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
@ -89,12 +94,13 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
|
||||
int mindim = 0;
|
||||
int origtexsize = 0;
|
||||
this->useFBO = true;
|
||||
|
||||
this->renderToTexture = 0;
|
||||
|
||||
this->texsize = texsize;
|
||||
|
||||
|
||||
#ifdef USE_FBO
|
||||
this->useFBO = true;
|
||||
if(this->useFBO)
|
||||
{
|
||||
glewInit();
|
||||
@ -144,9 +150,12 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else this->useFBO=0;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
this->useFBO=false;
|
||||
#endif
|
||||
/** Fallback pbuf;fer creation via teximage hack */
|
||||
/** Check the texture size against the viewport size */
|
||||
/** If the viewport is smaller, then we'll need to scale the texture size down */
|
||||
@ -181,7 +190,7 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
NULL);
|
||||
}
|
||||
|
||||
this->useFBO=0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -227,18 +236,18 @@ RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
|
||||
/** Locks the pbuffer */
|
||||
void RenderTarget::lock() {
|
||||
|
||||
|
||||
#ifdef USE_FBO
|
||||
if(this->useFBO)
|
||||
{
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->fbuffer[0]);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Unlocks the pbuffer */
|
||||
void RenderTarget::unlock() {
|
||||
|
||||
|
||||
#ifdef USE_FBO
|
||||
if(this->useFBO)
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, this->textureID[1] );
|
||||
@ -248,7 +257,7 @@ void RenderTarget::unlock() {
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
/** Fallback texture path */
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, this->textureID[0] );
|
||||
|
||||
@ -28,9 +28,9 @@
|
||||
#ifndef _RENDERTARGET_H
|
||||
#define _RENDERTARGET_H
|
||||
|
||||
|
||||
#ifdef USE_FBO
|
||||
#include <GL/glew.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(MACOS)
|
||||
#include <gl.h>
|
||||
@ -76,8 +76,10 @@ public:
|
||||
*/
|
||||
/** Render target texture ID for non-pbuffer systems */
|
||||
GLuint textureID[3];
|
||||
#ifdef USE_FBO
|
||||
GLuint fbuffer[2];
|
||||
GLuint depthb[2];
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -206,12 +206,15 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
//video texture memory and render fullscreen.
|
||||
|
||||
/** Reset the viewport size */
|
||||
#ifdef USE_FBO
|
||||
if(renderTarget->renderToTexture)
|
||||
{
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->renderTarget->fbuffer[1]);
|
||||
glViewport( 0, 0, this->renderTarget->texsize, this->renderTarget->texsize );
|
||||
}
|
||||
else glViewport( 0, 0, this->vw, this->vh );
|
||||
else
|
||||
#endif
|
||||
glViewport( 0, 0, this->vw, this->vh );
|
||||
|
||||
|
||||
|
||||
@ -241,9 +244,10 @@ void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInp
|
||||
if(this->showstats%2) draw_stats(presetInputs);
|
||||
glTranslatef(0.5 , 0.5, 0);
|
||||
|
||||
#ifdef USE_FBO
|
||||
if(renderTarget->renderToTexture)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -376,8 +376,8 @@ void projectM::projectM_reset()
|
||||
|
||||
/** Default variable settings */
|
||||
|
||||
this->wvw = 512;
|
||||
this->wvh = 512;
|
||||
// this->wvw = 512;
|
||||
// this->wvh = 512;
|
||||
|
||||
/** More other stuff */
|
||||
this->mspf = 0;
|
||||
|
||||
Reference in New Issue
Block a user