- OBJ file reading

- VBO memory management
- Lighting
This commit is contained in:
2014-11-17 18:19:46 +01:00
parent ba8e07aa4e
commit 5f388a1723
16 changed files with 578 additions and 135 deletions

View File

@@ -4,11 +4,12 @@
#include <string>
#include <unordered_map>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <glbinding/gl/gl.h>
#include "common.hh"
using namespace gl;
class ShaderException : public GLException {
public:
ShaderException(std::string const& msg) : GLException(glGetError()), _msg(msg) {
@@ -169,27 +170,25 @@ public:
glUseProgram(_progID);
}
int getUniformLocation(std::string const& name) const {
GLint getUniformLocation(std::string const& name) const {
auto search = _uniformLocCache.find(name);
if (search != _uniformLocCache.end())
return search->second;
int ret = glGetUniformLocation(_progID, name.c_str());
if (ret == -1)
throw GLException(glGetError());
_uniformLocCache.emplace(name, ret);
GLint ret = glGetUniformLocation(_progID, name.c_str());
if (ret != -1)
_uniformLocCache.emplace(name, ret);
return ret;
}
int getAttribLocation(std::string const& name) const {
GLint getAttribLocation(std::string const& name) const {
auto search = _attribLocCache.find(name);
if (search != _attribLocCache.end())
return search->second;
int ret = glGetAttribLocation(_progID, name.c_str());
if (ret == -1)
throw GLException(glGetError());
_attribLocCache.emplace(name, ret);
GLint ret = glGetAttribLocation(_progID, name.c_str());
if (ret != -1)
_attribLocCache.emplace(name, ret);
return ret;
}