begin on GLProgram
This commit is contained in:
parent
bf15a702ab
commit
6aef5dab75
@ -1,27 +1,47 @@
|
||||
#if 0
|
||||
#include "GLProgram.h"
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include "ruby.h"
|
||||
#include "gl3w.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
GLProgram::GLProgram()
|
||||
typedef struct
|
||||
{
|
||||
m_id = glCreateProgram();
|
||||
if (m_id == 0u)
|
||||
GLuint id;
|
||||
} GLProgram;
|
||||
|
||||
static VALUE ruby_class;
|
||||
|
||||
static void GLProgram_free(void * ptr)
|
||||
{
|
||||
GLProgram * program = (GLProgram *)ptr;
|
||||
|
||||
if (program->id > 0u)
|
||||
{
|
||||
cerr << "Error allocating GL program object" << endl;
|
||||
glDeleteProgram(program->id);
|
||||
}
|
||||
|
||||
delete program;
|
||||
}
|
||||
|
||||
GLProgram::~GLProgram()
|
||||
static VALUE GLProgram_new(VALUE klass)
|
||||
{
|
||||
if (m_id > 0u)
|
||||
GLProgram * glprogram = new GLProgram();
|
||||
|
||||
glprogram->id = glCreateProgram();
|
||||
if (glprogram->id == 0u)
|
||||
{
|
||||
glDeleteProgram(m_id);
|
||||
rb_raise(rb_eRuntimeError, "Error allocating GL program object");
|
||||
}
|
||||
|
||||
return Data_Wrap_Struct(klass, NULL, GLProgram_free, glprogram);
|
||||
}
|
||||
|
||||
void GLProgram_Init()
|
||||
{
|
||||
ruby_class = rb_define_class("GLProgram", rb_cObject);
|
||||
rb_define_singleton_method(ruby_class, "new", (VALUE(*)(...))GLProgram_new, 0);
|
||||
rb_define_attr(ruby_class, "id", 0, 1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
GLProgram & GLProgram::attach_shader(GLShaderRef shader)
|
||||
{
|
||||
if (m_id > 0u)
|
||||
|
@ -1,29 +1,6 @@
|
||||
#if 0
|
||||
#ifndef GLPROGRAM_H
|
||||
#define GLPROGRAM_H
|
||||
|
||||
#include "Ref.h"
|
||||
#include "GLShader.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class GLProgram
|
||||
{
|
||||
public:
|
||||
GLProgram();
|
||||
~GLProgram();
|
||||
GLProgram & attach_shader(GLShaderRef shader);
|
||||
GLProgram & bind_attribute(const char * attribute, GLuint index);
|
||||
bool link();
|
||||
GLuint get_id() { return m_id; }
|
||||
void use() { glUseProgram(m_id); }
|
||||
GLint get_uniform(const std::string & uniform_name);
|
||||
protected:
|
||||
GLuint m_id;
|
||||
std::map<std::string, GLint> m_uniforms;
|
||||
};
|
||||
typedef Ref<GLProgram> GLProgramRef;
|
||||
void GLProgram_Init();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <iostream>
|
||||
#include "ruby.h"
|
||||
#include "Window.h"
|
||||
#include "GLShader.h"
|
||||
#include "GLProgram.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -47,7 +49,11 @@ static int bootstrap()
|
||||
{
|
||||
int rv = 0;
|
||||
int err_state = 0;
|
||||
|
||||
Window_Init();
|
||||
GLShader_Init();
|
||||
GLProgram_Init();
|
||||
|
||||
rb_eval_string_protect(
|
||||
"load File.expand_path('../../runtime/main.rb', $0)",
|
||||
&err_state);
|
||||
|
Loading…
x
Reference in New Issue
Block a user