https://github.com/evanw/gl4
A small library for working with OpenGL 4
https://github.com/evanw/gl4
Last synced: 3 months ago
JSON representation
A small library for working with OpenGL 4
- Host: GitHub
- URL: https://github.com/evanw/gl4
- Owner: evanw
- License: cc0-1.0
- Created: 2012-02-16T18:59:54.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-07-23T17:58:39.000Z (almost 9 years ago)
- Last Synced: 2025-03-17T12:02:06.957Z (3 months ago)
- Language: C++
- Homepage:
- Size: 37.1 KB
- Stars: 34
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Introduction
This library provides simple wrappers around some OpenGL 4 functionality. It was created for the [Advanced GPU Programming](http://cs.brown.edu/courses/cs195v/) course at Brown University.## Example
#include
#include "gl4.h"Shader shader;
Buffer quad;
VAO layout;void setup() {
shader.vertexShader(glsl(
in vec2 vertex;
out vec2 coord;
void main() {
coord = vertex * 0.5 + 0.5;
gl_Position = vec4(vertex, 0.0, 1.0);
}
)).fragmentShader(glsl(
in vec2 coord;
out vec4 color;
void main() {
color = vec4(coord, 0.0, 1.0);
}
)).link();quad << vec2(-1, -1) << vec2(1, -1) << vec2(-1, 1) << vec2(1, 1);
quad.upload();
layout.create(shader, quad).attribute("vertex", 2).check();
}void draw() {
glClear(GL_COLOR_BUFFER_BIT);
shader.use();
layout.draw(GL_TRIANGLE_STRIP);
shader.unuse();
glutSwapBuffers();
}int main(int argc, char *argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("Example");
glutReshapeWindow(800, 600);
glutDisplayFunc(draw);
setup();
glutMainLoop();
return 0;
}