diff options
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/gl/notes.md | 10 | ||||
| -rw-r--r-- | src/gl/window.c | 9 | ||||
| -rw-r--r-- | src/gl/window.test.c | 45 | ||||
| -rw-r--r-- | src/test/honey-test.h | 4 | 
5 files changed, 68 insertions, 1 deletions
| diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b37672..bdd1832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ set(TEST_SOURCES  	${SRC_ROOT}/test/honey-test.c  	${SRC_ROOT}/logging/logging.test.c +	${SRC_ROOT}/gl/window.test.c  )  add_executable(test EXCLUDE_FROM_ALL ${TEST_SOURCES}) diff --git a/src/gl/notes.md b/src/gl/notes.md new file mode 100644 index 0000000..3ea0171 --- /dev/null +++ b/src/gl/notes.md @@ -0,0 +1,10 @@ +honey/gl +-------- + +only support 1 window, for simplicity + +want to be **as transparent as possible**! only hide things from the Lua layer when they are either performance-critical or when they are so C-level that wrapping them would be too clunky. + +**lua setup functions should do nothing except populate tables** + +`gl.init()` will create the window (because that's how we get the opengl context) diff --git a/src/gl/window.c b/src/gl/window.c new file mode 100644 index 0000000..c81c041 --- /dev/null +++ b/src/gl/window.c @@ -0,0 +1,9 @@ +#include "gl/glad/glad.h" +#include <GLFW/glfw3.h> +#include <lua.h> + + +int gl_init(lua_State *L) +{ +	return 0; +} diff --git a/src/gl/window.test.c b/src/gl/window.test.c new file mode 100644 index 0000000..0dc255b --- /dev/null +++ b/src/gl/window.test.c @@ -0,0 +1,45 @@ +#include <lua.h> +#include <lauxlib.h> +#include "test/honey-test.h" + +int mock_glfwInit(); +#define glfwInit mock_glfwInit +#include "gl/window.c" +#undef glfwInit + + +lily_mock_t *mock_glfwInit_data = NULL; +int mock_glfwInit() +{ +	lily_mock_call(mock_glfwInit_data, NULL); + +	int result; +	lily_dequeue(mock_glfwInit_data->values, int, &result); +	return result; +} + + +void gl_init_succeeds(); + +void suite_window() +{ +	lily_run_test(gl_init_succeeds); + +	CLEAN_MOCK(mock_glfwInit); +} + + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + + +void gl_init_succeeds() +{ +	USE_MOCK(mock_glfwInit); +	lua_State *L = luaL_newstate(); +	 +	lua_pushcfunction(L, gl_init); +	int error = lua_pcall(L, 0, 0, 0); + +	lily_assert_int_equal(error, 0); +	lily_assert_int_equal(mock_glfwInit_data->n_calls, 1); +} diff --git a/src/test/honey-test.h b/src/test/honey-test.h index ac79d8a..a31bcff 100644 --- a/src/test/honey-test.h +++ b/src/test/honey-test.h @@ -23,8 +23,10 @@  void suite_logging(); +void suite_window();  #define RUN_TESTS() \ -	lily_run_suite(suite_logging); +	lily_run_suite(suite_logging); \ +	lily_run_suite(suite_window); \  #endif | 
