|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 21:29:36
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Feb 24 22:29:09 2011 +0100
More detailed GL error checking
---
game/main.cc | 2 --
game/screen_intro.cc | 2 ++
game/video_driver.cc | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 8fbb531..cc08f5a 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -161,7 +161,6 @@ void mainLoop(std::string const& songlist) {
// Main loop
boost::xtime time = now();
unsigned frames = 0;
- glutil::GLErrorChecker glerror("mainloop");
while (!sm.isFinished()) {
Profiler prof("mainloop");
if( g_take_screenshot ) {
@@ -207,7 +206,6 @@ void mainLoop(std::string const& songlist) {
std::cerr << "ERROR: " << e.what() << std::endl;
sm.flashMessage(std::string("ERROR: ") + e.what());
}
- glerror.check("frame");
}
} catch (std::exception& e) {
// This should use ScreenManager fatalError, but it cannot
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 42b473c..f8927fb 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -115,11 +115,13 @@ void ScreenIntro::draw_menu_options() {
}
void ScreenIntro::draw() {
+ glutil::GLErrorChecker glerror("ScreenIntro::draw()");
{
float anim = SDL_GetTicks() % 20000 / 20000.0;
glutil::Color c(glmath::rotate(2.0 * M_PI * anim, glmath::Vec3(1.0, 1.0, 1.0)));
theme->bg.draw();
}
+ glerror.check("bg");
if (m_menu.current().image) m_menu.current().image->draw();
// Comment
theme->comment_bg.dimensions.center().screenBottom(-0.01);
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 79d5e80..2829abe 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -138,6 +138,7 @@ void Window::updateStereo(float sepFactor) {
}
void Window::render(boost::function<void (void)> drawFunc) {
+ glutil::GLErrorChecker glerror("Window::render");
if (s_width < screen->w || s_height < screen->h) glClear(GL_COLOR_BUFFER_BIT); // Black bars
bool stereo = config["graphic/stereo3d"].b();
int type = config["graphic/stereo3dtype"].i();
@@ -147,12 +148,14 @@ void Window::render(boost::function<void (void)> drawFunc) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
updateStereo(stereo ? getSeparation() : 0.0);
+ glerror.check("setup");
// Can we do direct to framebuffer rendering (no FBO)?
if (!stereo || type == 2) { view(stereo); drawFunc(); return; }
// Render both eyes to FBO (full resolution top/bottom)
unsigned w = s_width;
unsigned h = 2 * s_height;
FBO fbo(w, h);
+ glerror.check("FBO");
{
UseFBO user(fbo);
view(0);
@@ -160,12 +163,14 @@ void Window::render(boost::function<void (void)> drawFunc) {
glViewportIndexedf(1, 0, 0, w, h / 2);
drawFunc();
}
+ glerror.check("Render to FBO");
// Render to actual framebuffer from FBOs
UseTexture use(fbo.getTexture());
view(0); // Viewport for drawable area
glDisable(GL_BLEND);
glmath::Matrix colorMatrix;
updateStereo(0.0); // Disable stereo mode while we composite
+ glerror.check("FBO->FB setup");
for (int num = 0; num < 2; ++num) {
{
float saturation = 0.6; // (0..1)
@@ -195,9 +200,11 @@ void Window::render(boost::function<void (void)> drawFunc) {
dim.center((num == 0 ? 0.25 : -0.25) * dim.h());
fbo.getTexture().draw(dim, TexCoords(0.0, h, w, 0));
}
+ glerror.check("FBO->FB postcondition");
}
void Window::view(unsigned num) {
+ glutil::GLErrorChecker glerror("Window::view");
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
|