1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-25 03:32:22 +00:00

Actually show a window.

This is also the beginning outline of how we want to abstract graphics
away in erc.
This commit is contained in:
Peter Evans 2017-12-16 23:38:59 -06:00
parent b646bfc511
commit 8beb761535
5 changed files with 32 additions and 3 deletions

View File

@ -5,6 +5,14 @@ project(erc)
include(sources.cmake)
if(APPLE)
set(opengl_library /System/Library/Frameworks/OpenGL.framework)
endif()
if(NOT opengl_library)
message(FATAL_ERROR "This CMake file is not yet educated as to where OpenGL resides on your platform. Sorry!")
endif()
foreach(src ${erc_sources})
string(CONCAT relsrc src/ ${src})
list(APPEND sources ${relsrc})
@ -19,4 +27,4 @@ link_directories(/usr/local/lib)
add_executable(erc ${sources} src/main.c)
# Graphics
target_link_libraries(erc glfw)
target_link_libraries(erc ${opengl_library} glfw)

View File

@ -27,6 +27,8 @@ typedef struct {
extern int vm_screen_add_window(vm_screen_context *);
extern int vm_screen_init();
extern void vm_screen_finish();
extern void vm_screen_refresh(vm_screen_context *);
extern bool vm_screen_active(vm_screen_context *);
extern void vm_screen_draw_rect(vm_screen_context *, int, int, int, int);
extern void vm_screen_free_context(vm_screen_context *);
extern vm_screen_context *vm_screen_new_context();

View File

@ -105,7 +105,8 @@ main(int argc, char **argv)
exit(1);
}
for (;;) {
while (vm_screen_active(context)) {
vm_screen_refresh(context);
}
// ha ha ha ha #nervous #laughter

View File

@ -74,6 +74,16 @@ vm_screen_active(vm_screen_context *context)
return !glfwWindowShouldClose(context->window);
}
void
vm_screen_refresh(vm_screen_context *context)
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(context->window);
glfwPollEvents();
}
/*
* Set the color of a screen context to a given RGBA value.
*/

View File

@ -4,6 +4,14 @@ project(erc-test)
set(CMAKE_BUILD_TYPE Debug)
if(APPLE)
set(opengl_library /System/Library/Frameworks/OpenGL.framework)
endif()
if(NOT opengl_library)
message(FATAL_ERROR "This CMake file is not yet educated as to where OpenGL resides on your platform. Sorry!")
endif()
include_directories(../include /usr/local/include)
link_directories(/usr/local/lib)
@ -25,4 +33,4 @@ add_executable(erc-test ${sources} ${test_sources})
target_link_libraries(erc-test criterion)
# Graphics
target_link_libraries(erc-test glfw)
target_link_libraries(erc-test ${opengl_library} glfw)