mirror of
https://github.com/pevans/erc-c.git
synced 2024-08-21 00:29:00 +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:
parent
b646bfc511
commit
8beb761535
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user