diff options
Diffstat (limited to 'intern/ghost/test')
-rw-r--r-- | intern/ghost/test/CMakeLists.txt | 141 | ||||
-rw-r--r-- | intern/ghost/test/multitest/MultiTest.c | 59 | ||||
-rw-r--r-- | intern/ghost/test/multitest/stubs.c | 29 |
3 files changed, 198 insertions, 31 deletions
diff --git a/intern/ghost/test/CMakeLists.txt b/intern/ghost/test/CMakeLists.txt index f97397715bf..2d97489f657 100644 --- a/intern/ghost/test/CMakeLists.txt +++ b/intern/ghost/test/CMakeLists.txt @@ -1,16 +1,36 @@ +# see "cmake --help-policy CMP0003" +# So library linking is more sane cmake_policy(SET CMP0003 NEW) + +# So BUILDINFO and BLENDERPATH strings are automatically quoted cmake_policy(SET CMP0005 NEW) -cmake_minimum_required(VERSION 2.8) +# So syntax problems are errors +cmake_policy(SET CMP0010 NEW) + +# Input directories must have CMakeLists.txt +cmake_policy(SET CMP0014 NEW) + +cmake_minimum_required(VERSION 3.5) + +project(GhostMultiTest) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../..//build_files/cmake/Modules") set(WITH_GUARDEDALLOC ON) +add_executable(datatoc + "${CMAKE_SOURCE_DIR}/../../../source/blender/datatoc/datatoc.c") + +# Fake the current source dir for includes. +set(_CMAKE_CURRENT_SOURCE_DIR_INIT "${CMAKE_CURRENT_SOURCE_DIR}") + # ----------------------------------------------------------------------------- # Macros +# For data_to_c macro. +# include(../../../build_files/cmake/macros.cmake) # stub macro, does nothing macro(blender_add_lib @@ -18,6 +38,7 @@ macro(blender_add_lib sources includes includes_sys + library_deps # ignored. ) endmacro() @@ -28,10 +49,15 @@ macro(suffix_relpaths set(${new_files}) foreach(_file ${files}) - if(IS_ABSOLUTE _file) + if(IS_ABSOLUTE "${_file}") list(APPEND ${new_files} ${_file}) else() - list(APPEND ${new_files} "${prefix}${_file}") + set(_file_to "${prefix}${_file}") + list(APPEND ${new_files} ${_file_to}) + get_source_file_property(_is_generated ${_file} GENERATED) + set_source_files_properties(${_file_to} PROPERTIES GENERATED ${_is_generated}) + unset(_file_to) + unset(_is_generated) endif() endforeach() unset(_file) @@ -48,11 +74,39 @@ macro(data_to_c add_custom_command( OUTPUT ${file_to} COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} - COMMAND ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/datatoc ${file_from} ${file_to} + COMMAND "$<TARGET_FILE:datatoc>" ${file_from} ${file_to} DEPENDS ${file_from} datatoc) unset(_file_to_path) endmacro() +# same as above but generates the var name and output automatic. +function(data_to_c_simple + file_from + list_to_add + ) + + # remove ../'s + get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} REALPATH) + get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${file_from}.c REALPATH) + + + list(APPEND ${list_to_add} ${_file_to}) + source_group(Generated FILES ${_file_to}) + list(APPEND ${list_to_add} ${file_from}) + set(${list_to_add} ${${list_to_add}} PARENT_SCOPE) + + get_filename_component(_file_to_path ${_file_to} PATH) + + message(OUTPUT " ${_file_to}") + add_custom_command( + OUTPUT ${_file_to} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} + COMMAND "$<TARGET_FILE:datatoc>" ${_file_from} ${_file_to} + DEPENDS ${_file_from} datatoc) + + set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE) +endfunction() + # ----------------------------------------------------------------------------- # Defines @@ -96,6 +150,13 @@ suffix_relpaths(SRC_NEW "${SRC}" "../../string/") include_directories(${INC_NEW}) add_library(string_lib ${SRC_NEW}) +# numaapi (for 'bli_lib') +include(${CMAKE_SOURCE_DIR}/../../numaapi/CMakeLists.txt) +suffix_relpaths(INC_NEW "${INC}" "../../numaapi/") +suffix_relpaths(SRC_NEW "${SRC}" "../../numaapi/") +include_directories(${INC_NEW}) +add_library(numaapi_lib ${SRC_NEW}) + # guardedalloc include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt) suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/") @@ -103,6 +164,25 @@ suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/") include_directories(${INC_NEW}) add_library(guardedalloc_lib ${SRC_NEW}) +# gpu (used by blenfont) +add_definitions(-DGPU_STANDALONE) +set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/gpu") +include(${CMAKE_SOURCE_DIR}/../../../source/blender/gpu/CMakeLists.txt) +suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/gpu/") +suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/gpu/") +include_directories(${INC_NEW}) +add_library(gpu_lib ${SRC_NEW}) +set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}") + +# imbuf (used by ) +# set(CMAKE_CURRENT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf") +# include(${CMAKE_SOURCE_DIR}/../../../source/blender/imbuf/CMakeLists.txt) +# suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/imbuf/") +# suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/imbuf/") +# include_directories(${INC_NEW}) +# add_library(imbuf_lib ${SRC_NEW}) +# set(CMAKE_CURRENT_SOURCE_DIR "${_CMAKE_CURRENT_SOURCE_DIR_INIT}") + # blenfont include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt) suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/") @@ -128,6 +208,10 @@ add_library(glewmx_lib ${SRC_NEW}) include_directories( "../../../source/blender/blenlib" ) + +# Needed for math_matrix.c to avoid eigen_capi.h dep. +add_definitions(-DMATH_STANDALONE) + add_library(bli_lib "../../../source/blender/blenlib/intern/fileops.c" "../../../source/blender/blenlib/intern/gsqueue.c" @@ -136,15 +220,23 @@ add_library(bli_lib "../../../source/blender/blenlib/intern/string_utf8.c" "../../../source/blender/blenlib/intern/listbase.c" "../../../source/blender/blenlib/intern/math_color.c" + "../../../source/blender/blenlib/intern/math_geom.c" + "../../../source/blender/blenlib/intern/math_matrix.c" + "../../../source/blender/blenlib/intern/math_rotation.c" + "../../../source/blender/blenlib/intern/math_vector.c" "../../../source/blender/blenlib/intern/storage.c" "../../../source/blender/blenlib/intern/task.c" "../../../source/blender/blenlib/intern/threads.c" "../../../source/blender/blenlib/intern/time.c" "../../../source/blender/blenlib/intern/path_util.c" "../../../source/blender/blenlib/intern/BLI_dynstr.c" + "../../../source/blender/blenlib/intern/BLI_ghash.c" + "../../../source/blender/blenlib/intern/BLI_ghash_utils.c" "../../../source/blender/blenlib/intern/BLI_linklist.c" "../../../source/blender/blenlib/intern/BLI_memarena.c" "../../../source/blender/blenlib/intern/BLI_mempool.c" + "../../../source/blender/blenlib/intern/hash_mm2a.c" + "../../../source/blender/blenlib/intern/string_utils.c" "../../../source/blender/blenlib/intern/system.c" ) @@ -190,10 +282,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}") # ----------------------------------------------------------------------------- # Executables -# DataToC -add_executable(datatoc - ${CMAKE_SOURCE_DIR}/../../../source/blender/datatoc/datatoc.c) - # Gears (C) add_executable(gears_c ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c) @@ -224,8 +312,11 @@ target_link_libraries(gears_cpp # MultiTest (C) set(data_to_c_files) -data_to_c(${CMAKE_SOURCE_DIR}/../../../release/datafiles/bfont.ttf - ${CMAKE_CURRENT_BINARY_DIR}/bfont.ttf.c data_to_c_files) +data_to_c( + ${CMAKE_SOURCE_DIR}/../../../release/datafiles/bfont.ttf + ${CMAKE_CURRENT_BINARY_DIR}/bfont.ttf.c + data_to_c_files +) add_executable(multitest_c ${CMAKE_SOURCE_DIR}/multitest/Basic.c @@ -240,16 +331,20 @@ add_executable(multitest_c target_link_libraries(multitest_c - blenfont_lib - bli_lib - ghost_lib - glewmx_lib - string_lib - guardedalloc_lib - wcwidth_lib - ${OPENGL_gl_LIBRARY} - ${FREETYPE_LIBRARY} - ${ZLIB_LIBRARIES} - ${CMAKE_DL_LIBS} - ${PLATFORM_LINKLIBS} - ) + blenfont_lib + bli_lib + gpu_lib + # imbuf_lib + ghost_lib + bli_lib # again... + glewmx_lib + string_lib + numaapi_lib + guardedalloc_lib + wcwidth_lib + ${OPENGL_gl_LIBRARY} + ${FREETYPE_LIBRARY} + ${ZLIB_LIBRARIES} + ${CMAKE_DL_LIBS} + ${PLATFORM_LINKLIBS} +) diff --git a/intern/ghost/test/multitest/MultiTest.c b/intern/ghost/test/multitest/MultiTest.c index 45ea4afa274..374c7170dc6 100644 --- a/intern/ghost/test/multitest/MultiTest.c +++ b/intern/ghost/test/multitest/MultiTest.c @@ -16,6 +16,19 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. */ + +/* Developers Note: + * + * This test currently only creates windows and draws a 'dot' under the cursor on LMB, + * quits when Q is pressed. + * + * More work is needed for logging drawing to work properly. + * + * - Use GPU_matrix API. + * - Replace old OpenGL calls to glColor, etc with 'imm' API. + * - Investigate BLF font flushing (UI_widgetbase_draw_cache_flush) which is currently disabled. + */ + #ifdef _MSC_VER # pragma warning(disable : 4244 4305) #endif @@ -25,6 +38,7 @@ #include <stdio.h> #include <math.h> +#include <GL/glew.h> #include "GL.h" #include "MEM_guardedalloc.h" @@ -32,11 +46,6 @@ #include "GHOST_C-api.h" #include "BLF_api.h" -extern int datatoc_bfont_ttf_size; -extern char datatoc_bfont_ttf[]; - -/* cheat */ -char U[1024] = {0}; #include "Util.h" #include "Basic.h" @@ -45,7 +54,13 @@ char U[1024] = {0}; #include "WindowData.h" -/***/ +/* GPU API. */ +#include "GPU_immediate.h" +#include "GPU_context.h" +#include "GPU_init_exit.h" + +extern int datatoc_bfont_ttf_size; +extern char datatoc_bfont_ttf[]; typedef struct _LoggerWindow LoggerWindow; typedef struct _MultiTestApp MultiTestApp; @@ -122,6 +137,7 @@ typedef struct { MultiTestApp *app; GHOST_WindowHandle win; + GPUContext *gpu_context; int size[2]; @@ -138,6 +154,7 @@ static void mainwindow_log(MainWindow *mw, char *str) static void mainwindow_do_draw(MainWindow *mw) { GHOST_ActivateWindowDrawingContext(mw->win); + GPU_context_active_set(mw->gpu_context); if (mw->lmbut[0]) { glClearColor(0.5, 0.5, 0.5, 1); @@ -158,6 +175,7 @@ static void mainwindow_do_reshape(MainWindow *mw) GHOST_RectangleHandle bounds = GHOST_GetClientBounds(mw->win); GHOST_ActivateWindowDrawingContext(mw->win); + GPU_context_active_set(mw->gpu_context); mw->size[0] = GHOST_GetWidthRectangle(bounds); mw->size[1] = GHOST_GetHeightRectangle(bounds); @@ -311,6 +329,11 @@ MainWindow *mainwindow_new(MultiTestApp *app) if (win) { MainWindow *mw = MEM_callocN(sizeof(*mw), "mainwindow_new"); + + GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win); + mw->gpu_context = GPU_context_create(default_fb); + GPU_init(); + mw->app = app; mw->win = win; @@ -342,6 +365,7 @@ struct _LoggerWindow { MultiTestApp *app; GHOST_WindowHandle win; + GPUContext *gpu_context; int font; int fontheight; @@ -400,6 +424,7 @@ static void loggerwindow_do_reshape(LoggerWindow *lw) GHOST_RectangleHandle bounds = GHOST_GetClientBounds(lw->win); GHOST_ActivateWindowDrawingContext(lw->win); + GPU_context_active_set(lw->gpu_context); lw->size[0] = GHOST_GetWidthRectangle(bounds); lw->size[1] = GHOST_GetHeightRectangle(bounds); @@ -414,6 +439,8 @@ static void loggerwindow_do_draw(LoggerWindow *lw) int sb_rect[2][2], sb_thumb[2][2]; GHOST_ActivateWindowDrawingContext(lw->win); + GPU_context_active_set(lw->gpu_context); + immActivate(); glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); @@ -450,6 +477,8 @@ static void loggerwindow_do_draw(LoggerWindow *lw) } GHOST_SwapWindowBuffers(lw->win); + + immDeactivate(); } static void loggerwindow_do_move(LoggerWindow *lw, int x, int y) @@ -557,6 +586,11 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app) if (win) { LoggerWindow *lw = MEM_callocN(sizeof(*lw), "loggerwindow_new"); + + GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win); + lw->gpu_context = GPU_context_create(default_fb); + GPU_init(); + int bbox[2][2]; lw->app = app; lw->win = win; @@ -616,6 +650,7 @@ typedef struct { MultiTestApp *app; GHOST_WindowHandle win; + GPUContext *gpu_context; int size[2]; } ExtraWindow; @@ -623,6 +658,7 @@ typedef struct { static void extrawindow_do_draw(ExtraWindow *ew) { GHOST_ActivateWindowDrawingContext(ew->win); + GPU_context_active_set(ew->gpu_context); glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); @@ -638,6 +674,7 @@ static void extrawindow_do_reshape(ExtraWindow *ew) GHOST_RectangleHandle bounds = GHOST_GetClientBounds(ew->win); GHOST_ActivateWindowDrawingContext(ew->win); + GPU_context_active_set(ew->gpu_context); ew->size[0] = GHOST_GetWidthRectangle(bounds); ew->size[1] = GHOST_GetHeightRectangle(bounds); @@ -750,6 +787,11 @@ ExtraWindow *extrawindow_new(MultiTestApp *app) if (win) { ExtraWindow *ew = MEM_callocN(sizeof(*ew), "mainwindow_new"); + + GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(win); + ew->gpu_context = GPU_context_create(default_fb); + GPU_init(); + ew->app = app; ew->win = win; @@ -889,6 +931,9 @@ void multitestapp_run(MultiTestApp *app) void multitestapp_free(MultiTestApp *app) { + BLF_exit(); + GPU_exit(); + mainwindow_free(app->main); loggerwindow_free(app->logger); GHOST_DisposeSystem(app->sys); @@ -901,9 +946,7 @@ int main(int argc, char **argv) { MultiTestApp *app; -#ifndef USE_BMF BLF_init(); -#endif app = multitestapp_new(); diff --git a/intern/ghost/test/multitest/stubs.c b/intern/ghost/test/multitest/stubs.c index f0b076eeba0..151cdc71777 100644 --- a/intern/ghost/test/multitest/stubs.c +++ b/intern/ghost/test/multitest/stubs.c @@ -23,6 +23,7 @@ #include "IMB_imbuf.h" struct ImBuf; +struct ColorSpace; void IMB_freeImBuf(struct ImBuf *UNUSED(ibuf)) { @@ -31,3 +32,31 @@ void IMB_colormanagement_display_to_scene_linear_v3(float UNUSED(pixel[3]), struct ColorManagedDisplay *UNUSED(display)) { } + +bool IMB_colormanagement_space_is_scene_linear(struct ColorSpace *colorspace) +{ + return false; +} + +bool IMB_colormanagement_space_is_data(struct ColorSpace *colorspace) +{ + return false; +} + +void BKE_material_defaults_free_gpu(void) +{ +} + +/* Variables. */ +int G; + +/* Functions which aren't called. */ +void *BKE_image_free_buffers = NULL; +void *BKE_image_get_tile = NULL; +void *BKE_image_get_tile_from_iuser = NULL; +void *BKE_tempdir_session = NULL; +void *DRW_deferred_shader_remove = NULL; +void *datatoc_common_view_lib_glsl = NULL; +void *ntreeFreeLocalTree = NULL; +void *ntreeGPUMaterialNodes = NULL; +void *ntreeLocalize = NULL; |