From 5d56e993a8a959b578578b2f22ebcd93299ae85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 12 Sep 2011 00:11:39 +0200 Subject: [PATCH] Bind default Vertex Array Object on initialization. According to OpenGL specifications no default VAO is bound automatically, so without that it shouldn't work. The reason why it was working for me on NVidia was a driver bug, which is now fixed in recent drivers (280.xx, maybe) if using Core OpenGL. --- src/Scene.cpp | 9 +++++++++ src/Scene.h | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Scene.cpp b/src/Scene.cpp index 70a184b93..8c15d2f80 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -19,6 +19,15 @@ using namespace std; namespace Magnum { +Scene::Scene(): Object(0), _features(0), _camera(0) { + _parent = this; + setClearColor(0.1f, 0.1f, 0.1f, 1.0f); + + /* Bind default VAO */ + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); +} + void Scene::setFeature(Scene::Feature feature, bool enabled) { GLenum _feature; switch(feature) { diff --git a/src/Scene.h b/src/Scene.h index 3ff89f89d..1ee1677aa 100644 --- a/src/Scene.h +++ b/src/Scene.h @@ -43,10 +43,7 @@ class Scene: public Object { }; /** @brief Constructor */ - inline Scene(): Object(0), _features(0), _camera(0) { - _parent = this; - setClearColor(0.1f, 0.1f, 0.1f, 1.0f); - } + Scene(); /** @brief Clear color */ inline Vector4 clearColor() const { return _clearColor; } @@ -96,6 +93,7 @@ class Scene: public Object { unsigned int _features; Vector4 _clearColor; Camera* _camera; + GLuint vao; unsigned int viewportWidth, viewportHeight;