- OBJ file reading
- VBO memory management - Lighting
This commit is contained in:
23
shaders.hh
23
shaders.hh
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user