26 #include <glad/glad.h> 30 #define GLFW_EXPOSE_NATIVE_OSMESA 39 #define STB_IMAGE_WRITE_IMPLEMENTATION 40 #include <stb_image_write.h> 48 { -0.6f, -0.4f, 1.f, 0.f, 0.f },
49 { 0.6f, -0.4f, 0.f, 1.f, 0.f },
50 { 0.f, 0.6f, 0.f, 0.f, 1.f }
56 "attribute vec3 vCol;\n" 57 "attribute vec2 vPos;\n" 58 "varying vec3 color;\n" 61 " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" 67 "varying vec3 color;\n" 70 " gl_FragColor = vec4(color, 1.0);\n" 75 fprintf(stderr,
"Error: %s\n", description);
81 GLuint vertex_buffer, vertex_shader, fragment_shader,
program;
82 GLint mvp_location, vpos_location, vcol_location;
137 sizeof(
vertices[0]), (
void*) (
sizeof(
float) * 2));
140 ratio = width / (float) height;
151 #if USE_NATIVE_OSMESA 154 buffer = calloc(4, width * height);
161 buffer + (width * 4 * (height - 1)),
164 #if USE_NATIVE_OSMESA
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
static void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)
#define glGetAttribLocation
void *(* GLADloadproc)(const char *name)
static GLFWwindow * window
#define GLFW_CONTEXT_VERSION_MAJOR
Context client API major version hint and attribute.
#define GLFW_COCOA_MENUBAR
macOS specific init hint.
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
#define glUniformMatrix4fv
GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow *handle, int *width, int *height, int *format, void **buffer)
static void error_callback(int error, const char *description)
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define glVertexAttribPointer
#define glEnableVertexAttribArray
#define GL_COLOR_BUFFER_BIT
GLbitfield GLuint program
GLint GLsizei GLsizei height
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
#define glGetUniformLocation
#define GL_FRAGMENT_SHADER
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
The header of the native access functions.
static const struct @18 vertices[3]
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
static const char * vertex_shader_text
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
#define GLFW_VISIBLE
Window visibility window hint and attribute.
static const char * fragment_shader_text
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI void glfwInitHint(int hint, int value)
Sets the specified init hint to the desired value.