start using OGLplus

This commit is contained in:
Josh Holtrop 2015-05-26 23:16:22 -04:00
parent 2e5ac958b7
commit f65ef8554b
2 changed files with 39 additions and 2 deletions

View File

@ -4,7 +4,11 @@ task :default do
Rscons::Environment.new do |env|
env.build_root = "build"
env.parse_flags!("!sdl2-config --cflags --libs")
env["CXXFLAGS"] += %w[-isystem oglplus/include]
env["CXXFLAGS"] += %w[
-isystem oglplus/include
-isystem oglplus/implement
-std=gnu++11
]
env["CPPDEFINES"] += %w[
OGLPLUS_NO_SITE_CONFIG
]

35
main.cc
View File

@ -1,5 +1,8 @@
#include <SDL.h>
#include "oglplus/gl.hpp"
#include <oglplus/gl.hpp>
#include <oglplus/all.hpp>
using namespace oglplus;
#define WIDTH 800
#define HEIGHT 600
@ -54,6 +57,36 @@ int main(int argc, char * argv[])
static void init()
{
VertexShader vs;
FragmentShader fs;
Program program;
VertexArray cube;
Buffer verts;
vs.Source("#version 330\n"
"uniform mat4 projection;\n"
"uniform mat4 modelview;\n"
"in vec4 position;\n"
"in vec3 normal;\n"
"in vec2 texture;\n"
"out vec3 normal_i;\n"
"out vec2 texture_i;\n"
"void main(void)\n"
"{\n"
" normal_i = normal;\n"
" texture_i = texture;\n"
" gl_Position = projection * modelview * position\n"
"}");
vs.Compile();
fs.Source("#version 330\n"
"in vec3 normal_i;\n"
"in vec2 texture_i;\n"
"out vec4 frag_color;\n"
"void main(void)\n"
"{\n"
" frag_color = vec4(texture_i, 1.0, 1.0);\n"
"}");
fs.Compile();
}
static void display(SDL_Window * window)