Remove own gl classes

This commit is contained in:
hodasemi 2018-05-31 21:12:41 +02:00
parent be92b31d04
commit 9f318216e0
5 changed files with 1 additions and 169 deletions

View file

@ -84,7 +84,6 @@ void Bone::calculate_matrices()
}
else
{
float angle = calc_angle(curr_dir, prev_dir);
Vec3 axis = cross(curr_dir, prev_dir);

View file

@ -1,32 +0,0 @@
#ifndef BUFFER
#define BUFFER
#include <vector>
#include <GL/gl.h>
template <class T>
unsigned int sizevec(const std::vector<T> &p_vec) { return sizeof(T) * p_vec.size(); }
class Buffer
{
public:
Buffer()
{
glGenBuffers(1, &m_vbo);
}
~Buffer()
{
glDeleteBuffers(1, &m_vbo);
}
GLuint getBuffer()
{
return m_vbo;
}
private:
GLuint m_vbo;
};
#endif // BUFFER

View file

@ -1,133 +0,0 @@
#ifndef PROGRAM
#define PROGRAM
#include <fstream>
#include <iostream>
#include <string>
#include <GL/gl.h>
class Program
{
public:
Program()
{
}
~Program()
{
glDeleteProgram(m_prog);
}
void createProgram(const char *vs, const char *fs)
{
GLuint vert = createShader(vs, GL_VERTEX_SHADER);
GLuint frag = createShader(fs, GL_FRAGMENT_SHADER);
if ((vert == 0) || (frag == 0))
{
return;
}
m_prog = glCreateProgram();
glAttachShader(m_prog, vert);
glAttachShader(m_prog, frag);
glLinkProgram(m_prog);
glDeleteShader(vert);
glDeleteShader(frag);
}
void createProgram(const char *vs, const char *gs, const char *fs)
{
GLuint vert = createShader(vs, GL_VERTEX_SHADER);
GLuint geom = createShader(gs, GL_GEOMETRY_SHADER);
GLuint frag = createShader(fs, GL_FRAGMENT_SHADER);
if ((vert == 0) || (frag == 0) || (geom == 0))
{
return;
}
m_prog = glCreateProgram();
glAttachShader(m_prog, vert);
glAttachShader(m_prog, geom);
glAttachShader(m_prog, frag);
glLinkProgram(m_prog);
glDeleteShader(vert);
glDeleteShader(geom);
glDeleteShader(frag);
}
void createProgram(const std::string vs, const std::string fs)
{
createProgram(vs.c_str(), fs.c_str());
}
GLuint getProgram()
{
return m_prog;
}
private:
inline std::string loadShaderText(const char *path)
{
std::ifstream is(path);
std::string s_save;
if (is.is_open())
{
s_save.assign(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>());
is.close();
}
else
{
std::cout << "could not open " << path << std::endl;
}
return s_save;
}
inline GLuint createShader(const char *path, GLenum shadertype)
{
std::string s_source = loadShaderText(path);
if (s_source.empty())
{
return 0;
}
const char *c_source = s_source.c_str();
GLuint shader = glCreateShader(shadertype);
glShaderSource(shader, 1, (const char **)&c_source, NULL);
glCompileShader(shader);
GLint shaderCompiled = GL_FALSE;
glGetShaderiv(shader, GL_COMPILE_STATUS, &shaderCompiled);
if (shaderCompiled != GL_TRUE)
{
GLint log_length = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
char *log = new char[log_length];
glGetShaderInfoLog(shader, (GLsizei)log_length, NULL, log);
std::cout << "error compiling shader( " << path << " ): " << std::endl
<< log << std::endl;
delete[] log;
glDeleteShader(shader);
shader = 0;
}
return shader;
}
GLuint m_prog;
};
#endif // PROGRAM

View file

@ -12,6 +12,7 @@
#include <cgv/base/find_action.h>
#include "math_helper.h"
#include <fstream>
using namespace cgv::utils;

View file

@ -7,9 +7,6 @@
#include "common.h"
#include "DataStore.h"
#include "GLClasses/buffer.h"
#include "GLClasses/program.h"
#include <cgv/gui/trigger.h>
#include <cgv/gui/provider.h>
#include <cgv/gui/event_handler.h>