daily update on 20240226 by nitload youmu
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#include "gl.h"
|
||||
#include "glfw3.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
GladGLContext* currentContext;
|
||||
|
||||
void processInput(GLFWwindow* window);
|
||||
void FrameBufferSizeCallback(int x, int y, int height, int width);
|
||||
|
||||
int main()
|
||||
{
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(
|
||||
800, 600, "Test Context", NULL, NULL
|
||||
);
|
||||
if (window == NULL)
|
||||
{
|
||||
printf("Fatal error: failed to create glfw window.");
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%llu\n", (uint64_t)window);
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
currentContext = calloc(sizeof(GladGLContext));
|
||||
|
||||
PFNGLCLEARCOLORPROC glClearColor = (PFNGLCLEARCOLORPROC)glfwGetProcAddress("glClearColor");
|
||||
PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)glfwGetProcAddress("glClear");
|
||||
|
||||
printf("%llu\n", (uint64_t)glClearColor);
|
||||
printf("%llu\n", (uint64_t)glClear);
|
||||
|
||||
/*
|
||||
if (gladLoadGLContext(currentContext, (GLADloadfunc)glfwGetProcAddress))
|
||||
{
|
||||
printf("Fatal error: failed in loading OpenGL function.");
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
/**/
|
||||
|
||||
glfwSetFramebufferSizeCallback(window, FrameBufferSizeCallback);
|
||||
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
processInput(window);
|
||||
|
||||
glClearColor(0.9f, 0.3f, 0.9f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT /* | GLFW_DEPTH_BITS /**/);
|
||||
|
||||
//printf("%llu", (uint64_t)currentContext->Clear);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
|
||||
void FrameBufferSizeCallback(int x, int y, int height, int width)
|
||||
{
|
||||
currentContext->Viewport(0, 0, height, width);
|
||||
}
|
||||
Reference in New Issue
Block a user