Getting closer with FBO's

This commit is contained in:
Mark Watkins 2011-06-18 02:28:27 +10:00
parent 5407fda324
commit 1fe56dd1e9
5 changed files with 36 additions and 26 deletions

View File

@ -8309,7 +8309,7 @@
1308026543 D
1308326231 /home/mark/projects/git/sleepyhead/src/version.h
1308327771 /home/mark/projects/git/sleepyhead/src/version.h
1308003040 ent of cb2ab33... Linux wx2.8 & wx2.9 builds fixed
<wx/dcbuffer.h>
@ -8362,7 +8362,7 @@
"sleeplib/profiles.h"
"sleeplib/machine_loader.h"
1308313179 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
1308326479 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
"freetype-gl/font-manager.h"
"freetype-gl/texture-font.h"
"graph.h"
@ -11074,7 +11074,7 @@
<GL/glx.h>
<wx/bitmap.h>
1308314362 source:/home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.cpp
1308327673 source:/home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.cpp
"gl_pbuffer.h"
<GL/glu.h>
<wx/utils.h>

View File

@ -16,13 +16,13 @@
<File name="../../src/SleepyHeadMain.h" open="1" top="0" tabpos="2">
<Cursor position="2035" topLine="47" />
</File>
<File name="../../src/graphs/gl_pbuffer.cpp" open="1" top="0" tabpos="5">
<File name="../../src/graphs/gl_pbuffer.cpp" open="1" top="1" tabpos="5">
<Cursor position="3" topLine="0" />
</File>
<File name="../../src/graphs/gl_pbuffer.h" open="1" top="0" tabpos="6">
<Cursor position="401" topLine="0" />
</File>
<File name="../../src/graphs/graph.cpp" open="1" top="1" tabpos="3">
<File name="../../src/graphs/graph.cpp" open="1" top="0" tabpos="3">
<Cursor position="2743" topLine="83" />
</File>
<File name="../../src/graphs/graph.h" open="1" top="0" tabpos="4">

View File

@ -61,14 +61,7 @@ FBO::FBO(int width, int height)
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
// create texture to render to.
glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_2D, img);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0);
m_depth_buffer=true;
m_depth_buffer=false;
m_color_buffer=true; //false;
if (m_depth_buffer) {
@ -82,23 +75,39 @@ FBO::FBO(int width, int height)
glGenRenderbuffersEXT(1, &colorbuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorbuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, m_width, m_height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, colorbuffer);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorbuffer);
}
// create texture to render to.
/*glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_2D, img);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0);*/
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
//if (status!=GL_FRAMEBUFFER_COMPLETE_EXT) {
GLenum err = glGetError();
if (err!=GL_NO_ERROR) {
wxString a((char *)gluErrorString(status),wxConvUTF8);
throw GLException(wxT("glCheckFramebufferStatusEXT failed")+a);
if (status!=GL_FRAMEBUFFER_COMPLETE_EXT) {
wxString a;
a << (int)status; //((char *)gluErrorString(status),wxConvUTF8);
// glDeleteTextures(1, &img);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glDeleteFramebuffersEXT(1, &fbo);
if (m_depth_buffer)
glDeleteRenderbuffersEXT(1, &depthbuffer);
if (m_color_buffer)
glDeleteRenderbuffersEXT(1, &colorbuffer);
throw GLException(wxT("glCheckFramebufferStatusEXT failed: ")+a);
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
// GLenum err = glGetError();
// if (err!=GL_NO_ERROR) {
}
FBO::~FBO()
{
glDeleteTextures(1, &img);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glDeleteFramebuffersEXT(1, &fbo);
if (m_depth_buffer)
@ -119,7 +128,7 @@ wxBitmap *FBO::Snapshot(int width,int height)
{
//width=m_width;
//height=m_height;
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
//glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
void* pixels = malloc(3 * width * height); // must use malloc
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);

View File

@ -1003,6 +1003,7 @@ pBuffer *pbuffer=NULL;
wxBitmap * gGraphWindow::RenderBitmap(int width,int height)
{
wxBitmap *bmp;
Update();
if (!pbuffer) {
try {

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type
static const long _MAJOR = 0;
static const long _MINOR = 7;
static const long _BUILD = 6592;
static const long _REVISION = 19276;
static const long _BUILD = 6607;
static const long _REVISION = 19376;
//Miscellaneous Version Types
static const long _BUILDS_COUNT = 7932;
#define _RC_FILEVERSION 0,7,6592,19276
#define _RC_FILEVERSION_STRING "0, 7, 6592, 19276\0"
static const char _FULLVERSION_STRING[] = "0.7.6592.19276";
static const long _BUILDS_COUNT = 7973;
#define _RC_FILEVERSION 0,7,6607,19376
#define _RC_FILEVERSION_STRING "0, 7, 6607, 19376\0"
static const char _FULLVERSION_STRING[] = "0.7.6607.19376";
//These values are to keep track of your versioning state, don't modify them.
static const long _BUILD_HISTORY = 0;