begin creating a simple program

This commit is contained in:
Josh Holtrop 2015-06-11 19:32:47 -04:00
parent bf2052cdb7
commit 4452a8c1ff
3 changed files with 20 additions and 1 deletions

4
test/frag.glsl Normal file
View File

@ -0,0 +1,4 @@
void main(void)
{
gl_FragColor = vec4(0.5, 0.1, 0.9, 1.0);
}

View File

@ -17,6 +17,9 @@ bool init(void)
glClearColor (0.0, 0.0, 0.0, 0.0);
try
{
vs = make_shared<glcxx::Shader>();
fs = make_shared<glcxx::Shader>();
program = make_shared<glcxx::Program>();
vs->create_from_file(GL_VERTEX_SHADER, "test/vert.glsl");
fs->create_from_file(GL_FRAGMENT_SHADER, "test/frag.glsl");
program->create(vs, fs);
@ -58,7 +61,13 @@ int main(int argc, char *argv[])
return 2;
}
SDL_GL_CreateContext(window);
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
if (gl_context == NULL)
{
cerr << "Failed to create OpenGL context" << endl;
return 1;
}
SDL_GL_MakeCurrent(window, gl_context);
if (gl3wInit())
{

6
test/vert.glsl Normal file
View File

@ -0,0 +1,6 @@
attribute vec2 position;
void main(void)
{
gl_Position = vec4(position, 0, 1);
}