20 void GLAPIENTRY
MessageCallback(GLenum source,GLenum type,GLuint
id,GLenum severity,GLsizei length,
const GLchar* message,
const void* userParam){
21 if(type==GL_DEBUG_TYPE_ERROR)
22 fprintf(stderr,
"[[GL ERROR]] Type: 0x%x Severity: 0x%x Message: %s\n",type,severity,message);
26 glViewport(0,0,width,height);
30 SceneFramebufferUpdate=
true;
45 printf(
"Framebuffer resized to %dx%d\n",width,height);
50 fprintf(stderr,
"Error: %s\n", description);
54 glfwGetCursorPos(
Window,x,y);
60 static double last_time=0.0;
61 double current_time=glfwGetTime();
62 if(current_time-last_time>=0.5){
63 last_time=current_time;
68 0.5f).second,0.5f,1'000'000,
Vec3(1.0f,1.0f,1.0f));
73 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,4);
74 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,6);
75 glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE);
77 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_TRUE);
79 glfwWindowHint(GLFW_RESIZABLE,resizable);
83 perror(
"Failed to create GLFW WINDOW\n");
88 glfwMakeContextCurrent(
Window);
91 if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)){
92 perror(
"Failed to initialize GLAD\n");
100 glEnable(GL_DEBUG_OUTPUT);
104 printf(
"%s\n%s\n",(
char *)glGetString(GL_VERSION),(
char *)glGetString(GL_RENDERER));
130 const GLFWvidmode* modes=glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);
132 printf(
"Available modes:\n");
133 for(
int i=0;
i<count;
i++){
134 printf(
"%d: %dx%d @ %dHz\n",
i,modes[
i].width,modes[
i].height,modes[
i].refreshRate);
150 glfwWindowHint(GLFW_RESIZABLE,resizable);
155 while(*line<
'0' || *line>
'9')
157 while(*line>=
'0'&&*line<=
'9'){
170 FILE *file=fopen(
"/proc/meminfo",
"r");
174 while(fgets(line,128,file)!=NULL){
175 if(strncmp(line,value,strlen(value))==0){
190 FILE *file=fopen(
"/proc/self/status",
"r");
194 while(fgets(line,128,file)!=NULL){
195 if(strncmp(line,value,strlen(value))==0){
205 float totalMem=
static_cast<float>(
getMemInfoValue(
"MemTotal"))/1024.0f;
206 float availableMem=
static_cast<float>(
getMemInfoValue(
"MemAvailable"))/1024.0f;
209 float residentMem=
static_cast<float>(
getStatusValue(
"VmRSS"))/1024.0f;
210 printf(
"RAM: %.2f/%.2f MB\n",totalMem-availableMem,totalMem);
212 printf(
"Resident Memory: %.2f MB\n",residentMem);
222 return glfwGetMouseButton(
Window,button)==state;
245 bool SceneFramebufferUpdate=
false;
void SetPointSize(float new_size)
void SetLineWidth(float new_size)
RendererData * GetLightsData()
void SetUniform1f(const std::string &name, float v0)
std::pair< float, float > GetTextSize(std::string text, float scale)
void DrawText(const std::string &text, float x, float y, float scale, int layer, Vec3 color)
void GetMousePos(double *x, double *y)
bool GetMouseButtonState(int button, int state)
int getStatusValue(const char *value)
void GLAPIENTRY FramebufferSizeCallback(GLFWwindow *window, int width, int height)
bool GetKeyState(int key, int state)
void GLAPIENTRY ErrorCallback(int error, const char *description)
int parseLine(char *line)
int InitGlfwWindow(const char *window_name, bool resizable)
void SetResizable(bool resizable)
void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
int getMemInfoValue(const char *value)
TexturesManager * TEXTURES_MANAGER
The textures manager.
FontManager * FONT_MANAGER
The font manager.
Renderer * RENDERER
The main renderer.
TextRenderer * TEXT_RENDERER
The text renderers.
TextQueue * TEXT_QUEUE
The text queue.
Input * INPUT
The input manager.
TexturesManager * TEXTURES_MANAGER
The textures manager.
FontManager * FONT_MANAGER
The font manager.
Renderer * RENDERER
The main renderer.
TextRenderer * TEXT_RENDERER
The text renderers.
TextQueue * TEXT_QUEUE
The text queue.
Input * INPUT
The input manager.