#include <GL/glx.h>
#include <SDL3/SDL.h>
#include <iostream>
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
typedef void (*GL_CLEARCOLOR_F)(GLfloat, GLfloat, GLfloat, GLfloat);
typedef void (*GL_CLEAR_F)(GLbitfield);
typedef void (*GL_VIEWPORT_F)(GLint, GLint, GLsizei, GLsizei);
int main()
{
GL_CLEARCOLOR_F glClearColor = (GL_CLEARCOLOR_F)glXGetProcAddress((const GLubyte*)"glClearColor");
GL_CLEAR_F glClear = (GL_CLEAR_F)glXGetProcAddress((const GLubyte*)"glCLear");
GL_VIEWPORT_F glViewport = (GL_VIEWPORT_F)glXGetProcAddress((const GLubyte*)"glViewport");
if (!SDL_Init(SDL_INIT_VIDEO))
std::cout << "Can't init SDL: " << SDL_GetError() << std::endl;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Window* window = SDL_CreateWindow("Test", SCR_WIDTH, SCR_HEIGHT, SDL_WINDOW_OPENGL);
if (!window)
std::cout << "Can't create window: " << SDL_GetError() << std::endl;
SDL_GLContext context = SDL_GL_CreateContext(window);
if (!context)
std::cout << "Can't create context: " << SDL_GetError() << std::endl;
SDL_GL_SetSwapInterval(1);
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
bool shouldQuit = false;
SDL_Event event;
while (!shouldQuit)
{
while (SDL_PollEvent(&event))
if (event.type == SDL_EVENT_QUIT)
shouldQuit = true;
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
}
SDL_GL_DestroyContext(context);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}