https://github.com/evanw/gl
A small C++ library for working with OpenGL
https://github.com/evanw/gl
Last synced: about 2 months ago
JSON representation
A small C++ library for working with OpenGL
- Host: GitHub
- URL: https://github.com/evanw/gl
- Owner: evanw
- Created: 2013-07-05T02:19:38.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-05T02:29:45.000Z (almost 12 years ago)
- Last Synced: 2025-04-11T00:12:41.728Z (about 2 months ago)
- Language: C++
- Size: 98.6 KB
- Stars: 24
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Introduction
This library provides simple C++ wrappers around some OpenGL functionality. It was modified from an [OpenGL 4 library](https://github.com/evanw/gl4) created for the [Advanced GPU Programming](http://cs.brown.edu/courses/cs195v/) course at Brown University.
## Example
#ifdef __APPLE_CC__
#include
#else
#include
#endif
#include "gl.h"Shader shader;
Buffer quad;
VAO layout;void setup() {
shader.vertexShader(glsl(
attribute vec2 vertex;
varying vec2 coord;
void main() {
coord = vertex * 0.5 + 0.5;
gl_Position = vec4(vertex, 0.0, 1.0);
}
)).fragmentShader(glsl(
varying vec2 coord;
void main() {
gl_FragColor = 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;
}