Previous Thread  Next Thread

chat icon Blender UI usage in other software

jemfest

Posted: Sat May 05, 2012 6:50 pm
Joined: 05 May 2012
Posts: 5
Hi
can the blender UI be see int another software? what are the directory and file that can be used, if this can be achieved?

thank sin advanced
Jem
Reply with quote


stiv

Posted: Sat May 05, 2012 9:34 pm
Joined: 05 Aug 2003
Posts: 3645
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 .
Reply with quote


jemfest

Posted: Sat May 05, 2012 9:39 pm
Joined: 05 May 2012
Posts: 5
I supposed that but effectively is well designed i think this can be done. There is in the group someone that know this layer?
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 .
Reply with quote


sphaero

Posted: Sun May 06, 2012 4:56 pm
Joined: 28 Feb 2012
Posts: 17
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
Reply with quote


jemfest

Posted: Sun May 06, 2012 4:58 pm
Joined: 05 May 2012
Posts: 5
i'm making some experiment and i have compiled my own blender on osx.
The compilation generate all static library. i'm trying to compile the ghost test application but i have likened all library and i still have lost dependency.
i continue to investigate.
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
Reply with quote


sphaero

Posted: Sat Jun 16, 2012 11:07 pm
Joined: 28 Feb 2012
Posts: 17
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 Rolling Eyes
Reply with quote


jemfest

Posted: Sun Jun 17, 2012 9:10 am
Joined: 05 May 2012
Posts: 5
hi,
i stopped to work on this because i have many things to do, but after july i restart the investigation. Anyway if some internal blender developer give us some hints...will not be so bad.
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 Rolling Eyes
Reply with quote


jemfest

Posted: Sun Jun 17, 2012 9:10 am
Joined: 05 May 2012
Posts: 5
hi,
i stopped to work on this because i have many things to do, but after july i restart the investigation. Anyway if some internal blender developer give us some hints...will not be so bad.
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 Rolling Eyes
Reply with quote


sphaero

Posted: Sun Jun 17, 2012 12:05 pm
Joined: 28 Feb 2012
Posts: 17
I got this back from one of the developers I asked to look into it:

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.
Reply with quote


spaces

Posted: Mon Jun 18, 2012 2:32 am
Joined: 10 Sep 2011
Posts: 22
Yes this question comes up quite often everywhere. Gimp with Blender's GUI would be like heaven.

Problem is, it will never happen. :/
Reply with quote


sphaero

Posted: Mon Jun 18, 2012 11:08 am
Joined: 28 Feb 2012
Posts: 17
I tend to disagree. I don't know how long Blender will be able to maintain their monolithic approach but I foresee that if they will become more modular, seperating the GUI will be very beneficial. Easier to maintain but also flexible in a sense that certain functionality works better or more robust outside Blender. As a standalone application. Take for example puppeteering using a Kinect. There are some implementations using OSC the send the data to Blender. The UI of the kinect app is completely different from Blender. From a user experience point of view this is not good. Developers don't mind... however... Imagine if developers could keep the user experience, I think we'd have a lot more apps for blender.

I think it would be easiest to start a project copying the Blender UI to a seperate lib. I think there are only dependencies on GLUT/Ghost? It should be possible to just copy the code and adapt it from there.... If it's done right Blender could implement that lib in the future....? And if done right you'd have a python version right away as well. Smile

Rg,

Arnaud
Reply with quote


stiv

Posted: Mon Jun 18, 2012 5:56 pm
Joined: 05 Aug 2003
Posts: 3645
Quote:
I think it would be easiest...


If it were easy, someone would have done it by now.

And you left out one step - after you finally create the UI toolkit library, you need to refactor Blender to use it.
Reply with quote


sphaero

Posted: Tue Jun 19, 2012 9:40 am
Joined: 28 Feb 2012
Posts: 17
Quote:
If it's done right Blender could implement that lib in the future


But you're right... it's not easy. But do you disagree this is a sensible path for the future?
Reply with quote


bonorenofu

Posted: Thu Nov 15, 2012 1:27 am
Joined: 15 Nov 2012
Posts: 1
sphaero wrote:
Quote:
If it's done right Blender could implement that lib in the future


But you're right... it's not easy. But do you disagree this is a sensible path for the future?


I was looking for the same thing. I've manage to compile it and run the gear demo. Havent' done anything else yet.

First, checkout ghost and string from SVN under the same directory (https://svn.blender.org/svnroot/bf-blender/trunk/blender/intern/ghost and https://svn.blender.org/svnroot/bf-blender/trunk/blender/intern/string)

Then apply these patch for string:
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})


and this one for ghost:
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)


Finally build.

To run it the gears demo on mac osx, an app bundle have to be made first.

It wasn't that hard actually. I'll try to build something more later.

Hope that helps.
Reply with quote


sphaero

Posted: Fri Jun 14, 2013 8:21 pm
Joined: 28 Feb 2012
Posts: 17
I think you just compiled ghost:

Ghost ("Generic Handy Operating System Toolkit") is a replacement for GLUT, see:
http://www.letworyinteractive.com/blendercode/d5/d2e/GHOSTPage.html
http://projects.blender.org/docman/view.php/13/4/ghost_doc.html
http://wiki.blender.org/index.php/Dev:Source/Architecture/Ghost_Refactoring

But GHOST would just give us access to the keyboard, mouse etc and a OpenGL context to draw on. I'm not sure yet how Blender does it but GHOST is used to do the window drawing but all the windows are filled by python scripts which call certain c methods... or something like that Smile
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group