mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-21 08:30:55 +00:00
Add glew, defines for width/height
This commit is contained in:
parent
a73c15c37c
commit
83dcfaf646
@ -27,4 +27,4 @@ link_directories(/usr/local/lib)
|
||||
add_executable(erc ${sources} src/main.c)
|
||||
|
||||
# Graphics
|
||||
target_link_libraries(erc ${opengl_library} glfw)
|
||||
target_link_libraries(erc ${opengl_library} glfw GLEW)
|
||||
|
@ -1,9 +1,13 @@
|
||||
#ifndef _VM_SCREEN_H_
|
||||
#define _VM_SCREEN_H_
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define VM_SCREEN_DEFWIDTH 800
|
||||
#define VM_SCREEN_DEFHEIGHT 600
|
||||
|
||||
/*
|
||||
* If you just want to plot a single pixel, you can use this macro to
|
||||
* abstract away the need to indicate the x/y dimensions (as those must
|
||||
|
@ -6,11 +6,25 @@
|
||||
* program, which only knows to call the functions here.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "vm_screen.h"
|
||||
|
||||
static bool init_glew = false;
|
||||
|
||||
static void
|
||||
glew_init()
|
||||
{
|
||||
if (!init_glew) {
|
||||
glewExperimental = GL_TRUE;
|
||||
glewInit();
|
||||
|
||||
init_glew = true;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
vm_screen_init()
|
||||
{
|
||||
@ -18,6 +32,13 @@ vm_screen_init()
|
||||
return ERR_GFXINIT;
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -48,7 +69,10 @@ vm_screen_create()
|
||||
int
|
||||
vm_screen_add_window(vm_screen *screen)
|
||||
{
|
||||
screen->window = glfwCreateWindow(320, 240, "erc", NULL, NULL);
|
||||
screen->window = glfwCreateWindow(VM_SCREEN_DEFWIDTH,
|
||||
VM_SCREEN_DEFHEIGHT,
|
||||
"erc", NULL, NULL);
|
||||
|
||||
if (screen->window == NULL) {
|
||||
log_critical("Could not create a window");
|
||||
return ERR_GFXINIT;
|
||||
@ -56,6 +80,10 @@ vm_screen_add_window(vm_screen *screen)
|
||||
|
||||
glfwMakeContextCurrent(screen->window);
|
||||
|
||||
// glew can only be initialized _after_ the window is built; if you
|
||||
// do so beforehand, you will be rudely presented with a segfault.
|
||||
glew_init();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user