Bootstrap

使用glew和glfw进行opengl编程

freeglut和glut是很多教程使用的,不过现在glfw明显好多了,还有glew是windows下面使用opengl1.1以上版本api的比较好的办法,更重要的是这两个都是跨平台的,用起来真的是很方便的说,
#define GLEW_STATIC
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

char szTitle[64] = "opengl tutorial 001-color triangle";

static void error_callback(int error, const char* description)
{
    fputs(description, stderr);
}

static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}

int main(void)
{
    GLFWwindow * window;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit()) return -1;
    window = glfwCreateWindow(512,400,szTitle,NULL,NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);

    glfwSetKeyCallback(window, key_c
;