| stiv wrote: |
| A common question. The Blender UI was never designed as a library for use in other software. It was a custom-built toolkit for Blender.
If you want to look at the source code, look under blender/intern/ghost . |
| sphaero wrote: |
| I see this question very often too and I'm looking into this as well. So if anybody knows something more about how doing this would be greatly appreciated. Just a small example would already be very helpful.
The reason why is that I'm currently looking into creating dedicated applications for use with blender in a networked environment for realtime usuage. A lot of these programs are very simple so it doesn't need the whole blender load. It would also give me the possibilty to include other code while leaving blender intact but saving the user experience. I've already noticed that the whole gui is mostly controlled through python. For example leaving out the python scripts gets you a very minimal blender. Rg, Arnaud |
| sphaero wrote: |
| Any progress anywhere?
Since I simply don't have the time to play with this myself I tried looking for a programmer for a paid job. Just a small payment to do the job but I've had two workers now who have gotten lost in this. It seems it's really hard.... or I just got bad programmers |
| sphaero wrote: |
| Any progress anywhere?
Since I simply don't have the time to play with this myself I tried looking for a programmer for a paid job. Just a small payment to do the job but I've had two workers now who have gotten lost in this. It seems it's really hard.... or I just got bad programmers |
| Quote: |
| I think exposing the "GUI-API" can't be done in a clean way yet and really would require a major blender-rewrite. An ugly hack can be done, but it will not be stable and probably requires to be updated along with each blender-release. |
| Quote: |
| I think it would be easiest... |
| Quote: |
| If it's done right Blender could implement that lib in the future |
| sphaero wrote: | ||
But you're right... it's not easy. But do you disagree this is a sensible path for the future? |
| Code: |
|
Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 52214) +++ CMakeLists.txt (working copy) @@ -38,4 +38,5 @@ STR_String.h ) -blender_add_lib(bf_intern_string "${SRC}" "${INC}" "${INC_SYS}") +include_directories( ./ ) +add_library(bf_intern_string ${SRC} ${INC} ${INC_SYS}) |
| Code: |
|
Index: test/gears/GHOST_C-Test.c =================================================================== --- test/gears/GHOST_C-Test.c (revision 52214) +++ test/gears/GHOST_C-Test.c (working copy) @@ -50,7 +50,7 @@ # include <GL/gl.h> # else /* WIN32 */ /* __APPLE__ is defined */ -# include <AGL/gl.h> +#include <OpenGL/gl.h> # endif /* WIN32 */ #else /* defined(WIN32) || defined(__APPLE__) */ # include <GL/gl.h> Index: test/gears/GHOST_Test.cpp =================================================================== --- test/gears/GHOST_Test.cpp (revision 52214) +++ test/gears/GHOST_Test.cpp (working copy) @@ -46,7 +46,7 @@ # include <GL/gl.h> # else // WIN32 // __APPLE__ is defined -# include <AGL/gl.h> +# include <OpenGL/gl.h> # endif // WIN32 #else // defined(WIN32) || defined(__APPLE__) # include <GL/gl.h> Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt (revision 52214) +++ test/CMakeLists.txt (working copy) @@ -2,107 +2,9 @@ cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0005 NEW) +set(CMAKE_BUILD_TYPE Debug) cmake_minimum_required(VERSION 2.8) -# ----------------------------------------------------------------------------- -# Macros - - -# stub macro, does nothing -macro(blender_add_lib - name - sources - includes - includes_sys - ) - -endmacro() - -# suffix relative paths so we can use external cmake files -macro(suffix_relpaths - new_files files prefix) - - set(${new_files}) - foreach(_file ${files}) - if(IS_ABSOLUTE _file) - list(APPEND ${new_files} ${_file}) - else() - list(APPEND ${new_files} "${prefix}${_file}") - endif() - endforeach() - unset(_file) -endmacro() - - -# ----------------------------------------------------------------------------- -# Defines - -# set the endian define -if(MSVC) - # for some reason this fails on msvc - add_definitions(-D__LITTLE_ENDIAN__) -else() - include(TestBigEndian) - test_big_endian(_SYSTEM_BIG_ENDIAN) - if(_SYSTEM_BIG_ENDIAN) - add_definitions(-D__BIG_ENDIAN__) - else() - add_definitions(-D__LITTLE_ENDIAN__) - endif() - unset(_SYSTEM_BIG_ENDIAN) -endif() - - -# ----------------------------------------------------------------------------- -# Libraries - -# ghost -include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt) -suffix_relpaths(INC_NEW "${INC}" "../") -suffix_relpaths(SRC_NEW "${SRC}" "../") -include_directories(${INC_NEW}) -add_library(ghost_lib ${SRC_NEW}) - -# string -include(${CMAKE_SOURCE_DIR}/../../string/CMakeLists.txt) -suffix_relpaths(INC_NEW "${INC}" "../../string/") -suffix_relpaths(SRC_NEW "${SRC}" "../../string/") -include_directories(${INC_NEW}) -add_library(string_lib ${SRC_NEW}) - -# guardedalloc -include(${CMAKE_SOURCE_DIR}/../../guardedalloc/CMakeLists.txt) -suffix_relpaths(INC_NEW "${INC}" "../../guardedalloc/") -suffix_relpaths(SRC_NEW "${SRC}" "../../guardedalloc/") -include_directories(${INC_NEW}) -add_library(guardedalloc_lib ${SRC_NEW}) - -# blenfont -include(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont/CMakeLists.txt) -suffix_relpaths(INC_NEW "${INC}" "../../../source/blender/blenfont/") -suffix_relpaths(SRC_NEW "${SRC}" "../../../source/blender/blenfont/") -include_directories(${INC_NEW}) -add_library(blenfont_lib ${SRC_NEW}) - -# grr, blenfont needs BLI -include_directories( - "../../../source/blender/blenlib" - "../../../source/blender/blenloader" - ) -add_library(bli_lib - "../../../source/blender/blenlib/intern/fileops.c" - "../../../source/blender/blenlib/intern/rct.c" - "../../../source/blender/blenlib/intern/string.c" - "../../../source/blender/blenlib/intern/string_utf8.c" - "../../../source/blender/blenlib/intern/listbase.c" - "../../../source/blender/blenlib/intern/storage.c" - "../../../source/blender/blenlib/intern/path_util.c" - "../../../source/blender/blenlib/intern/BLI_dynstr.c" - "../../../source/blender/blenlib/intern/BLI_linklist.c" - "../../../source/blender/blenlib/intern/BLI_memarena.c" - ) - - find_package(OpenGL REQUIRED) find_package(Freetype REQUIRED) @@ -112,8 +14,18 @@ include_directories(${CMAKE_SOURCE_DIR}/../) include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${FREETYPE_INCLUDE_DIRS}) -include_directories(${CMAKE_SOURCE_DIR}/../../../source/blender/blenfont) +if(APPLE) + find_library(FOUNDATION_LIBRARY Foundation) + find_library(COCOA_LIBRARY Cocoa) + find_library(CARBON_LIBRARY Carbon) + set(PLATFORM_LINKLIBS + ${FOUNDATION_LIBRARY} + ${COCOA_LIBRARY} + ${CARBON_LIBRARY} + ) +endif() + if(UNIX AND NOT APPLE) find_package(X11 REQUIRED) @@ -126,14 +38,16 @@ # ----------------------------------------------------------------------------- # Executables - +include_directories(../ ../../string/) +link_directories(../../../ghost/build ../../../string/build) # Gears (C) add_executable(gears_c ${CMAKE_SOURCE_DIR}/gears/GHOST_C-Test.c) target_link_libraries(gears_c - ghost_lib - string_lib + bf_intern_ghost + bf_intern_string + stdc++ ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PLATFORM_LINKLIBS} @@ -145,34 +59,34 @@ ${CMAKE_SOURCE_DIR}/gears/GHOST_Test.cpp) target_link_libraries(gears_cpp - ghost_lib - string_lib + bf_intern_ghost + bf_intern_string ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PLATFORM_LINKLIBS} ) -# MultiTest (C) -add_executable(multitest_c - ${CMAKE_SOURCE_DIR}/../../../source/blender/editors/datafiles/bfont.ttf.c - ${CMAKE_SOURCE_DIR}/multitest/Basic.c - ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c - ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c - ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c - ${CMAKE_SOURCE_DIR}/multitest/Util.c - ${CMAKE_SOURCE_DIR}/multitest/WindowData.c -) - -target_link_libraries(multitest_c - blenfont_lib - bli_lib - ghost_lib - string_lib - guardedalloc_lib - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} - ${FREETYPE_LIBRARY} - ${ZLIB_LIBRARIES} - ${PLATFORM_LINKLIBS} - ) +## MultiTest (C) +#add_executable(multitest_c +# ${CMAKE_SOURCE_DIR}/../../../source/blender/editors/datafiles/bfont.ttf.c +# ${CMAKE_SOURCE_DIR}/multitest/Basic.c +# ${CMAKE_SOURCE_DIR}/multitest/EventToBuf.c +# ${CMAKE_SOURCE_DIR}/multitest/MultiTest.c +# ${CMAKE_SOURCE_DIR}/multitest/ScrollBar.c +# ${CMAKE_SOURCE_DIR}/multitest/Util.c +# ${CMAKE_SOURCE_DIR}/multitest/WindowData.c +#) +# +#target_link_libraries(multitest_c +# blenfont_lib +# bli_lib +# ghost_lib +# string_lib +# guardedalloc_lib +# ${OPENGL_gl_LIBRARY} +# ${OPENGL_glu_LIBRARY} +# ${FREETYPE_LIBRARY} +# ${ZLIB_LIBRARIES} +# ${PLATFORM_LINKLIBS} +# ) Index: intern/GHOST_SystemCocoa.mm =================================================================== --- intern/GHOST_SystemCocoa.mm (revision 52214) +++ intern/GHOST_SystemCocoa.mm (working copy) @@ -1144,6 +1144,7 @@ eventData = (GHOST_TEventDataPtr) temp_buff; break; +#if 0 case GHOST_kDragnDropTypeBitmap: { NSImage *droppedImg = (NSImage*)data; @@ -1260,6 +1261,7 @@ eventData = (GHOST_TEventDataPtr) ibuf; } +#endif break; default: Index: intern/GHOST_EventDragnDrop.h =================================================================== --- intern/GHOST_EventDragnDrop.h (revision 52214) +++ intern/GHOST_EventDragnDrop.h (working copy) @@ -35,8 +35,8 @@ #include "GHOST_Event.h" extern "C" { -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" +//#include "IMB_imbuf.h" +//#include "IMB_imbuf_types.h" }; /** @@ -101,9 +101,11 @@ return; switch (m_dragnDropEventData.dataType) { +/* case GHOST_kDragnDropTypeBitmap: IMB_freeImBuf((ImBuf *)m_dragnDropEventData.data); break; +*/ case GHOST_kDragnDropTypeFilenames: { GHOST_TStringArray *strArray = (GHOST_TStringArray *)m_dragnDropEventData.data; Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 52214) +++ CMakeLists.txt (working copy) @@ -23,13 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -set(INC - . - ../string - ../../source/blender/imbuf - ../../source/blender/makesdna -) - +set(WITH_COCOA 1) set(INC_SYS ${GLEW_INCLUDE_PATH} ) @@ -312,5 +306,8 @@ endif() -blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}") - +add_definitions(-DGHOST_COCOA) +include_directories( ./ ../string/) +link_directories( ../string/build/ ) +add_library(bf_intern_ghost ${SRC} ${INC} ${INC_SYS}) +target_link_libraries(bf_intern_ghost bf_intern_string) |