#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
if (!glfwInit())
return -1;
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window) {
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window)) {
/* Render here */
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
VS
#include <GL3/gl3.h>
#include <SDL.h>
/* Our program's entry point */
int main(int argc, char *argv[])
{
SDL_Window *mainwindow;
SDL_GLContext maincontext;
SDL_Event event;
int running = 1;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
exit(1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!mainwindow)
exit(1);
maincontext = SDL_GL_CreateContext(mainwindow);
SDL_GL_SetSwapInterval(1);
while (running) {
while (SDL_PollEvent(&event) {
if ( event == SDL_WINDOWEVENT_CLOSE ) {
running = 0;
break;
}
/* render */
}
SDL_GL_SwapWindow(mainwindow);
}
SDL_GL_DeleteContext(maincontext);
SDL_DestroyWindow(mainwindow);
SDL_Quit();
return 0;
}
It's got SDL beat a bit in simplicity for OpenGL, sorry dude.