begin creating a simple program
This commit is contained in:
parent
bf2052cdb7
commit
4452a8c1ff
4
test/frag.glsl
Normal file
4
test/frag.glsl
Normal file
@ -0,0 +1,4 @@
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = vec4(0.5, 0.1, 0.9, 1.0);
|
||||
}
|
@ -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
6
test/vert.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
attribute vec2 position;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = vec4(position, 0, 1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user