26 #include <glad/glad.h> 38 "attribute vec2 vPos;\n" 39 "varying vec2 texcoord;\n" 42 " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" 48 "uniform sampler2D texture;\n" 49 "uniform vec3 color;\n" 50 "varying vec2 texcoord;\n" 53 " gl_FragColor = vec4(color * texture2D(texture, texcoord).rgb, 1.0);\n" 66 fprintf(stderr,
"Error: %s\n", description);
75 int main(
int argc,
char** argv)
79 GLint mvp_location, vpos_location, color_location, texture_location;
113 GLuint vertex_shader, fragment_shader;
120 for (y = 0; y < 16; y++)
122 for (x = 0; x < 16; x++)
123 pixels[y * 16 + x] = rand() % 256;
209 for (i = 0; i < 2; i++)
#define GL_TEXTURE_MAG_FILTER
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
static const vec2 vertices[4]
static void error_callback(int error, const char *description)
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)
#define GLFW_CONTEXT_VERSION_MAJOR
Context client API major version hint and attribute.
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
#define glUniformMatrix4fv
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define glVertexAttribPointer
#define glEnableVertexAttribArray
GLbitfield GLuint program
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
#define GL_TEXTURE_MIN_FILTER
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow *window, int *left, int *top, int *right, int *bottom)
Retrieves the size of the frame of the window.
static const char * fragment_shader_text
static const char * vertex_shader_text
#define glGetUniformLocation
#define GL_FRAGMENT_SHADER
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
GLFWAPI void glfwSetWindowPos(GLFWwindow *window, int xpos, int ypos)
Sets the position of the client area of the specified window.
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI void glfwWaitEvents(void)
Waits until events are queued and processes them.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
GLFWAPI void glfwGetWindowPos(GLFWwindow *window, int *xpos, int *ypos)
Retrieves the position of the client area of the specified window.
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
int main(int argc, char **argv)
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.