Merge with trunk up to r38584.

This commit is contained in:
Joerg Mueller 2011-07-21 21:11:58 +00:00
commit 4532bd731d
193 changed files with 18441 additions and 17999 deletions

@ -90,6 +90,9 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
get_blender_version()
# Blender internal features
option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
mark_as_advanced(WITH_BLENDER)
option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
option(WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON)
@ -106,12 +109,21 @@ option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_GAMEENGINE "Enable Game Engine" ON)
option(WITH_PLAYER "Build Player" OFF)
option(WITH_AUDASPACE "Build with blenders audio library" ON)
mark_as_advanced(WITH_AUDASPACE)
# GHOST Windowing Library Options
option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF)
mark_as_advanced(WITH_GHOST_DEBUG)
option(WITH_GHOST_SDL "Enable building blender against SDL for windowing rather then the native APIs" OFF)
mark_as_advanced(WITH_GHOST_SDL)
# Misc...
option(WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF)
mark_as_advanced(WITH_HEADLESS)
option(WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON)
mark_as_advanced(WITH_AUDASPACE)
# (unix defaults to OpenMP On)
if(UNIX AND NOT APPLE)
option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
@ -129,6 +141,7 @@ endif()
# Modifiers
option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON)
option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON)
option(WITH_MOD_DECIMATE "Enable Decimate Modifier" ON)
option(WITH_MOD_BOOLEAN "Enable Boolean Modifier" ON)
option(WITH_MOD_CLOTH_ELTOPO "Enable Experemental cloth solver" OFF)
@ -201,6 +214,10 @@ endif()
#-----------------------------------------------------------------------------
# Check for conflicting/unsupported configurations
if(NOT WITH_BLENDER AND NOT WITH_PLAYER)
message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
endif()
if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
endif()
@ -209,6 +226,10 @@ if(NOT WITH_AUDASPACE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG require WITH_AUDASPACE")
endif()
if(NOT WITH_SDL AND WITH_GHOST_SDL)
message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL to be ON")
endif()
if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
endif()
@ -433,7 +454,7 @@ if(UNIX AND NOT APPLE)
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
if(NOT WITH_HEADLESS)
if((NOT WITH_HEADLESS) AND (NOT WITH_GHOST_SDL))
find_package(X11 REQUIRED)
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
@ -708,10 +729,14 @@ elseif(WIN32)
endif()
if(WITH_PYTHON)
set(PYTHON_VERSION 3.2)
set(PYTHON_INCLUDE_DIRS "${LIBDIR}/python/include/python${PYTHON_VERSION}")
# set(PYTHON_BINARY python) # not used yet
set(PYTHON_LIBRARIES ${LIBDIR}/python/lib/python32.lib)
# normally cached but not since we include them with blender
set(PYTHON_VERSION 3.2) # CACHE STRING)
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH)
set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32.lib") #CACHE FILEPATH)
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
endif()
set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
@ -811,12 +836,14 @@ elseif(WIN32)
endif()
if(WITH_PYTHON)
set(PYTHON ${LIBDIR}/python)
set(PYTHON_VERSION 3.2)
set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
# set(PYTHON_BINARY python) # not used yet
set(PYTHON_LIBRARIES ${PYTHON}/lib/python32mw.lib)
set(PYTHON_LIBPATH ${PYTHON}/lib)
# normally cached but not since we include them with blender
set(PYTHON_VERSION 3.2) # CACHE STRING)
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH)
set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib") # CACHE FILEPATH)
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
endif()
set(PLATFORM_LINKFLAGS "--stack,2097152")
@ -867,27 +894,33 @@ elseif(APPLE)
set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib) # TODO, deprecate
endif()
set(PYTHON_VERSION 3.2)
if(PYTHON_VERSION MATCHES 3.2)
# we use precompiled libraries for py 3.2 and up by default
set(PYTHON ${LIBDIR}/python)
set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
# set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
set(PYTHON_LIBRARIES python${PYTHON_VERSION})
set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
else()
# otherwise, use custom system framework
set(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
if(WITH_PYTHON)
set(PYTHON_VERSION 3.2)
set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
# set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
set(PYTHON_LIBRARIES "")
set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
if(PYTHON_VERSION MATCHES 3.2)
# we use precompiled libraries for py 3.2 and up by default
# normally cached but not since we include them with blender
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
# set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
set(PYTHON_LIBRARY python${PYTHON_VERSION})
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
else()
# otherwise, use custom system framework
# *not used but maintained incase some dev wants to*
set(PYTHON "/System/Library/Frameworks/Python.framework/Versions/" CACHE PATH)
set(PYTHON_INCLUDE_DIR "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE PATH)
# set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
set(PYTHON_LIBRARY "" CACHE FILEPATH)
set(PYTHON_LIBPATH "${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config" CACHE PATH)
set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python" CACHE STRING)
unset(PYTHON)
endif()
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
endif()
if(WITH_INTERNATIONAL)
@ -1182,6 +1215,20 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
endif()
# ensure python header is found since detection can fail, this could happen
# with _any_ library but since we used a fixed python version this tends to
# be most problematic.
if(WITH_PYTHON)
if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
"Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
"to a valid python include path. Containing "
"Python.h for python version \"${PYTHON_VERSION}\"")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
@ -1210,7 +1257,9 @@ add_subdirectory(extern)
#-----------------------------------------------------------------------------
# Blender Application
add_subdirectory(source/creator)
if(WITH_BLENDER)
add_subdirectory(source/creator)
endif()
#-----------------------------------------------------------------------------

@ -73,7 +73,7 @@ all:
@echo
@echo Building Blender ...
make -C $(BUILD_DIR) -s -j $(NPROCS) install
$(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install
@echo
@echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
@echo blender installed, run from: "$(BUILD_DIR)/bin/blender"
@ -99,15 +99,19 @@ test:
# run pep8 check check on scripts we distribute.
test_pep8:
python source/tests/pep8.py > test_pep8.log 2>&1
python3 source/tests/pep8.py > test_pep8.log 2>&1
@echo "written: test_pep8.log"
# run some checks on our cmakefiles.
test_cmake:
python build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
@echo "written: test_cmake_consistency.log"
# run deprecation tests, see if we have anything to remove.
test_deprecated:
python3 source/tests/check_deprecated.py
clean:
make -C $(BUILD_DIR) clean
$(MAKE) -C $(BUILD_DIR) clean
.PHONY: all

@ -361,6 +361,23 @@ if not quickie and do_clean:
print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC
Exit()
# ensure python header is found since detection can fail, this could happen
# with _any_ library but since we used a fixed python version this tends to
# be most problematic.
if env['WITH_BF_PYTHON']:
py_h = os.path.join(Dir(env.subst('${BF_PYTHON_INC}')).abspath, "Python.h")
if not os.path.exists(py_h):
print("\nMissing: \"" + env.subst('${BF_PYTHON_INC}') + os.sep + "Python.h\",\n"
" Set 'BF_PYTHON_INC' to point "
"to a valid python include path.\n Containing "
"Python.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"")
Exit()
del py_h
if not os.path.isdir ( B.root_build_dir):
os.makedirs ( B.root_build_dir )
os.makedirs ( B.root_build_dir + 'source' )

@ -35,6 +35,21 @@ global_c = set()
global_refs = {}
def replace_line(f, i, text, keep_indent=True):
file_handle = open(f, 'r')
data = file_handle.readlines()
file_handle.close()
l = data[i]
ws = l[:len(l) - len(l.lstrip())]
data[i] = "%s%s\n" % (ws, text)
file_handle = open(f, 'w')
file_handle.writelines(data)
file_handle.close()
def source_list(path, filename_check=None):
for dirpath, dirnames, filenames in os.walk(path):
@ -77,7 +92,20 @@ def cmake_get_src(f):
found = False
i = 0
# print(f)
def is_definition(l, f, i, name):
if ('set(%s' % name) in l or ('set(' in l and l.endswith(name)):
if len(l.split()) > 1:
raise Exception("strict formatting not kept 'set(%s*' %s:%d" % (name, f, i))
return True
if ("list(APPEND %s" % name) in l or ('list(APPEND ' in l and l.endswith(name)):
if l.endswith(")"):
raise Exception("strict formatting not kept 'list(APPEND %s...)' on 1 line %s:%d" % (name, f, i))
return True
while it is not None:
context_name = ""
while it is not None:
i += 1
try:
@ -87,16 +115,13 @@ def cmake_get_src(f):
break
l = l.strip()
if not l.startswith("#"):
if 'set(SRC' in l or ('set(' in l and l.endswith("SRC")):
if len(l.split()) > 1:
raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i))
found = True
found = is_definition(l, f, i, "SRC")
if found:
context_name = "SRC"
break
if "list(APPEND SRC" in l or ('list(APPEND ' in l and l.endswith("SRC")):
if l.endswith(")"):
raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i))
found = True
found = is_definition(l, f, i, "INC")
if found:
context_name = "INC"
break
if found:
@ -125,30 +150,45 @@ def cmake_get_src(f):
if not l:
pass
elif l.startswith("$"):
# assume if it ends with SRC we know about it
if not l.split("}")[0].endswith("SRC"):
print("Can't use var '%s' %s:%d" % (l, f, i))
if context_name == "SRC":
# assume if it ends with context_name we know about it
if not l.split("}")[0].endswith(context_name):
print("Can't use var '%s' %s:%d" % (l, f, i))
elif len(l.split()) > 1:
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
else:
new_file = normpath(join(cmake_base, l))
if is_c_header(new_file):
sources_h.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif is_c(new_file):
sources_c.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif l in ("PARENT_SCOPE", ):
# cmake var, ignore
pass
elif new_file.endswith(".list"):
pass
elif new_file.endswith(".def"):
pass
else:
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
if context_name == "SRC":
if is_c_header(new_file):
sources_h.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif is_c(new_file):
sources_c.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif l in ("PARENT_SCOPE", ):
# cmake var, ignore
pass
elif new_file.endswith(".list"):
pass
elif new_file.endswith(".def"):
pass
else:
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
elif context_name == "INC":
if os.path.isdir(new_file):
new_path_rel = os.path.relpath(new_file, cmake_base)
if new_path_rel != l:
print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel))
## Save time. just replace the line
# replace_line(f, i - 1, new_path_rel)
else:
raise Exception("non existant include %s:%d -> %s" % (f, i, new_file))
# print(new_file)
global_h.update(set(sources_h))
@ -166,6 +206,10 @@ def cmake_get_src(f):
if ff not in sources_c:
print(" missing: " + ff)
'''
# reset
sources_h[:] = []
sources_c[:] = []
filen.close()

@ -320,11 +320,7 @@ def creator(env):
defs.append('WITH_PYTHON')
if env['BF_DEBUG']:
defs.append('_DEBUG')
if env['BF_BUILDINFO']:
defs.append('BUILD_DATE')
defs.append('NAN_BUILDINFO')
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs.append(env['BF_PTHREADS_INC'])

@ -121,6 +121,7 @@ def validate_arguments(args, bc):
'BF_OPENMP_INC',
'BF_OPENMP_LIBPATH',
'WITH_GHOST_COCOA',
'WITH_GHOST_SDL',
'USE_QTKIT',
'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE',
'BF_X264_CONFIG',
@ -385,6 +386,7 @@ def read_opts(env, cfg, args):
('BF_OPENMP_INC', 'Path to OpenMP includes (used when cross-compiling with older versions of WinGW)', ''),
('BF_OPENMP_LIBPATH', 'Path to OpenMP libraries (used when cross-compiling with older versions of WinGW)', ''),
(BoolVariable('WITH_GHOST_COCOA', 'Use Cocoa-framework if true', False)),
(BoolVariable('WITH_GHOST_SDL', 'Enable building blender against SDL for windowing rather then the native APIs', False)),
(BoolVariable('USE_QTKIT', 'Use QTKIT if true', False)),
(BoolVariable('WITH_BF_QUICKTIME', 'Use QuickTime if true', False)),

@ -29,4 +29,4 @@ if not hasattr(logic, 'video'):
logic.video.source.play()
# you need to call this function every frame to ensure update of the texture.
logic.video.refresh(True)
logic.video.refresh(True)

@ -1379,14 +1379,15 @@ OpenGL}" and the online NeHe tutorials are two of the best resources.
.. code-block:: python
import Blender
from Blender.BGL import *
import bgl
xval, yval= 100, 40
# Get the scale of the view matrix
viewMatrix = Buffer(GL_FLOAT, 16)
glGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix)
f = 1/viewMatrix[0]
glRasterPos2f(xval*f, yval*f) # Instead of the usual glRasterPos2i(xval, yval)
view_matrix = bgl.Buffer(bgl.GL_FLOAT, 16)
bgl.glGetFloatv(bgl.GL_MODELVIEW_MATRIX, view_matrix)
f = 1.0 / view_matrix[0]
# Instead of the usual glRasterPos2i(xval, yval)
bgl.glRasterPos2f(xval * f, yval * f)
.. function:: glReadBuffer(mode):
@ -1839,32 +1840,32 @@ class Buffer:
The Buffer object is simply a block of memory that is delineated and initialized by the
user. Many OpenGL functions return data to a C-style pointer, however, because this
is not possible in python the Buffer object can be used to this end. Wherever pointer
notation is used in the OpenGL functions the Buffer object can be used in it's BGL
notation is used in the OpenGL functions the Buffer object can be used in it's bgl
wrapper. In some instances the Buffer object will need to be initialized with the template
parameter, while in other instances the user will want to create just a blank buffer
which will be zeroed by default.
Example with Buffer::
import Blender
from Blender import BGL
myByteBuffer = BGL.Buffer(BGL.GL_BYTE, [32,32])
BGL.glGetPolygonStipple(myByteBuffer)
print myByteBuffer.dimensions
print myByteBuffer.list
.. code-block:: python
import bgl
myByteBuffer = bgl.Buffer(bgl.GL_BYTE, [32, 32])
bgl.glGetPolygonStipple(myByteBuffer)
print(myByteBuffer.dimensions)
print(myByteBuffer.to_list())
sliceBuffer = myByteBuffer[0:16]
print sliceBuffer
.. attribute:: list
The contents of the Buffer.
print(sliceBuffer)
.. attribute:: dimensions
The size of the Buffer.
The number of dimensions of the Buffer.
.. method:: to_list()
The contents of the Buffer as a python list.
.. method:: __init__(type, dimensions, template = None):
This will create a new Buffer object for use with other BGL OpenGL commands.
This will create a new Buffer object for use with other bgl OpenGL commands.
Only the type of argument to store in the buffer and the dimensions of the buffer
are necessary. Buffers are zeroed by default unless a template is supplied, in
which case the buffer is initialized to the template.

@ -19,7 +19,7 @@
#
set(INC
./include
include
)
set(INC_SYS

@ -25,7 +25,7 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
./include
include
)
set(INC_SYS
@ -33,7 +33,9 @@ set(INC_SYS
)
if(UNIX)
list(APPEND INC_SYS ${X11_X11_INCLUDE_PATH})
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
endif()
set(SRC

@ -25,7 +25,7 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
include
)
set(INC_SYS

@ -31,7 +31,6 @@ add_subdirectory(moto)
add_subdirectory(memutil)
add_subdirectory(iksolver)
add_subdirectory(opennl)
add_subdirectory(smoke)
add_subdirectory(mikktspace)
if(WITH_AUDASPACE)
@ -42,6 +41,10 @@ if(WITH_MOD_FLUID)
add_subdirectory(elbeem)
endif()
if(WITH_MOD_SMOKE)
add_subdirectory(smoke)
endif()
if(WITH_MOD_DECIMATE)
add_subdirectory(container)
add_subdirectory(decimation)

@ -22,9 +22,9 @@
set(INC
.
intern
FX
SRC
intern
../ffmpeg
)
@ -165,8 +165,12 @@ set(SRC
if(WITH_CODEC_FFMPEG)
add_definitions(-DWITH_FFMPEG)
list(APPEND INC ffmpeg)
list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS})
list(APPEND INC
ffmpeg
)
list(APPEND INC_SYS
${FFMPEG_INCLUDE_DIRS}
)
list(APPEND SRC
ffmpeg/AUD_FFMPEGFactory.cpp
ffmpeg/AUD_FFMPEGReader.cpp
@ -178,8 +182,12 @@ endif()
if(WITH_SDL)
add_definitions(-DWITH_SDL)
list(APPEND INC SDL)
list(APPEND INC_SYS ${SDL_INCLUDE_DIR})
list(APPEND INC
SDL
)
list(APPEND INC_SYS
${SDL_INCLUDE_DIR}
)
list(APPEND SRC
SDL/AUD_SDLDevice.cpp
@ -189,8 +197,12 @@ endif()
if(WITH_OPENAL)
add_definitions(-DWITH_OPENAL)
list(APPEND INC OpenAL)
list(APPEND INC_SYS ${OPENAL_INCLUDE_DIR})
list(APPEND INC
OpenAL
)
list(APPEND INC_SYS
${OPENAL_INCLUDE_DIR}
)
list(APPEND SRC
OpenAL/AUD_OpenALDevice.cpp
@ -200,8 +212,12 @@ endif()
if(WITH_JACK)
add_definitions(-DWITH_JACK)
list(APPEND INC jack)
list(APPEND INC_SYS ${JACK_INCLUDE_DIRS})
list(APPEND INC
jack
)
list(APPEND INC_SYS
${JACK_INCLUDE_DIRS}
)
list(APPEND SRC
jack/AUD_JackDevice.cpp
@ -211,8 +227,12 @@ endif()
if(WITH_CODEC_SNDFILE)
add_definitions(-DWITH_SNDFILE)
list(APPEND INC sndfile)
list(APPEND INC_SYS ${SNDFILE_INCLUDE_DIRS})
list(APPEND INC
sndfile
)
list(APPEND INC_SYS
${SNDFILE_INCLUDE_DIRS}
)
list(APPEND SRC
sndfile/AUD_SndFileFactory.cpp
sndfile/AUD_SndFileReader.cpp
@ -224,7 +244,9 @@ endif()
if(WITH_SAMPLERATE)
add_definitions(-DWITH_SAMPLERATE)
list(APPEND INC_SYS ${SAMPLERATE_INCLUDE_DIRS})
list(APPEND INC_SYS
${SAMPLERATE_INCLUDE_DIRS}
)
list(APPEND SRC
SRC/AUD_SRCResampleFactory.cpp
SRC/AUD_SRCResampleReader.cpp
@ -236,8 +258,12 @@ endif()
if(WITH_FFTW3 AND FALSE)
add_definitions(-DWITH_FFTW3)
list(APPEND INC fftw)
list(APPEND INC_SYS ${FFTW3_INCLUDE_DIRS})
list(APPEND INC
fftw
)
list(APPEND INC_SYS
${FFTW3_INCLUDE_DIRS}
)
list(APPEND SRC
fftw/AUD_BandPassFactory.cpp
fftw/AUD_BandPassReader.cpp
@ -248,8 +274,12 @@ if(WITH_FFTW3 AND FALSE)
endif()
if(WITH_PYTHON)
list(APPEND INC Python)
list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS})
list(APPEND INC
Python
)
list(APPEND INC_SYS
${PYTHON_INCLUDE_DIRS}
)
list(APPEND SRC
Python/AUD_PyAPI.cpp

@ -26,11 +26,11 @@
set(INC
.
./intern
./extern
../memutil
extern
intern
../container
../guardedalloc
../memutil
../moto/include
../../source/blender/blenlib
../../source/blender/makesdna

@ -25,11 +25,11 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
./intern
intern
../container
../guardedalloc
../moto/include
../memutil
../moto/include
)
set(INC_SYS

@ -40,7 +40,7 @@
#define FFMPEG_HAVE_AVIO 1
#endif
#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 122))
#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 121))
#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1
#endif

@ -37,17 +37,16 @@ set(INC_SYS
set(SRC
intern/GHOST_Buttons.cpp
intern/GHOST_CallbackEventConsumer.cpp
intern/GHOST_C-api.cpp
intern/GHOST_Path-api.cpp
intern/GHOST_CallbackEventConsumer.cpp
intern/GHOST_DisplayManager.cpp
intern/GHOST_EventManager.cpp
intern/GHOST_EventPrinter.cpp
intern/GHOST_ISystem.cpp
intern/GHOST_ISystemPaths.cpp
intern/GHOST_ModifierKeys.cpp
intern/GHOST_NDOFManager.cpp
intern/GHOST_Path-api.cpp
intern/GHOST_Path-api.cpp
intern/GHOST_Rect.cpp
intern/GHOST_System.cpp
intern/GHOST_TimerManager.cpp
@ -64,6 +63,7 @@ set(SRC
GHOST_Path-api.h
GHOST_Rect.h
GHOST_Types.h
intern/GHOST_Buttons.h
intern/GHOST_CallbackEventConsumer.h
intern/GHOST_Debug.h
@ -75,7 +75,6 @@ set(SRC
intern/GHOST_EventKey.h
intern/GHOST_EventManager.h
intern/GHOST_EventNDOF.h
intern/GHOST_EventPrinter.h
intern/GHOST_EventString.h
intern/GHOST_EventTrackpad.h
intern/GHOST_EventWheel.h
@ -89,13 +88,37 @@ set(SRC
intern/GHOST_WindowManager.h
)
if(WITH_HEADLESS)
if(WITH_GHOST_DEBUG)
list(APPEND SRC
intern/GHOST_DisplayManagerNULL.h
intern/GHOST_SystemNULL.h
intern/GHOST_WindowNULL.h
intern/GHOST_EventPrinter.cpp
intern/GHOST_EventPrinter.h
)
add_definitions(-DWITH_HEADLESS)
add_definitions(-DWITH_GHOST_DEBUG)
endif()
if(WITH_HEADLESS OR WITH_GHOST_SDL)
if(WITH_HEADLESS)
list(APPEND SRC
intern/GHOST_DisplayManagerNULL.h
intern/GHOST_SystemNULL.h
intern/GHOST_WindowNULL.h
)
add_definitions(-DWITH_HEADLESS)
else()
list(APPEND SRC
intern/GHOST_DisplayManagerSDL.cpp
intern/GHOST_SystemSDL.cpp
intern/GHOST_WindowSDL.cpp
intern/GHOST_DisplayManagerSDL.h
intern/GHOST_SystemSDL.h
intern/GHOST_WindowSDL.h
)
add_definitions(-DWITH_GHOST_SDL)
endif()
# ack, this is still system dependant
if(APPLE)
@ -124,6 +147,10 @@ if(WITH_HEADLESS)
)
endif()
list(APPEND INC_SYS
${SDL_INCLUDE_DIR}
)
elseif(APPLE)
if(WITH_COCOA)
list(APPEND SRC
@ -161,7 +188,9 @@ elseif(UNIX)
add_definitions(-DWITH_X11_XINPUT)
endif()
list(APPEND INC_SYS ${X11_X11_INCLUDE_PATH})
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
list(APPEND SRC
intern/GHOST_DisplayManagerX11.cpp
@ -181,7 +210,9 @@ elseif(UNIX)
if(X11_XF86keysym_INCLUDE_PATH)
add_definitions(-DWITH_XF86KEYSYM)
list(APPEND INC_SYS ${X11_XF86keysym_INCLUDE_PATH})
list(APPEND INC_SYS
${X11_XF86keysym_INCLUDE_PATH}
)
endif()
elseif(WIN32)
@ -189,7 +220,9 @@ elseif(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
list(APPEND INC_SYS ${WINTAB_INC})
list(APPEND INC_SYS
${WINTAB_INC}
)
list(APPEND SRC
intern/GHOST_DisplayManagerWin32.cpp

@ -14,11 +14,24 @@ if window_system == 'darwin':
pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget']
defs=['_USE_MATH_DEFINES']
if window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'):
incs = '. ../string #extern/glew/include #source/blender/imbuf #source/blender/makesdna ' + env['BF_OPENGL_INC']
if env['WITH_GHOST_SDL']:
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
except ValueError:
pass
incs += ' ' + env['BF_SDL_INC']
defs += ['WITH_GHOST_SDL']
elif window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'irix6', 'aix4', 'aix5'):
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
defs += ['PREFIX=\\"/usr/local/\\"'] # XXX, make an option
@ -29,6 +42,7 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64
try:
sources.remove('intern' + os.sep + f + 'X11.cpp')
sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
elif window_system == 'darwin':
@ -42,6 +56,7 @@ elif window_system == 'darwin':
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
sources.remove('intern' + os.sep + f + 'Carbon.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
else:
@ -50,6 +65,7 @@ elif window_system == 'darwin':
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
sources.remove('intern' + os.sep + f + 'Cocoa.mm')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
@ -58,9 +74,10 @@ else:
Exit()
if env['BF_GHOST_DEBUG']:
defs.append('BF_GHOST_DEBUG')
defs.append('WITH_GHOST_DEBUG')
else:
sources.remove('intern' + os.sep + 'GHOST_EventPrinter.cpp')
incs = '. ../string #extern/glew/include #source/blender/imbuf #source/blender/makesdna ' + env['BF_OPENGL_INC']
if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'):
incs = env['BF_WINTAB_INC'] + ' ' + incs

@ -41,9 +41,9 @@
#endif // DEBUG
#endif // WIN32
#ifdef BF_GHOST_DEBUG
#ifdef WITH_GHOST_DEBUG
#define GHOST_DEBUG // spit ghost events to stdout
#endif // BF_GHOST_DEBUG
#endif // WITH_GHOST_DEBUG
#ifdef GHOST_DEBUG
#include <iostream>

@ -0,0 +1,93 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_DisplayManagerSDL.cpp
* \ingroup GHOST
*/
#include "GHOST_SystemSDL.h"
#include "GHOST_DisplayManagerSDL.h"
GHOST_DisplayManagerSDL::GHOST_DisplayManagerSDL(GHOST_SystemSDL *system)
:
GHOST_DisplayManager(),
m_system(system)
{
/* do nothing */
}
GHOST_TSuccess
GHOST_DisplayManagerSDL::getNumDisplays(GHOST_TUns8& numDisplays)
{
numDisplays= SDL_GetNumVideoDisplays();
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_DisplayManagerSDL::getNumDisplaySettings(GHOST_TUns8 display,
GHOST_TInt32& numSettings)
{
GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
numSettings= GHOST_TInt32(1);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_DisplayManagerSDL::getDisplaySetting(GHOST_TUns8 display,
GHOST_TInt32 index,
GHOST_DisplaySetting& setting)
{
GHOST_ASSERT(display < 1, "Only single display systems are currently supported.\n");
GHOST_ASSERT(index < 1, "Requested setting outside of valid range.\n");
SDL_DisplayMode mode;
SDL_GetDesktopDisplayMode(display, &mode);
setting.xPixels= mode.w;
setting.yPixels= mode.h;
setting.bpp= SDL_BYTESPERPIXEL(mode.format);
/* assume 60 when unset */
setting.frequency= mode.refresh_rate ? mode.refresh_rate : 60;
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_DisplayManagerSDL::getCurrentDisplaySetting(GHOST_TUns8 display,
GHOST_DisplaySetting& setting)
{
return getDisplaySetting(display,GHOST_TInt32(0),setting);
}
GHOST_TSuccess
GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display,
const GHOST_DisplaySetting& setting)
{
// This is never going to work robustly in X
// but it's currently part of the full screen interface
// we fudge it for now.
return GHOST_kSuccess;
}

@ -0,0 +1,73 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_DisplayManagerSDL.h
* \ingroup GHOST
* Declaration of GHOST_DisplayManagerSDL class.
*/
#ifndef _GHOST_DISPLAY_MANAGER_SDL_H_
#define _GHOST_DISPLAY_MANAGER_SDL_H_
#include "GHOST_DisplayManager.h"
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(1, 3, 0)
# error "SDL 1.3 or newer is needed to build with Ghost"
#endif
class GHOST_SystemSDL;
class GHOST_DisplayManagerSDL : public GHOST_DisplayManager
{
public:
GHOST_DisplayManagerSDL(GHOST_SystemSDL *system);
GHOST_TSuccess
getNumDisplays(GHOST_TUns8& numDisplays);
GHOST_TSuccess
getNumDisplaySettings(GHOST_TUns8 display,
GHOST_TInt32& numSettings);
GHOST_TSuccess
getDisplaySetting(GHOST_TUns8 display,
GHOST_TInt32 index,
GHOST_DisplaySetting& setting);
GHOST_TSuccess
getCurrentDisplaySetting(GHOST_TUns8 display,
GHOST_DisplaySetting& setting);
GHOST_TSuccess
setCurrentDisplaySetting(GHOST_TUns8 display,
const GHOST_DisplaySetting& setting);
private :
GHOST_SystemSDL * m_system;
};
#endif /* _GHOST_DISPLAY_MANAGER_SDL_H_ */

@ -37,6 +37,7 @@
#include "GHOST_EventDragnDrop.h"
#include "GHOST_Debug.h"
#include <stdio.h>
bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event)
{
@ -82,17 +83,17 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event)
case GHOST_kEventKeyUp:
{
GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData();
STR_String str;
char str[32]= {'\0'};
getKeyString(keyData->key, str);
std::cout << "GHOST_kEventKeyUp, key: " << str.Ptr();
std::cout << "GHOST_kEventKeyUp, key: " << str;
}
break;
case GHOST_kEventKeyDown:
{
GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData();
STR_String str;
char str[32]= {'\0'};
getKeyString(keyData->key, str);
std::cout << "GHOST_kEventKeyDown, key: " << str.Ptr();
std::cout << "GHOST_kEventKeyDown, key: " << str;
}
break;
@ -183,165 +184,161 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event)
}
void GHOST_EventPrinter::getKeyString(GHOST_TKey key, STR_String& str) const
void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const
{
if ((key >= GHOST_kKeyComma) && (key <= GHOST_kKeyRightBracket)) {
str = ((char)key);
sprintf(str, "%c", (char)key);
} else if ((key >= GHOST_kKeyNumpad0) && (key <= GHOST_kKeyNumpad9)) {
int number = key - GHOST_kKeyNumpad0;
STR_String numberStr (number);
str = "Numpad";
str += numberStr;
sprintf(str, "Numpad %d", (key - GHOST_kKeyNumpad0));
#if defined(__sun__) || defined(__sun)
} else if (key == 268828432) { /* solaris keyboards are messed up */
/* This should really test XK_F11 but that doesn't work */
str = "F11";
strcpy(str, "F11");
} else if (key == 268828433) { /* solaris keyboards are messed up */
/* This should really test XK_F12 but that doesn't work */
str = "F12";
strcpy(str, "F12");
#endif
} else if ((key >= GHOST_kKeyF1) && (key <= GHOST_kKeyF24)) {
int number = key - GHOST_kKeyF1 + 1;
STR_String numberStr (number);
str = "F";
str += numberStr;
sprintf(str, "F%d", key - GHOST_kKeyF1 + 1);
} else {
switch (key)
{
const char *tstr= NULL;
switch (key) {
case GHOST_kKeyBackSpace:
str = "BackSpace";
tstr = "BackSpace";
break;
case GHOST_kKeyTab:
str = "Tab";
tstr = "Tab";
break;
case GHOST_kKeyLinefeed:
str = "Linefeed";
tstr = "Linefeed";
break;
case GHOST_kKeyClear:
str = "Clear";
tstr = "Clear";
break;
case GHOST_kKeyEnter:
str = "Enter";
tstr = "Enter";
break;
case GHOST_kKeyEsc:
str = "Esc";
tstr = "Esc";
break;
case GHOST_kKeySpace:
str = "Space";
tstr = "Space";
break;
case GHOST_kKeyQuote:
str = "Quote";
tstr = "Quote";
break;
case GHOST_kKeyBackslash:
str = "\\";
tstr = "\\";
break;
case GHOST_kKeyAccentGrave:
str = "`";
tstr = "`";
break;
case GHOST_kKeyLeftShift:
str = "LeftShift";
tstr = "LeftShift";
break;
case GHOST_kKeyRightShift:
str = "RightShift";
tstr = "RightShift";
break;
case GHOST_kKeyLeftControl:
str = "LeftControl";
tstr = "LeftControl";
break;
case GHOST_kKeyRightControl:
str = "RightControl";
tstr = "RightControl";
break;
case GHOST_kKeyLeftAlt:
str = "LeftAlt";
tstr = "LeftAlt";
break;
case GHOST_kKeyRightAlt:
str = "RightAlt";
tstr = "RightAlt";
break;
case GHOST_kKeyOS:
str = "OS";
tstr = "OS";
break;
case GHOST_kKeyGrLess:
// PC german!
str = "GrLess";
tstr = "GrLess";
break;
case GHOST_kKeyCapsLock:
str = "CapsLock";
tstr = "CapsLock";
break;
case GHOST_kKeyNumLock:
str = "NumLock";
tstr = "NumLock";
break;
case GHOST_kKeyScrollLock:
str = "ScrollLock";
tstr = "ScrollLock";
break;
case GHOST_kKeyLeftArrow:
str = "LeftArrow";
tstr = "LeftArrow";
break;
case GHOST_kKeyRightArrow:
str = "RightArrow";
tstr = "RightArrow";
break;
case GHOST_kKeyUpArrow:
str = "UpArrow";
tstr = "UpArrow";
break;
case GHOST_kKeyDownArrow:
str = "DownArrow";
tstr = "DownArrow";
break;
case GHOST_kKeyPrintScreen:
str = "PrintScreen";
tstr = "PrintScreen";
break;
case GHOST_kKeyPause:
str = "Pause";
tstr = "Pause";
break;
case GHOST_kKeyInsert:
str = "Insert";
tstr = "Insert";
break;
case GHOST_kKeyDelete:
str = "Delete";
tstr = "Delete";
break;
case GHOST_kKeyHome:
str = "Home";
tstr = "Home";
break;
case GHOST_kKeyEnd:
str = "End";
tstr = "End";
break;
case GHOST_kKeyUpPage:
str = "UpPage";
tstr = "UpPage";
break;
case GHOST_kKeyDownPage:
str = "DownPage";
tstr = "DownPage";
break;
case GHOST_kKeyNumpadPeriod:
str = "NumpadPeriod";
tstr = "NumpadPeriod";
break;
case GHOST_kKeyNumpadEnter:
str = "NumpadEnter";
tstr = "NumpadEnter";
break;
case GHOST_kKeyNumpadPlus:
str = "NumpadPlus";
tstr = "NumpadPlus";
break;
case GHOST_kKeyNumpadMinus:
str = "NumpadMinus";
tstr = "NumpadMinus";
break;
case GHOST_kKeyNumpadAsterisk:
str = "NumpadAsterisk";
tstr = "NumpadAsterisk";
break;
case GHOST_kKeyNumpadSlash:
str = "NumpadSlash";
tstr = "NumpadSlash";
break;
case GHOST_kKeyMediaPlay:
str = "MediaPlayPause";
tstr = "MediaPlayPause";
break;
case GHOST_kKeyMediaStop:
str = "MediaStop";
tstr = "MediaStop";
break;
case GHOST_kKeyMediaFirst:
str = "MediaFirst";
tstr = "MediaFirst";
break;
case GHOST_kKeyMediaLast:
str = "MediaLast";
tstr = "MediaLast";
break;
default:
str = "unknown";
tstr = "unknown";
break;
}
sprintf(str, "%s", tstr);
}
}

@ -58,7 +58,7 @@ protected:
* @param key The GHOST key code to convert.
* @param str The GHOST key code converted to a readable string.
*/
void getKeyString(GHOST_TKey key, STR_String& str) const;
void getKeyString(GHOST_TKey key, char str[32]) const;
};
#endif // _GHOST_EVENT_PRINTER_H_

@ -43,6 +43,8 @@
#ifdef WITH_HEADLESS
# include "GHOST_SystemNULL.h"
#elif defined(WITH_GHOST_SDL)
# include "GHOST_SystemSDL.h"
#elif defined(WIN32)
# include "GHOST_SystemWin32.h"
#else
@ -67,6 +69,8 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
if (!m_system) {
#ifdef WITH_HEADLESS
m_system = new GHOST_SystemNULL();
#elif defined(WITH_GHOST_SDL)
m_system = new GHOST_SystemSDL();
#elif defined(WIN32)
m_system = new GHOST_SystemWin32 ();
#else

@ -85,6 +85,8 @@ GHOST_NDOFManager::deviceOpen(GHOST_IWindow* window,
/* do nothing */
#elif defined(_WIN32) || defined(__APPLE__)
m_DeviceHandle = ndofDeviceOpen((void *)&currentNdofValues);
#elif defined(WITH_GHOST_SDL)
/* do nothing */
#else
GHOST_SystemX11 *sys;
sys = static_cast<GHOST_SystemX11*>(GHOST_ISystem::getSystem());

@ -0,0 +1,555 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_SystemSDL.cpp
* \ingroup GHOST
*/
#include <assert.h>
#include "GHOST_SystemSDL.h"
#include "GHOST_WindowManager.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventKey.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventWheel.h"
GHOST_SystemSDL::GHOST_SystemSDL()
:
GHOST_System()
{
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) {
printf ("Error initializing SDL: %s\n", SDL_GetError());
}
/* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); */
/* SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
}
GHOST_SystemSDL::~GHOST_SystemSDL()
{
SDL_Quit();
}
GHOST_IWindow *
GHOST_SystemSDL::createWindow(const STR_String& title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow
)
{
GHOST_WindowSDL *window= NULL;
window= new GHOST_WindowSDL (this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1);
if (window) {
if (window->getValid()) {
m_windowManager->addWindow(window);
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
}
else {
delete window;
window= NULL;
}
}
return window;
}
GHOST_TSuccess
GHOST_SystemSDL::init() {
GHOST_TSuccess success = GHOST_System::init();
if (success) {
m_displayManager = new GHOST_DisplayManagerSDL(this);
if (m_displayManager) {
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
void
GHOST_SystemSDL::getMainDisplayDimensions(GHOST_TUns32& width,
GHOST_TUns32& height) const
{
SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode); /* note, always 0 display */
width= mode.w;
height= mode.h;
}
GHOST_TUns8
GHOST_SystemSDL::getNumDisplays() const
{
return SDL_GetNumVideoDisplays();
}
GHOST_TSuccess
GHOST_SystemSDL::getModifierKeys(GHOST_ModifierKeys& keys) const
{
SDL_Keymod mod= SDL_GetModState();
keys.set(GHOST_kModifierKeyLeftShift, (mod & KMOD_LSHIFT) != 0);
keys.set(GHOST_kModifierKeyRightShift, (mod & KMOD_RSHIFT) != 0);
keys.set(GHOST_kModifierKeyLeftControl, (mod & KMOD_LCTRL) != 0);
keys.set(GHOST_kModifierKeyRightControl, (mod & KMOD_RCTRL) != 0);
keys.set(GHOST_kModifierKeyLeftAlt, (mod & KMOD_LALT) != 0);
keys.set(GHOST_kModifierKeyRightAlt, (mod & KMOD_RALT) != 0);
keys.set(GHOST_kModifierKeyOS, (mod & (KMOD_LGUI|KMOD_RGUI)) != 0);
return GHOST_kSuccess;
}
#define GXMAP(k,x,y) case x: k= y; break;
static GHOST_TKey
convertSDLKey(SDL_Scancode key)
{
GHOST_TKey type;
if ((key >= SDL_SCANCODE_A) && (key <= SDL_SCANCODE_Z)) {
type= GHOST_TKey( key - SDL_SCANCODE_A + int(GHOST_kKeyA));
} else if ((key >= SDL_SCANCODE_1) && (key <= SDL_SCANCODE_0)) {
type= GHOST_TKey(key - SDL_SCANCODE_1 + int(GHOST_kKey0));
} else if ((key >= SDL_SCANCODE_F1) && (key <= SDL_SCANCODE_F12)) {
type= GHOST_TKey(key - SDL_SCANCODE_F1 + int(GHOST_kKeyF1));
} else if ((key >= SDL_SCANCODE_F13) && (key <= SDL_SCANCODE_F24)) {
type= GHOST_TKey(key - SDL_SCANCODE_F13 + int(GHOST_kKeyF13));
} else {
switch(key) {
/* TODO SDL_SCANCODE_NONUSBACKSLASH */
GXMAP(type,SDL_SCANCODE_BACKSPACE, GHOST_kKeyBackSpace);
GXMAP(type,SDL_SCANCODE_TAB, GHOST_kKeyTab);
GXMAP(type,SDL_SCANCODE_RETURN, GHOST_kKeyEnter);
GXMAP(type,SDL_SCANCODE_ESCAPE, GHOST_kKeyEsc);
GXMAP(type,SDL_SCANCODE_SPACE, GHOST_kKeySpace);
GXMAP(type,SDL_SCANCODE_SEMICOLON, GHOST_kKeySemicolon);
GXMAP(type,SDL_SCANCODE_PERIOD, GHOST_kKeyPeriod);
GXMAP(type,SDL_SCANCODE_COMMA, GHOST_kKeyComma);
GXMAP(type,SDL_SCANCODE_APOSTROPHE, GHOST_kKeyQuote);
GXMAP(type,SDL_SCANCODE_GRAVE, GHOST_kKeyAccentGrave);
GXMAP(type,SDL_SCANCODE_MINUS, GHOST_kKeyMinus);
GXMAP(type,SDL_SCANCODE_SLASH, GHOST_kKeySlash);
GXMAP(type,SDL_SCANCODE_BACKSLASH, GHOST_kKeyBackslash);
GXMAP(type,SDL_SCANCODE_KP_EQUALS, GHOST_kKeyEqual);
GXMAP(type,SDL_SCANCODE_LEFTBRACKET, GHOST_kKeyLeftBracket);
GXMAP(type,SDL_SCANCODE_RIGHTBRACKET, GHOST_kKeyRightBracket);
GXMAP(type,SDL_SCANCODE_PAUSE, GHOST_kKeyPause);
GXMAP(type,SDL_SCANCODE_LSHIFT, GHOST_kKeyLeftShift);
GXMAP(type,SDL_SCANCODE_RSHIFT, GHOST_kKeyRightShift);
GXMAP(type,SDL_SCANCODE_LCTRL, GHOST_kKeyLeftControl);
GXMAP(type,SDL_SCANCODE_RCTRL, GHOST_kKeyRightControl);
GXMAP(type,SDL_SCANCODE_LALT, GHOST_kKeyLeftAlt);
GXMAP(type,SDL_SCANCODE_RALT, GHOST_kKeyRightAlt);
GXMAP(type,SDL_SCANCODE_RGUI, GHOST_kKeyOS);
GXMAP(type,SDL_SCANCODE_INSERT, GHOST_kKeyInsert);
GXMAP(type,SDL_SCANCODE_DELETE, GHOST_kKeyDelete);
GXMAP(type,SDL_SCANCODE_HOME, GHOST_kKeyHome);
GXMAP(type,SDL_SCANCODE_END, GHOST_kKeyEnd);
GXMAP(type,SDL_SCANCODE_PAGEUP, GHOST_kKeyUpPage);
GXMAP(type,SDL_SCANCODE_PAGEDOWN, GHOST_kKeyDownPage);
GXMAP(type,SDL_SCANCODE_LEFT, GHOST_kKeyLeftArrow);
GXMAP(type,SDL_SCANCODE_RIGHT, GHOST_kKeyRightArrow);
GXMAP(type,SDL_SCANCODE_UP, GHOST_kKeyUpArrow);
GXMAP(type,SDL_SCANCODE_DOWN, GHOST_kKeyDownArrow);
GXMAP(type,SDL_SCANCODE_CAPSLOCK, GHOST_kKeyCapsLock);
GXMAP(type,SDL_SCANCODE_SCROLLLOCK, GHOST_kKeyScrollLock);
GXMAP(type,SDL_SCANCODE_NUMLOCKCLEAR, GHOST_kKeyNumLock);
/* keypad events */
/* note, sdl defines a bunch of kp defines I never saw before like
* SDL_SCANCODE_KP_PERCENT, SDL_SCANCODE_KP_XOR - campbell */
GXMAP(type,SDL_SCANCODE_KP_0, GHOST_kKeyNumpad0);
GXMAP(type,SDL_SCANCODE_KP_1, GHOST_kKeyNumpad1);
GXMAP(type,SDL_SCANCODE_KP_2, GHOST_kKeyNumpad2);
GXMAP(type,SDL_SCANCODE_KP_3, GHOST_kKeyNumpad3);
GXMAP(type,SDL_SCANCODE_KP_4, GHOST_kKeyNumpad4);
GXMAP(type,SDL_SCANCODE_KP_5, GHOST_kKeyNumpad5);
GXMAP(type,SDL_SCANCODE_KP_6, GHOST_kKeyNumpad6);
GXMAP(type,SDL_SCANCODE_KP_7, GHOST_kKeyNumpad7);
GXMAP(type,SDL_SCANCODE_KP_8, GHOST_kKeyNumpad8);
GXMAP(type,SDL_SCANCODE_KP_9, GHOST_kKeyNumpad9);
GXMAP(type,SDL_SCANCODE_KP_PERIOD, GHOST_kKeyNumpadPeriod);
GXMAP(type,SDL_SCANCODE_KP_ENTER, GHOST_kKeyNumpadEnter);
GXMAP(type,SDL_SCANCODE_KP_PLUS, GHOST_kKeyNumpadPlus);
GXMAP(type,SDL_SCANCODE_KP_MINUS, GHOST_kKeyNumpadMinus);
GXMAP(type,SDL_SCANCODE_KP_MULTIPLY, GHOST_kKeyNumpadAsterisk);
GXMAP(type,SDL_SCANCODE_KP_DIVIDE, GHOST_kKeyNumpadSlash);
/* Media keys in some keyboards and laptops with XFree86/Xorg */
GXMAP(type,SDL_SCANCODE_AUDIOPLAY, GHOST_kKeyMediaPlay);
GXMAP(type,SDL_SCANCODE_AUDIOSTOP, GHOST_kKeyMediaStop);
GXMAP(type,SDL_SCANCODE_AUDIOPREV, GHOST_kKeyMediaFirst);
// GXMAP(type,XF86XK_AudioRewind, GHOST_kKeyMediaFirst);
GXMAP(type,SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast);
default:
type= GHOST_kKeyUnknown;
break;
}
}
return type;
}
#undef GXMAP
void
GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
{
GHOST_Event * g_event= NULL;
switch(sdl_event->type) {
case SDL_WINDOWEVENT:
{
SDL_WindowEvent &sdl_sub_evt= sdl_event->window;
GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
//assert(window != NULL); // can be NULL on close window.
switch (sdl_sub_evt.event) {
case SDL_WINDOWEVENT_EXPOSED:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window);
break;
case SDL_WINDOWEVENT_RESIZED:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window);
break;
case SDL_WINDOWEVENT_MOVED:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window);
break;
case SDL_WINDOWEVENT_CLOSE:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window);
break;
}
}
break;
case SDL_QUIT:
g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL);
break;
case SDL_MOUSEMOTION:
{
SDL_MouseMotionEvent &sdl_sub_evt= sdl_event->motion;
SDL_Window *sdl_win= SDL_GetWindowFromID(sdl_sub_evt.windowID);
GHOST_WindowSDL *window= findGhostWindow(sdl_win);
assert(window != NULL);
int x_win, y_win;
SDL_GetWindowPosition(sdl_win, &x_win, &y_win);
GHOST_TInt32 x_root= sdl_sub_evt.x + x_win;
GHOST_TInt32 y_root= sdl_sub_evt.y + y_win;
#if 0
if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal)
{
GHOST_TInt32 x_new= x_root;
GHOST_TInt32 y_new= y_root;
GHOST_TInt32 x_accum, y_accum;
GHOST_Rect bounds;
/* fallback to window bounds */
if(window->getCursorGrabBounds(bounds)==GHOST_kFailure)
window->getClientBounds(bounds);
/* could also clamp to screen bounds
* wrap with a window outside the view will fail atm */
bounds.wrapPoint(x_new, y_new, 8); /* offset of one incase blender is at screen bounds */
window->getCursorGrabAccum(x_accum, y_accum);
// cant use setCursorPosition because the mouse may have no focus!
if(x_new != x_root || y_new != y_root) {
if (1 ) { //xme.time > m_last_warp) {
/* when wrapping we don't need to add an event because the
* setCursorPosition call will cause a new event after */
SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); /* wrap */
window->setCursorGrabAccum(x_accum + (x_root - x_new), y_accum + (y_root - y_new));
// m_last_warp= lastEventTime(xme.time);
} else {
// setCursorPosition(x_new, y_new); /* wrap but don't accumulate */
SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win);
}
g_event = new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_new, y_new);
}
else {
g_event = new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root + x_accum, y_root + y_accum);
}
}
else
#endif
{
g_event= new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root, y_root);
}
break;
}
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
{
SDL_MouseButtonEvent &sdl_sub_evt= sdl_event->button;
GHOST_TButtonMask gbmask= GHOST_kButtonMaskLeft;
GHOST_TEventType type= (sdl_sub_evt.state==SDL_PRESSED) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
assert(window != NULL);
/* process rest of normal mouse buttons */
if(sdl_sub_evt.button == SDL_BUTTON_LEFT)
gbmask= GHOST_kButtonMaskLeft;
else if(sdl_sub_evt.button == SDL_BUTTON_MIDDLE)
gbmask= GHOST_kButtonMaskMiddle;
else if(sdl_sub_evt.button == SDL_BUTTON_RIGHT)
gbmask= GHOST_kButtonMaskRight;
/* these buttons are untested! */
else if(sdl_sub_evt.button == SDL_BUTTON_X1)
gbmask= GHOST_kButtonMaskButton4;
else if(sdl_sub_evt.button == SDL_BUTTON_X2)
gbmask= GHOST_kButtonMaskButton5;
else
break;
g_event= new GHOST_EventButton(getMilliSeconds(), type, window, gbmask);
break;
}
case SDL_MOUSEWHEEL:
{
SDL_MouseWheelEvent &sdl_sub_evt= sdl_event->wheel;
GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
assert(window != NULL);
g_event= new GHOST_EventWheel(getMilliSeconds(), window, sdl_sub_evt.y);
}
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
{
SDL_KeyboardEvent &sdl_sub_evt= sdl_event->key;
GHOST_TEventType type= (sdl_sub_evt.state == SDL_PRESSED) ? GHOST_kEventKeyDown : GHOST_kEventKeyUp;
GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
assert(window != NULL);
GHOST_TKey gkey= convertSDLKey(sdl_sub_evt.keysym.scancode);
/* note, the sdl_sub_evt.keysym.sym is truncated, for unicode support ghost has to be modified */
g_event= new GHOST_EventKey(getMilliSeconds(), type, window, gkey, sdl_sub_evt.keysym.sym);
}
break;
}
if (g_event) {
pushEvent(g_event);
}
}
GHOST_TSuccess
GHOST_SystemSDL::getCursorPosition(GHOST_TInt32& x,
GHOST_TInt32& y) const
{
int x_win, y_win;
SDL_Window *win= SDL_GetMouseFocus();
SDL_GetWindowPosition(win, &x_win, &y_win);
int xi, yi;
SDL_GetMouseState(&xi, &yi);
x= xi + x_win;
y= yi + x_win;
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_SystemSDL::setCursorPosition(GHOST_TInt32 x,
GHOST_TInt32 y)
{
int x_win, y_win;
SDL_Window *win= SDL_GetMouseFocus();
SDL_GetWindowPosition(win, &x_win, &y_win);
SDL_WarpMouseInWindow(win, x - x_win, y - y_win);
return GHOST_kSuccess;
}
bool
GHOST_SystemSDL::generateWindowExposeEvents()
{
vector<GHOST_WindowSDL *>::iterator w_start= m_dirty_windows.begin();
vector<GHOST_WindowSDL *>::const_iterator w_end= m_dirty_windows.end();
bool anyProcessed= false;
for (;w_start != w_end; ++w_start) {
GHOST_Event * g_event= new
GHOST_Event(
getMilliSeconds(),
GHOST_kEventWindowUpdate,
*w_start
);
(*w_start)->validate();
if (g_event) {
printf("Expose events pushed\n");
pushEvent(g_event);
anyProcessed= true;
}
}
m_dirty_windows.clear();
return anyProcessed;
}
bool
GHOST_SystemSDL::processEvents(bool waitForEvent)
{
// Get all the current events -- translate them into
// ghost events and call base class pushEvent() method.
bool anyProcessed= false;
do {
GHOST_TimerManager* timerMgr= getTimerManager();
if (waitForEvent && m_dirty_windows.empty() && !SDL_HasEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)) {
GHOST_TUns64 next= timerMgr->nextFireTime();
if (next==GHOST_kFireTimeNever) {
SDL_WaitEventTimeout(NULL, -1);
//SleepTillEvent(m_display, -1);
} else {
GHOST_TInt64 maxSleep= next - getMilliSeconds();
if(maxSleep >= 0) {
SDL_WaitEventTimeout(NULL, next - getMilliSeconds());
// SleepTillEvent(m_display, next - getMilliSeconds()); // X11
}
}
}
if (timerMgr->fireTimers(getMilliSeconds())) {
anyProcessed= true;
}
SDL_Event sdl_event;
while (SDL_PollEvent(&sdl_event)) {
processEvent(&sdl_event);
anyProcessed= true;
}
if (generateWindowExposeEvents()) {
anyProcessed= true;
}
} while (waitForEvent && !anyProcessed);
return anyProcessed;
}
GHOST_WindowSDL *
GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
{
if (sdl_win == NULL) return NULL;
// It is not entirely safe to do this as the backptr may point
// to a window that has recently been removed.
// We should always check the window manager's list of windows
// and only process events on these windows.
vector<GHOST_IWindow *> & win_vec= m_windowManager->getWindows();
vector<GHOST_IWindow *>::iterator win_it= win_vec.begin();
vector<GHOST_IWindow *>::const_iterator win_end= win_vec.end();
for (; win_it != win_end; ++win_it) {
GHOST_WindowSDL * window= static_cast<GHOST_WindowSDL *>(*win_it);
if (window->getSDLWindow() == sdl_win) {
return window;
}
}
return NULL;
}
void
GHOST_SystemSDL::addDirtyWindow(GHOST_WindowSDL *bad_wind)
{
GHOST_ASSERT((bad_wind != NULL), "addDirtyWindow() NULL ptr trapped (window)");
m_dirty_windows.push_back(bad_wind);
}
GHOST_TSuccess GHOST_SystemSDL::getButtons(GHOST_Buttons& buttons) const
{
Uint8 state= SDL_GetMouseState(NULL, NULL);
buttons.set(GHOST_kButtonMaskLeft, (state & SDL_BUTTON_LMASK) != 0);
buttons.set(GHOST_kButtonMaskMiddle, (state & SDL_BUTTON_MMASK) != 0);
buttons.set(GHOST_kButtonMaskRight, (state & SDL_BUTTON_RMASK) != 0);
return GHOST_kSuccess;
}
GHOST_TUns8 *
GHOST_SystemSDL::getClipboard(bool selection) const
{
return (GHOST_TUns8 *)SDL_GetClipboardText();
}
void
GHOST_SystemSDL::putClipboard(GHOST_TInt8 *buffer, bool selection) const
{
SDL_SetClipboardText(buffer);
}
GHOST_TUns64
GHOST_SystemSDL::getMilliSeconds()
{
return GHOST_TUns64(SDL_GetTicks()); /* note, 32 -> 64bits */
}

@ -0,0 +1,126 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_SystemSDL.h
* \ingroup GHOST
* Declaration of GHOST_SystemSDL class.
*/
#ifndef _GHOST_SYSTEM_SDL_H_
#define _GHOST_SYSTEM_SDL_H_
#include "GHOST_System.h"
#include "../GHOST_Types.h"
#include "GHOST_DisplayManagerSDL.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowSDL.h"
#include "GHOST_Event.h"
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(1, 3, 0)
# error "SDL 1.3 or newer is needed to build with Ghost"
#endif
class GHOST_WindowSDL;
class GHOST_SystemSDL : public GHOST_System {
public:
void addDirtyWindow(GHOST_WindowSDL *bad_wind);
GHOST_SystemSDL();
~GHOST_SystemSDL();
bool
processEvents(bool waitForEvent);
int
toggleConsole(int action) { return 0; }
GHOST_TSuccess
getModifierKeys(GHOST_ModifierKeys& keys) const;
GHOST_TSuccess
getButtons(GHOST_Buttons& buttons) const;
GHOST_TUns8 *
getClipboard(bool selection) const;
void
putClipboard(GHOST_TInt8 *buffer, bool selection) const;
GHOST_TUns64
getMilliSeconds();
GHOST_TUns8
getNumDisplays() const;
GHOST_TSuccess
getCursorPosition(GHOST_TInt32& x,
GHOST_TInt32& y) const;
GHOST_TSuccess
setCursorPosition(GHOST_TInt32 x,
GHOST_TInt32 y);
void
getMainDisplayDimensions(GHOST_TUns32& width,
GHOST_TUns32& height) const;
private:
GHOST_TSuccess
init();
GHOST_IWindow *
createWindow(const STR_String& title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow
);
/* SDL spesific */
GHOST_WindowSDL * findGhostWindow(SDL_Window *sdl_win);
bool
generateWindowExposeEvents();
void
processEvent(SDL_Event *sdl_event);
/// The vector of windows that need to be updated.
std::vector<GHOST_WindowSDL *> m_dirty_windows;
};
#endif

@ -763,7 +763,7 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, WPARAM
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii);
#ifdef BF_GHOST_DEBUG
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;
#endif
}

@ -150,8 +150,9 @@ GHOST_SystemX11(
if (gettimeofday(&tv,NULL) == -1) {
GHOST_ASSERT(false,"Could not instantiate timer!");
}
m_start_time = GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000);
// Taking care not to overflow the tv.tv_sec*1000
m_start_time = GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000;
/* use detectable autorepeate, mac and windows also do this */
@ -199,7 +200,8 @@ getMilliSeconds(
GHOST_ASSERT(false,"Could not compute time!");
}
return GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000) - m_start_time;
// Taking care not to overflow the tv.tv_sec*1000
return GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000 - m_start_time;
}
GHOST_TUns8
@ -859,60 +861,28 @@ getModifierKeys(
// now translate key symobols into keycodes and
// test with vector.
const KeyCode shift_l = XKeysymToKeycode(m_display,XK_Shift_L);
const KeyCode shift_r = XKeysymToKeycode(m_display,XK_Shift_R);
const KeyCode control_l = XKeysymToKeycode(m_display,XK_Control_L);
const KeyCode control_r = XKeysymToKeycode(m_display,XK_Control_R);
const KeyCode alt_l = XKeysymToKeycode(m_display,XK_Alt_L);
const KeyCode alt_r = XKeysymToKeycode(m_display,XK_Alt_R);
const KeyCode super_l = XKeysymToKeycode(m_display,XK_Super_L);
const KeyCode super_r = XKeysymToKeycode(m_display,XK_Super_R);
const static KeyCode shift_l = XKeysymToKeycode(m_display,XK_Shift_L);
const static KeyCode shift_r = XKeysymToKeycode(m_display,XK_Shift_R);
const static KeyCode control_l = XKeysymToKeycode(m_display,XK_Control_L);
const static KeyCode control_r = XKeysymToKeycode(m_display,XK_Control_R);
const static KeyCode alt_l = XKeysymToKeycode(m_display,XK_Alt_L);
const static KeyCode alt_r = XKeysymToKeycode(m_display,XK_Alt_R);
const static KeyCode super_l = XKeysymToKeycode(m_display,XK_Super_L);
const static KeyCode super_r = XKeysymToKeycode(m_display,XK_Super_R);
// Shift
if ((m_keyboard_vector[shift_l >> 3] >> (shift_l & 7)) & 1) {
keys.set(GHOST_kModifierKeyLeftShift,true);
} else {
keys.set(GHOST_kModifierKeyLeftShift,false);
}
if ((m_keyboard_vector[shift_r >> 3] >> (shift_r & 7)) & 1) {
// shift
keys.set(GHOST_kModifierKeyLeftShift, ((m_keyboard_vector[shift_l >> 3] >> (shift_l & 7)) & 1) != 0);
keys.set(GHOST_kModifierKeyRightShift, ((m_keyboard_vector[shift_r >> 3] >> (shift_r & 7)) & 1) != 0);
// control
keys.set(GHOST_kModifierKeyLeftControl, ((m_keyboard_vector[control_l >> 3] >> (control_l & 7)) & 1) != 0);
keys.set(GHOST_kModifierKeyRightControl, ((m_keyboard_vector[control_r >> 3] >> (control_r & 7)) & 1) != 0);
// alt
keys.set(GHOST_kModifierKeyLeftAlt, ((m_keyboard_vector[alt_l >> 3] >> (alt_l & 7)) & 1) != 0);
keys.set(GHOST_kModifierKeyRightAlt, ((m_keyboard_vector[alt_r >> 3] >> (alt_r & 7)) & 1) != 0);
// super (windows) - only one GHOST-kModifierKeyOS, so mapping to either
keys.set(GHOST_kModifierKeyOS, ( ((m_keyboard_vector[super_l >> 3] >> (super_l & 7)) & 1) ||
((m_keyboard_vector[super_r >> 3] >> (super_r & 7)) & 1) ) != 0);
keys.set(GHOST_kModifierKeyRightShift,true);
} else {
keys.set(GHOST_kModifierKeyRightShift,false);
}
// control (weep)
if ((m_keyboard_vector[control_l >> 3] >> (control_l & 7)) & 1) {
keys.set(GHOST_kModifierKeyLeftControl,true);
} else {
keys.set(GHOST_kModifierKeyLeftControl,false);
}
if ((m_keyboard_vector[control_r >> 3] >> (control_r & 7)) & 1) {
keys.set(GHOST_kModifierKeyRightControl,true);
} else {
keys.set(GHOST_kModifierKeyRightControl,false);
}
// Alt (yawn)
if ((m_keyboard_vector[alt_l >> 3] >> (alt_l & 7)) & 1) {
keys.set(GHOST_kModifierKeyLeftAlt,true);
} else {
keys.set(GHOST_kModifierKeyLeftAlt,false);
}
if ((m_keyboard_vector[alt_r >> 3] >> (alt_r & 7)) & 1) {
keys.set(GHOST_kModifierKeyRightAlt,true);
} else {
keys.set(GHOST_kModifierKeyRightAlt,false);
}
// Super (Windows) - only one GHOST-kModifierKeyOS, so mapping
// to either
if ( ((m_keyboard_vector[super_l >> 3] >> (super_l & 7)) & 1) ||
((m_keyboard_vector[super_r >> 3] >> (super_r & 7)) & 1) ) {
keys.set(GHOST_kModifierKeyOS,true);
} else {
keys.set(GHOST_kModifierKeyOS,false);
}
return GHOST_kSuccess;
}

@ -0,0 +1,628 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_WindowSDL.cpp
* \ingroup GHOST
*/
#include "GHOST_WindowSDL.h"
#include "SDL_mouse.h"
#include <assert.h>
static SDL_GLContext s_firstContext= NULL;
GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
const STR_String& title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples
)
:
GHOST_Window(width,height,state,type,stereoVisual,numOfAASamples),
m_system (system),
m_invalid_window(false),
m_sdl_custom_cursor(NULL)
{
m_sdl_win= SDL_CreateWindow(title,
left,
top,
width,
height,
SDL_WINDOW_RESIZABLE|SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
m_sdl_glcontext= SDL_GL_CreateContext(m_sdl_win);
//fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n",
// theEvent->error_code, theEvent->request_code) ;
setTitle(title);
}
GHOST_WindowSDL::~GHOST_WindowSDL()
{
if(m_sdl_custom_cursor) {
SDL_FreeCursor(m_sdl_custom_cursor);
}
if (m_sdl_glcontext != s_firstContext) {
SDL_GL_DeleteContext(m_sdl_glcontext);
}
SDL_DestroyWindow(m_sdl_win);
}
GHOST_TSuccess
GHOST_WindowSDL::installDrawingContext(GHOST_TDrawingContextType type)
{
// only support openGL for now.
GHOST_TSuccess success;
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
m_sdl_glcontext= SDL_GL_CreateContext(m_sdl_win);
if (m_sdl_glcontext != NULL) {
if (!s_firstContext) {
s_firstContext= m_sdl_glcontext;
}
success= (SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext) < 0) ?
GHOST_kFailure : GHOST_kSuccess;
}
else {
success= GHOST_kFailure;
}
break;
case GHOST_kDrawingContextTypeNone:
success= GHOST_kSuccess;
break;
default:
success= GHOST_kFailure;
}
return success;
}
GHOST_TSuccess
GHOST_WindowSDL::invalidate(void)
{
// So the idea of this function is to generate an expose event
// for the window.
// Unfortunately X does not handle expose events for you and
// it is the client's job to refresh the dirty part of the window.
// We need to queue up invalidate calls and generate GHOST events
// for them in the system.
// We implement this by setting a boolean in this class to concatenate
// all such calls into a single event for this window.
// At the same time we queue the dirty windows in the system class
// and generate events for them at the next processEvents call.
if (m_invalid_window == false) {
m_system->addDirtyWindow(this);
m_invalid_window= true;
}
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::swapBuffers()
{
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
SDL_GL_SwapWindow(m_sdl_win);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess
GHOST_WindowSDL::activateDrawingContext()
{
if (m_sdl_glcontext !=NULL) {
int status=SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext);
(void)status;
return GHOST_kSuccess;
}
return GHOST_kFailure;
}
GHOST_TSuccess
GHOST_WindowSDL::removeDrawingContext()
{
GHOST_TSuccess success;
if (m_sdl_glcontext != NULL) {
SDL_GL_DeleteContext(m_sdl_glcontext);
success= GHOST_kSuccess;
}
else {
success= GHOST_kFailure;
}
return success;
}
GHOST_TSuccess
GHOST_WindowSDL::setState(GHOST_TWindowState state)
{
switch(state) {
case GHOST_kWindowStateNormal:
SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE);
SDL_RestoreWindow(m_sdl_win);
break;
case GHOST_kWindowStateMaximized:
SDL_SetWindowFullscreen(m_sdl_win, SDL_FALSE);
SDL_MaximizeWindow(m_sdl_win);
break;
case GHOST_kWindowStateMinimized:
SDL_MinimizeWindow(m_sdl_win);
break;
case GHOST_kWindowStateFullScreen:
SDL_SetWindowFullscreen(m_sdl_win, SDL_TRUE);
break;
default:
break;
}
return GHOST_kSuccess;
}
GHOST_TWindowState
GHOST_WindowSDL::getState() const
{
Uint32 flags= SDL_GetWindowFlags(m_sdl_win);
if(flags & SDL_WINDOW_FULLSCREEN) return GHOST_kWindowStateFullScreen;
else if(flags & SDL_WINDOW_MAXIMIZED) return GHOST_kWindowStateMaximized;
else if(flags & SDL_WINDOW_MINIMIZED) return GHOST_kWindowStateMinimized;
return GHOST_kWindowStateNormal;
}
void
GHOST_WindowSDL::setTitle(const STR_String& title)
{
SDL_SetWindowTitle(m_sdl_win, title.ReadPtr());
}
void
GHOST_WindowSDL::getTitle(STR_String& title) const
{
title= SDL_GetWindowTitle(m_sdl_win);
}
void
GHOST_WindowSDL::getWindowBounds(GHOST_Rect& bounds) const
{
getClientBounds(bounds);
}
void
GHOST_WindowSDL::getClientBounds(GHOST_Rect& bounds) const
{
int x, y, w, h;
SDL_GetWindowSize(m_sdl_win, &w, &h);
SDL_GetWindowPosition(m_sdl_win, &x, &y);
bounds.m_l= x;
bounds.m_r= x + w;
bounds.m_t= y;
bounds.m_b= y + h;
}
GHOST_TSuccess
GHOST_WindowSDL::setClientWidth(GHOST_TUns32 width)
{
int height;
SDL_GetWindowSize(m_sdl_win, NULL, &height);
SDL_SetWindowSize(m_sdl_win, width, height);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setClientHeight(GHOST_TUns32 height)
{
int width;
SDL_GetWindowSize(m_sdl_win, &width, NULL);
SDL_SetWindowSize(m_sdl_win, width, height);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setClientSize(GHOST_TUns32 width,
GHOST_TUns32 height)
{
SDL_SetWindowSize(m_sdl_win, width, height);
return GHOST_kSuccess;
}
void
GHOST_WindowSDL::screenToClient( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const
{
/* XXXSDL_WEAK_ABS_COORDS */
int x_win, y_win;
SDL_GetWindowPosition(m_sdl_win, &x_win, &y_win);
outX = inX - x_win;
outY = inY - y_win;
}
void
GHOST_WindowSDL::clientToScreen( GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY ) const
{
/* XXXSDL_WEAK_ABS_COORDS */
int x_win, y_win;
SDL_GetWindowPosition(m_sdl_win, &x_win, &y_win);
outX = inX + x_win;
outY = inY + y_win;
}
/* mouse cursor */
static unsigned char sdl_std_cursor_mask_xterm[]= {0xef,0x01,0xff,0x01,0xff,0x01,0x7c,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x7c,0x00,0xff,0x01,0xff,0x01,0xef,0x01,};
static unsigned char sdl_std_cursor_xterm[]= {0x00,0x77,0x00,0x1c,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x1c,0x00,0x77,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_xterm 9
#define sdl_std_cursor_HEIGHT_xterm 16
#define sdl_std_cursor_HOT_X_xterm -3
#define sdl_std_cursor_HOT_Y_xterm -7
static unsigned char sdl_std_cursor_mask_watch[]= {0xfc,0x0f,0xfc,0x0f,0xfc,0x0f,0xfe,0x1f,0xff,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfe,0x1f,0xfc,0x0f,0xfc,0x0f,0xfc,0x0f,};
static unsigned char sdl_std_cursor_watch[]= {0xf8,0x07,0xf8,0x07,0xf8,0x07,0xfc,0x0f,0x86,0x18,0x83,0x30,0x81,0xe0,0xc1,0xe1,0xc1,0xe1,0x21,0xe0,0x13,0x30,0x06,0x18,0xfc,0x0f,0xf8,0x07,0xf8,0x07,0xf8,0x07,};
#define sdl_std_cursor_WIDTH_watch 16
#define sdl_std_cursor_HEIGHT_watch 16
#define sdl_std_cursor_HOT_X_watch -15
#define sdl_std_cursor_HOT_Y_watch -7
static unsigned char sdl_std_cursor_mask_umbrella[]= {0xe8,0x76,0xfb,0xdf,0xfd,0x3f,0xfe,0xff,0xff,0x3f,0xff,0xff,0xcf,0x79,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x07,0xc0,0x07,0xc0,0x07,0xc0,0x07,0x80,0x03,};
static unsigned char sdl_std_cursor_umbrella[]= {0x88,0x04,0x20,0x0a,0xc9,0x32,0xf2,0x09,0x4c,0x06,0x43,0x18,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x01,0x40,0x01,0x80,0x00,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_umbrella 16
#define sdl_std_cursor_HEIGHT_umbrella 16
#define sdl_std_cursor_HOT_X_umbrella -7
#define sdl_std_cursor_HOT_Y_umbrella -12
static unsigned char sdl_std_cursor_mask_top_side[]= {0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xc0,0x01,0xe0,0x03,0xf0,0x07,0xf8,0x0f,0xdc,0x1d,0xcc,0x19,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,};
static unsigned char sdl_std_cursor_top_side[]= {0xff,0x1f,0xff,0x1f,0x00,0x00,0x40,0x00,0xe0,0x00,0x50,0x01,0x48,0x02,0x44,0x04,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_top_side 15
#define sdl_std_cursor_HEIGHT_top_side 16
#define sdl_std_cursor_HOT_X_top_side -6
#define sdl_std_cursor_HOT_Y_top_side -14
static unsigned char sdl_std_cursor_mask_top_right_corner[]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf0,0xfc,0xf7,0xfc,0xf7,0xfc,0xf7,0xc0,0xf7,0xe0,0xf7,0x70,0xf7,0x38,0xf7,0x1c,0xf7,0x0c,0xf7,0x00,0xf0,0x00,0xf0,};
static unsigned char sdl_std_cursor_top_right_corner[]= {0xff,0x3f,0xff,0x3f,0x00,0x30,0x00,0x30,0x00,0x30,0xfc,0x31,0x80,0x31,0x40,0x31,0x20,0x31,0x10,0x31,0x08,0x31,0x04,0x31,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_top_right_corner 16
#define sdl_std_cursor_HEIGHT_top_right_corner 16
#define sdl_std_cursor_HOT_X_top_right_corner -13
#define sdl_std_cursor_HOT_Y_top_right_corner -14
static unsigned char sdl_std_cursor_mask_top_left_corner[]= {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xef,0x3f,0xef,0x3f,0xef,0x3f,0xef,0x03,0xef,0x07,0xef,0x0e,0xef,0x1c,0xef,0x38,0xef,0x30,0x0f,0x00,0x0f,0x00,};
static unsigned char sdl_std_cursor_top_left_corner[]= {0xff,0x3f,0xff,0x3f,0x03,0x00,0x03,0x00,0x03,0x00,0xe3,0x0f,0x63,0x00,0xa3,0x00,0x23,0x01,0x23,0x02,0x23,0x04,0x23,0x08,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_top_left_corner 16
#define sdl_std_cursor_HEIGHT_top_left_corner 16
#define sdl_std_cursor_HOT_X_top_left_corner 0
#define sdl_std_cursor_HOT_Y_top_left_corner -14
static unsigned char sdl_std_cursor_mask_spraycan[]= {0x00,0x0c,0x18,0x0d,0x7c,0x0d,0x7c,0x0d,0x7e,0x0d,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,};
static unsigned char sdl_std_cursor_spraycan[]= {0x00,0x06,0x80,0x00,0x2c,0x06,0x9e,0x00,0x16,0x06,0x3f,0x00,0x21,0x00,0x27,0x00,0x25,0x00,0x27,0x00,0x25,0x00,0x27,0x00,0x27,0x00,0x21,0x00,0x21,0x00,0x3f,0x00,};
#define sdl_std_cursor_WIDTH_spraycan 12
#define sdl_std_cursor_HEIGHT_spraycan 16
#define sdl_std_cursor_HOT_X_spraycan -9
#define sdl_std_cursor_HOT_Y_spraycan -14
static unsigned char sdl_std_cursor_mask_sb_v_double_arrow[]= {0x38,0x00,0x7c,0x00,0xfe,0x00,0xff,0x01,0xff,0x01,0x7c,0x00,0x7c,0x00,0x7c,0x00,0x7c,0x00,0x7c,0x00,0xff,0x01,0xff,0x01,0xfe,0x00,0x7c,0x00,0x38,0x00,};
static unsigned char sdl_std_cursor_sb_v_double_arrow[]= {0x10,0x00,0x38,0x00,0x7c,0x00,0xfe,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0xfe,0x00,0x7c,0x00,0x38,0x00,0x10,0x00,};
#define sdl_std_cursor_WIDTH_sb_v_double_arrow 9
#define sdl_std_cursor_HEIGHT_sb_v_double_arrow 15
#define sdl_std_cursor_HOT_X_sb_v_double_arrow -3
#define sdl_std_cursor_HOT_Y_sb_v_double_arrow -8
static unsigned char sdl_std_cursor_mask_sb_h_double_arrow[]= {0x18,0x0c,0x1c,0x1c,0xfe,0x3f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xfe,0x3f,0x1c,0x1c,0x18,0x0c,};
static unsigned char sdl_std_cursor_sb_h_double_arrow[]= {0x00,0x00,0x08,0x08,0x0c,0x18,0xfe,0x3f,0x0f,0x78,0xfe,0x3f,0x0c,0x18,0x08,0x08,0x00,0x00};
#define sdl_std_cursor_WIDTH_sb_h_double_arrow 15
#define sdl_std_cursor_HEIGHT_sb_h_double_arrow 9
#define sdl_std_cursor_HOT_X_sb_h_double_arrow -7
#define sdl_std_cursor_HOT_Y_sb_h_double_arrow -4
static unsigned char sdl_std_cursor_mask_right_side[]= {0x00,0xf0,0x00,0xf0,0xc0,0xf0,0xc0,0xf1,0x80,0xf3,0x00,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xf7,0x80,0xf3,0xc0,0xf1,0xc0,0xf0,0x00,0xf0,0x00,0xf0,};
static unsigned char sdl_std_cursor_right_side[]= {0x00,0x30,0x00,0x30,0x40,0x30,0x80,0x30,0x00,0x31,0x00,0x32,0xff,0x37,0x00,0x32,0x00,0x31,0x80,0x30,0x40,0x30,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_right_side 16
#define sdl_std_cursor_HEIGHT_right_side 15
#define sdl_std_cursor_HOT_X_right_side -13
#define sdl_std_cursor_HOT_Y_right_side -7
static unsigned char sdl_std_cursor_mask_right_ptr[]= {0x00,0x03,0x80,0x03,0xc0,0x03,0xe0,0x03,0xf0,0x03,0xf8,0x03,0xfc,0x03,0xfe,0x03,0xff,0x03,0xff,0x03,0xf8,0x03,0xbc,0x03,0x3c,0x03,0x1e,0x00,0x1e,0x00,0x0c,0x00,};
static unsigned char sdl_std_cursor_right_ptr[]= {0x00,0x80,0x00,0xc0,0x00,0xe0,0x00,0xf0,0x00,0xf8,0x00,0xfc,0x00,0xfe,0x00,0xff,0x00,0xf8,0x00,0xd8,0x00,0x8c,0x00,0x0c,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_right_ptr 10
#define sdl_std_cursor_HEIGHT_right_ptr 16
#define sdl_std_cursor_HOT_X_right_ptr -7
#define sdl_std_cursor_HOT_Y_right_ptr -14
static unsigned char sdl_std_cursor_mask_question_arrow[]= {0xf8,0x00,0xfc,0x01,0xfe,0x03,0xff,0x07,0x8f,0x07,0x9f,0x07,0xde,0x07,0xfc,0x03,0xf8,0x01,0xf8,0x00,0xf8,0x00,0xfc,0x01,0xfe,0x03,0xfc,0x01,0xf8,0x00,0x70,0x00,};
static unsigned char sdl_std_cursor_question_arrow[]= {0x7c,0x00,0xfe,0x00,0xc7,0x01,0x83,0x01,0x87,0x01,0xc6,0x01,0xe0,0x00,0x78,0x00,0x38,0x00,0x28,0x00,0x28,0x00,0xee,0x00,0x6c,0x00,0x38,0x00,0x10,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_question_arrow 11
#define sdl_std_cursor_HEIGHT_question_arrow 16
#define sdl_std_cursor_HOT_X_question_arrow -4
#define sdl_std_cursor_HOT_Y_question_arrow -8
static unsigned char sdl_std_cursor_mask_pirate[]= {0xf0,0x03,0xf8,0x07,0xfc,0x0f,0xfe,0x1f,0xfe,0x1f,0xfc,0x0f,0xf8,0x07,0xf1,0x83,0xf1,0xe3,0xf3,0xf3,0xef,0x39,0x1e,0x1e,0xe0,0x01,0xfe,0xc7,0xff,0xff,0x0f,0x7c,};
static unsigned char sdl_std_cursor_pirate[]= {0xe0,0x01,0xf0,0x03,0xf8,0x07,0xcc,0x0c,0xcc,0x0c,0xf8,0x07,0xf0,0x03,0xe0,0x01,0xe1,0x21,0xe1,0x61,0xc2,0x10,0x1c,0x0e,0xe0,0x01,0xf8,0x47,0x0f,0x7c,0x01,0x20,};
#define sdl_std_cursor_WIDTH_pirate 16
#define sdl_std_cursor_HEIGHT_pirate 16
#define sdl_std_cursor_HOT_X_pirate -7
#define sdl_std_cursor_HOT_Y_pirate -4
static unsigned char sdl_std_cursor_mask_left_side[]= {0x0f,0x00,0x0f,0x00,0x0f,0x03,0x8f,0x03,0xcf,0x01,0xef,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x00,0xcf,0x01,0x8f,0x03,0x0f,0x03,0x0f,0x00,0x0f,0x00,};
static unsigned char sdl_std_cursor_left_side[]= {0x03,0x00,0x03,0x00,0x83,0x00,0x43,0x00,0x23,0x00,0x13,0x00,0xfb,0x3f,0x13,0x00,0x23,0x00,0x43,0x00,0x83,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_left_side 16
#define sdl_std_cursor_HEIGHT_left_side 15
#define sdl_std_cursor_HOT_X_left_side 0
#define sdl_std_cursor_HOT_Y_left_side -7
static unsigned char sdl_std_cursor_mask_left_ptr[]= {0x03,0x00,0x07,0x00,0x0f,0x00,0x1f,0x00,0x3f,0x00,0x7f,0x00,0xff,0x00,0xff,0x01,0xff,0x03,0xff,0x03,0x7f,0x00,0xf7,0x00,0xf3,0x00,0xe0,0x01,0xe0,0x01,0xc0,0x00,};
static unsigned char sdl_std_cursor_left_ptr[]= {0x00,0x00,0x02,0x00,0x06,0x00,0x0e,0x00,0x1e,0x00,0x3e,0x00,0x7e,0x00,0xfe,0x00,0xfe,0x00,0x3e,0x00,0x36,0x00,0x62,0x00,0x60,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_left_ptr 10
#define sdl_std_cursor_HEIGHT_left_ptr 16
#define sdl_std_cursor_HOT_X_left_ptr -8
#define sdl_std_cursor_HOT_Y_left_ptr -14
static unsigned char sdl_std_cursor_mask_exchange[]= {0xe3,0x07,0xf7,0x0f,0xff,0x1f,0xff,0x3f,0x3f,0x38,0xff,0x30,0xff,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x0c,0xfe,0x1c,0xfc,0xfc,0xff,0xf8,0xff,0xf0,0xef,0xe0,0xc7,};
static unsigned char sdl_std_cursor_exchange[]= {0xf1,0x03,0xfb,0x07,0x1f,0x0c,0x09,0x08,0x19,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x26,0x04,0x24,0x0c,0x3e,0xf8,0x37,0xf0,0x23,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_exchange 16
#define sdl_std_cursor_HEIGHT_exchange 16
#define sdl_std_cursor_HOT_X_exchange -6
#define sdl_std_cursor_HOT_Y_exchange -8
static unsigned char sdl_std_cursor_mask_crosshair[]= {0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,};
static unsigned char sdl_std_cursor_crosshair[]= {0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x7f,0xff,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_crosshair 16
#define sdl_std_cursor_HEIGHT_crosshair 16
#define sdl_std_cursor_HOT_X_crosshair -7
#define sdl_std_cursor_HOT_Y_crosshair -8
static unsigned char sdl_std_cursor_mask_bottom_side[]= {0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xc0,0x01,0xcc,0x19,0xdc,0x1d,0xf8,0x0f,0xf0,0x07,0xe0,0x03,0xc0,0x01,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,};
static unsigned char sdl_std_cursor_bottom_side[]= {0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x44,0x04,0x48,0x02,0x50,0x01,0xe0,0x00,0x40,0x00,0x00,0x00,0xff,0x1f,0xff,0x1f,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_bottom_side 15
#define sdl_std_cursor_HEIGHT_bottom_side 16
#define sdl_std_cursor_HOT_X_bottom_side -6
#define sdl_std_cursor_HOT_Y_bottom_side -1
static unsigned char sdl_std_cursor_mask_bottom_right_corner[]= {0x00,0xf0,0x00,0xf0,0x0c,0xf7,0x1c,0xf7,0x38,0xf7,0x70,0xf7,0xe0,0xf7,0xc0,0xf7,0xfc,0xf7,0xfc,0xf7,0xfc,0xf7,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,};
static unsigned char sdl_std_cursor_bottom_right_corner[]= {0x00,0x30,0x00,0x30,0x04,0x31,0x08,0x31,0x10,0x31,0x20,0x31,0x40,0x31,0x80,0x31,0xfc,0x31,0x00,0x30,0x00,0x30,0x00,0x30,0xff,0x3f,0xff,0x3f,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_bottom_right_corner 16
#define sdl_std_cursor_HEIGHT_bottom_right_corner 16
#define sdl_std_cursor_HOT_X_bottom_right_corner -13
#define sdl_std_cursor_HOT_Y_bottom_right_corner -1
static unsigned char sdl_std_cursor_mask_bottom_left_corner[]= {0x0f,0x00,0x0f,0x00,0xef,0x30,0xef,0x38,0xef,0x1c,0xef,0x0e,0xef,0x07,0xef,0x03,0xef,0x3f,0xef,0x3f,0xef,0x3f,0x0f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,};
static unsigned char sdl_std_cursor_bottom_left_corner[]= {0x03,0x00,0x03,0x00,0x23,0x08,0x23,0x04,0x23,0x02,0x23,0x01,0xa3,0x00,0x63,0x00,0xe3,0x0f,0x03,0x00,0x03,0x00,0x03,0x00,0xff,0x3f,0xff,0x3f,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_bottom_left_corner 16
#define sdl_std_cursor_HEIGHT_bottom_left_corner 16
#define sdl_std_cursor_HOT_X_bottom_left_corner 0
#define sdl_std_cursor_HOT_Y_bottom_left_corner -1
static unsigned char sdl_std_cursor_mask_arrow[]= {0x00,0xe0,0x00,0xf8,0x00,0xfe,0x80,0x7f,0xe0,0x7f,0xf8,0x3f,0xfc,0x3f,0xfc,0x1f,0xe0,0x1f,0xf0,0x0f,0xf8,0x0f,0x7c,0x07,0x3e,0x07,0x1f,0x02,0x0e,0x00,0x04,0x00,};
static unsigned char sdl_std_cursor_arrow[]= {0x00,0x30,0x00,0x3c,0x00,0x1f,0xc0,0x1f,0xf0,0x0f,0xfc,0x0f,0xc0,0x07,0xe0,0x07,0x70,0x03,0x38,0x03,0x1c,0x01,0x0e,0x01,0x07,0x00,0x02,0x00,0x00,0x00,0x00,0x00,};
#define sdl_std_cursor_WIDTH_arrow 16
#define sdl_std_cursor_HEIGHT_arrow 16
#define sdl_std_cursor_HOT_X_arrow -13
#define sdl_std_cursor_HOT_Y_arrow -14
/* end cursor data */
static SDL_Cursor *sdl_std_cursor_array[(int)GHOST_kStandardCursorNumCursors]= {0};
/* utility function mostly a copy of SDL_CreateCursor but allows us to change
* color and supports blenders flipped bits */
static SDL_Cursor *
sdl_ghost_CreateCursor(const Uint8 *data,
const Uint8 *mask,
int w,
int h,
int hot_x,
int hot_y)
{
SDL_Surface *surface;
SDL_Cursor *cursor;
int x, y;
Uint32 *pixel;
Uint8 datab= 0, maskb= 0;
const Uint32 black= 0xFF000000;
const Uint32 white= 0xFFFFFFFF;
const Uint32 transparent= 0x00000000;
/* Make sure the width is a multiple of 8 */
w= ((w + 7) & ~7);
/* Create the surface from a bitmap */
surface= SDL_CreateRGBSurface(0, w, h, 32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000);
if (!surface) {
return NULL;
}
for (y= 0; y < h; ++y) {
pixel= (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch);
for (x= 0; x < w; ++x) {
if ((x % 8) == 0) {
datab= *data++;
maskb= *mask++;
/* reverse bit order */
datab= (datab * 0x0202020202ULL & 0x010884422010ULL) % 1023;
maskb= (maskb * 0x0202020202ULL & 0x010884422010ULL) % 1023;
}
if (maskb & 0x80) {
*pixel++= (datab & 0x80) ? white : black;
}
else {
*pixel++= (datab & 0x80) ? white : transparent;
}
datab <<= 1;
maskb <<= 1;
}
}
cursor= SDL_CreateColorCursor(surface, hot_x, hot_y);
SDL_FreeSurface(surface);
return cursor;
}
/* TODO, this is currently never freed but it wont leak either. */
static void sdl_cursor_init(void)
{
#define DEF_CURSOR(name, ind) \
assert(\
(\
sdl_std_cursor_array[(int)ind]= \
sdl_ghost_CreateCursor(sdl_std_cursor_##name, \
sdl_std_cursor_mask_##name, \
sdl_std_cursor_WIDTH_##name, \
sdl_std_cursor_HEIGHT_##name, \
(sdl_std_cursor_WIDTH_##name + (sdl_std_cursor_HOT_X_##name)) - 1, \
(sdl_std_cursor_HEIGHT_##name + (sdl_std_cursor_HOT_Y_##name)) - 1) \
) != NULL) \
DEF_CURSOR(left_ptr, GHOST_kStandardCursorDefault);
DEF_CURSOR(right_ptr, GHOST_kStandardCursorRightArrow);
DEF_CURSOR(left_ptr, GHOST_kStandardCursorLeftArrow);
DEF_CURSOR(umbrella, GHOST_kStandardCursorInfo); // TODO, replace this one.
DEF_CURSOR(pirate, GHOST_kStandardCursorDestroy);
DEF_CURSOR(question_arrow, GHOST_kStandardCursorHelp);
DEF_CURSOR(exchange, GHOST_kStandardCursorCycle);
DEF_CURSOR(spraycan, GHOST_kStandardCursorSpray);
DEF_CURSOR(watch, GHOST_kStandardCursorWait);
DEF_CURSOR(xterm, GHOST_kStandardCursorText);
DEF_CURSOR(crosshair, GHOST_kStandardCursorCrosshair);
DEF_CURSOR(sb_v_double_arrow, GHOST_kStandardCursorUpDown);
DEF_CURSOR(sb_h_double_arrow, GHOST_kStandardCursorLeftRight);
DEF_CURSOR(top_side, GHOST_kStandardCursorTopSide);
DEF_CURSOR(bottom_side, GHOST_kStandardCursorBottomSide);
DEF_CURSOR(left_side, GHOST_kStandardCursorLeftSide);
DEF_CURSOR(right_side, GHOST_kStandardCursorRightSide);
DEF_CURSOR(top_left_corner, GHOST_kStandardCursorTopLeftCorner);
DEF_CURSOR(top_right_corner, GHOST_kStandardCursorTopRightCorner);
DEF_CURSOR(bottom_right_corner, GHOST_kStandardCursorBottomRightCorner);
DEF_CURSOR(bottom_left_corner , GHOST_kStandardCursorBottomLeftCorner);
DEF_CURSOR(arrow , GHOST_kStandardCursorCopy);
//DEF_CURSOR(arrow, GHOST_kStandardCursorCustom);
DEF_CURSOR(arrow, GHOST_kStandardCursorPencil);
#undef DEF_CURSOR
}
GHOST_TSuccess
GHOST_WindowSDL::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
{
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setWindowCursorShape(GHOST_TStandardCursor shape)
{
if(sdl_std_cursor_array[0] == NULL) {
sdl_cursor_init();
}
SDL_SetCursor(sdl_std_cursor_array[(int)shape]);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX,
int hotY)
{
return setWindowCustomCursorShape((GHOST_TUns8 *)bitmap,
(GHOST_TUns8 *)mask,
16, 16,
hotX, hotY,
0, 1);
}
GHOST_TSuccess
GHOST_WindowSDL::setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex, int sizey,
int hotX, int hotY,
int fg_color, int bg_color)
{
if(m_sdl_custom_cursor) {
SDL_FreeCursor(m_sdl_custom_cursor);
}
m_sdl_custom_cursor= sdl_ghost_CreateCursor((const Uint8 *)bitmap,
(const Uint8 *)mask,
sizex, sizex,
hotX, hotY);
SDL_SetCursor(m_sdl_custom_cursor);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setWindowCursorVisibility(bool visible)
{
SDL_ShowCursor(visible);
return GHOST_kSuccess;
}

@ -0,0 +1,167 @@
/*
* $Id$
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): Campbell Barton
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ghost/intern/GHOST_WindowSDL.h
* \ingroup GHOST
* Declaration of GHOST_WindowSDL class.
*/
#ifndef _GHOST_WINDOWSDL_H_
#define _GHOST_WINDOWSDL_H_
#include "GHOST_Window.h"
#include "GHOST_SystemSDL.h"
#include <map>
extern "C" {
#include "SDL.h"
}
#if !SDL_VERSION_ATLEAST(1, 3, 0)
# error "SDL 1.3 or newer is needed to build with Ghost"
#endif
class STR_String;
class GHOST_WindowSDL : public GHOST_Window
{
private :
GHOST_SystemSDL * m_system;
bool m_invalid_window;
SDL_Window * m_sdl_win;
SDL_GLContext m_sdl_glcontext;
SDL_Cursor * m_sdl_custom_cursor;
public:
const GHOST_TabletData* GetTabletData() { return NULL; }
GHOST_WindowSDL(GHOST_SystemSDL *system,
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top,
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples
);
~GHOST_WindowSDL();
/* SDL spesific */
SDL_Window *
getSDLWindow()
{
return m_sdl_win;
}
GHOST_TSuccess invalidate(void);
/**
* called by the X11 system implementation when expose events
* for the window have been pushed onto the GHOST queue
*/
void validate()
{
m_invalid_window = false;
}
bool getValid() const
{
return (m_sdl_win != NULL);
}
void getWindowBounds(GHOST_Rect& bounds) const;
void getClientBounds(GHOST_Rect& bounds) const;
protected:
GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
GHOST_TSuccess removeDrawingContext();
GHOST_TSuccess
setWindowCursorGrab(GHOST_TGrabCursorMode mode);
GHOST_TSuccess
setWindowCursorShape(GHOST_TStandardCursor shape);
GHOST_TSuccess
setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
GHOST_TUns8 mask[16][2],
int hotX, int hotY);
GHOST_TSuccess
setWindowCustomCursorShape(GHOST_TUns8 *bitmap,
GHOST_TUns8 *mask,
int sizex, int sizey,
int hotX, int hotY,
int fg_color, int bg_color);
GHOST_TSuccess
setWindowCursorVisibility(bool visible);
void
setTitle(const STR_String& title);
void
getTitle(STR_String& title) const;
GHOST_TSuccess
setClientWidth(GHOST_TUns32 width);
GHOST_TSuccess
setClientHeight(GHOST_TUns32 height);
GHOST_TSuccess
setClientSize(GHOST_TUns32 width,
GHOST_TUns32 height);
void
screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32& outX, GHOST_TInt32& outY) const;
void
clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32& outX, GHOST_TInt32& outY) const;
GHOST_TSuccess
swapBuffers();
GHOST_TSuccess
activateDrawingContext();
GHOST_TSuccess
setState(GHOST_TWindowState state);
GHOST_TWindowState
getState() const;
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) { return GHOST_kSuccess; } // TODO
};
#endif // _GHOST_WINDOWSDL_H_

@ -243,7 +243,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre
int iNrActiveGroups = 0, index = 0;
const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext);
tbool bRes = TFALSE;
const float fThresCos = (const float) cos((fAngularThreshold*(float)M_PI)/180.0f);
const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f);
// verify all call-backs have been set
if( pContext->m_pInterface->m_getNumFaces==NULL ||
@ -1411,7 +1411,7 @@ STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[]
// weight contribution by the angle
// between the two edge vectors
fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos);
fAngle = (const float) acos(fCos);
fAngle = (float) acos(fCos);
fMagS = pTriInfos[f].fMagS;
fMagT = pTriInfos[f].fMagT;

@ -84,12 +84,14 @@ set(SRC
)
if(WITH_OPENMP)
add_definitions(-DPARALLEL=1)
add_definitions(-DPARALLEL=1)
endif()
if(WITH_FFTW3)
add_definitions(-DFFTW3=1)
list(APPEND INC ${FFTW3_INCLUDE_DIRS})
list(APPEND INC
${FFTW3_INCLUDE_DIRS}
)
endif()
blender_add_lib(bf_intern_smoke "${SRC}" "${INC}" "${INC_SYS}")

@ -31,6 +31,8 @@ __all__ = (
import bpy as _bpy
error_duplicates = False
def paths():
# RELEASE SCRIPTS: official scripts distributed in Blender releases
paths = _bpy.utils.script_paths("addons")
@ -47,8 +49,11 @@ def paths():
def modules(module_cache):
global error_duplicates
import os
error_duplicates = False
path_list = paths()
# fake module importing
@ -117,7 +122,12 @@ def modules(module_cache):
modules_stale -= {mod_name}
mod = module_cache.get(mod_name)
if mod:
if mod.__time__ != os.path.getmtime(mod_path):
if mod.__file__ != mod_path:
print("multiple addons with the same name:\n %r\n %r" %
(mod.__file__, mod_path))
error_duplicates = True
elif mod.__time__ != os.path.getmtime(mod_path):
print("reloading addon:", mod_name, mod.__time__, os.path.getmtime(mod_path), mod_path)
del module_cache[mod_name]
mod = None

@ -35,7 +35,7 @@ def abspath(path, start=None):
:type start: string
"""
if path.startswith("//"):
return _os.path.join(_os.path.dirname(_bpy.data.filepath if start is None else start), path[2:])
return _os.path.join(_os.path.dirname(_bpy.data.filepath) if start is None else start, path[2:])
return path
@ -117,7 +117,7 @@ def display_name_from_filepath(name):
"""
Returns the path stripped of directort and extension, ensured to be utf8 compatible.
"""
return _os.path.splitext(_os.path.basename(name))[0].encode("utf8", "replace").decode("utf8")
return _os.path.splitext(basename(name))[0].encode("utf8", "replace").decode("utf8")
def resolve_ncase(path):
@ -231,3 +231,12 @@ def module_names(path, recursive=False):
modules.append(("%s.%s" % (filename, mod_name), mod_path))
return modules
def basename(path):
"""
Equivalent to os.path.basename, but skips a "//" suffix.
Use for Windows compatibility.
"""
return _os.path.basename(path[2:] if path.startswith("//") else path)

@ -298,11 +298,18 @@ _presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths
def preset_paths(subdir):
"""
Returns a list of paths for a specific preset.
:arg subdir: preset subdirectory (must not be an absolute path).
:type subdir: string
:return: script paths.
:rtype: list
"""
dirs = []
for path in script_paths("presets", all=True):
directory = _os.path.join(path, subdir)
if _os.path.isdir(directory):
if not directory.startswith(path):
raise Exception("invalid subdir given %r" % subdir)
elif _os.path.isdir(directory):
dirs.append(directory)
return dirs

@ -86,7 +86,9 @@ def load_image(imagepath,
variants = [imagepath]
if dirname:
variants += [os.path.join(dirname, imagepath), os.path.join(dirname, os.path.basename(imagepath))]
variants += [os.path.join(dirname, imagepath),
os.path.join(dirname, bpy.path.basename(imagepath)),
]
for filepath_test in variants:
if ncase_cmp:
@ -99,7 +101,7 @@ def load_image(imagepath,
return _image_load(nfilepath)
if place_holder:
image = bpy.data.images.new(os.path.basename(imagepath), 128, 128)
image = bpy.data.images.new(bpy.path.basename(imagepath), 128, 128)
# allow the path to be resolved later
image.filepath = imagepath
return image

@ -22,6 +22,7 @@ __all__ = (
"ExportHelper",
"ImportHelper",
"axis_conversion",
"axis_conversion_ensure",
"create_derived_objects",
"free_derived_objects",
"unpack_list",
@ -154,12 +155,50 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'):
if from_forward == to_forward and from_up == to_up:
return Matrix().to_3x3()
if from_forward[-1] == from_up[-1] or to_forward[-1] == to_up[-1]:
raise Exception("invalid axis arguments passed, "
"can't use up/forward on the same axis.")
value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3) for i, a in enumerate((from_forward, from_up, to_forward, to_up))))
for i, axis_lut in enumerate(_axis_convert_lut):
if value in axis_lut:
return Matrix(_axis_convert_matrix[i])
assert("internal error")
assert(0)
def axis_conversion_ensure(operator, forward_attr, up_attr):
"""
Function to ensure an operator has valid axis conversion settings, intended
to be used from :class:`Operator.check`.
:arg operator: the operator to access axis attributes from.
:type operator: :class:`Operator`
:arg forward_attr:
:type forward_attr: string
:arg up_attr: the directory the *filepath* will be referenced from (normally the export path).
:type up_attr: string
:return: True if the value was modified.
:rtype: boolean
"""
def validate(axis_forward, axis_up):
if axis_forward[-1] == axis_up[-1]:
axis_up = axis_up[0:-1] + 'XYZ'[('XYZ'.index(axis_up[-1]) + 1) % 3]
return axis_forward, axis_up
change = False
axis = getattr(operator, forward_attr), getattr(operator, up_attr)
axis_new = validate(*axis)
if axis != axis_new:
setattr(operator, forward_attr, axis_new[0])
setattr(operator, up_attr, axis_new[1])
return True
else:
return False
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()

@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8-80 compliant>
__all__ = (
"mesh_linked_faces",
@ -25,6 +25,7 @@ __all__ = (
"edge_loops_from_faces",
"edge_loops_from_edges",
"ngon_tesselate",
"face_random_points",
)
@ -67,7 +68,8 @@ def mesh_linked_faces(mesh):
if mapped_index != nxt_mapped_index:
ok = True
# Assign mapping to this group so they all map to this group
# Assign mapping to this group so they
# all map to this group
for grp_f in face_groups[nxt_mapped_index]:
face_mapping[grp_f.index] = mapped_index
@ -433,3 +435,70 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
fill[i] = tuple([ii for ii in reversed(fi)])
return fill
def face_random_points(num_points, faces):
"""
Generates a list of random points over mesh faces.
:arg num_points: the number of random points to generate on each face.
:type int:
:arg faces: list of the faces to generate points on.
:type faces: :class:`MeshFaces`, sequence
:return: list of random points over all faces.
:rtype: list
"""
from random import random
from mathutils.geometry import area_tri
# Split all quads into 2 tris, tris remain unchanged
tri_faces = []
for f in faces:
tris = []
verts = f.id_data.vertices
fv = f.vertices[:]
tris.append((verts[fv[0]].co,
verts[fv[1]].co,
verts[fv[2]].co,
))
if len(fv) == 4:
tris.append((verts[fv[0]].co,
verts[fv[3]].co,
verts[fv[2]].co,
))
tri_faces.append(tris)
# For each face, generate the required number of random points
sampled_points = [None] * (num_points * len(faces))
for i, tf in enumerate(tri_faces):
for k in range(num_points):
# If this is a quad, we need to weight its 2 tris by their area
if len(tf) != 1:
area1 = area_tri(*tf[0])
area2 = area_tri(*tf[1])
area_tot = area1 + area2
area1 = area1 / area_tot
area2 = area2 / area_tot
vecs = tf[0 if (random() < area1) else 1]
else:
vecs = tf[0]
u1 = random()
u2 = random()
u_tot = u1 + u2
if u_tot > 1:
u1 = 1.0 - u1
u2 = 1.0 - u2
side1 = vecs[1] - vecs[0]
side2 = vecs[2] - vecs[0]
p = vecs[0] + u1 * side1 + u2 * side2
sampled_points[num_points * i + k] = p
return sampled_points

@ -163,7 +163,7 @@ class ProjectEdit(bpy.types.Operator):
filepath_final = filepath + ("%.3d.%s" % (i, EXT))
i += 1
image_new.name = os.path.basename(filepath_final)
image_new.name = bpy.path.basename(filepath_final)
ProjectEdit._proj_hack[0] = image_new.name
image_new.filepath_raw = filepath_final # TODO, filepath raw is crummy

@ -21,13 +21,102 @@
import bpy
from mathutils import Vector
def GlobalBB_LQ(bb_world):
# Initialize the variables with the 8th vertex
left, right, front, back, down, up =\
bb_world[7][0],\
bb_world[7][0],\
bb_world[7][1],\
bb_world[7][1],\
bb_world[7][2],\
bb_world[7][2]
# Test against the other 7 verts
for i in range (7):
# X Range
val = bb_world[i][0]
if val < left:
left = val
if val > right:
right = val
# Y Range
val = bb_world[i][1]
if val < front:
front = val
if val > back:
back = val
# Z Range
val = bb_world[i][2]
if val < down:
down = val
if val > up:
up = val
return (Vector((left, front, up)), Vector((right, back, down)))
def align_objects(align_x, align_y, align_z, align_mode, relative_to):
def GlobalBB_HQ(obj):
matrix_world = obj.matrix_world.copy()
# Initialize the variables with the last vertex
verts = obj.data.vertices
val = verts[-1].co * matrix_world
left, right, front, back, down, up =\
val[0],\
val[0],\
val[1],\
val[1],\
val[2],\
val[2]
# Test against all other verts
for i in range (len(verts)-1):
vco = verts[i].co * matrix_world
# X Range
val = vco[0]
if val < left:
left = val
if val > right:
right = val
# Y Range
val = vco[1]
if val < front:
front = val
if val > back:
back = val
# Z Range
val = vco[2]
if val < down:
down = val
if val > up:
up = val
return (Vector((left, front, up)), Vector((right, back, down)))
def align_objects(align_x, align_y, align_z, align_mode, relative_to, bb_quality):
cursor = bpy.context.scene.cursor_location
Left_Up_Front_SEL = [0.0, 0.0, 0.0]
Right_Down_Back_SEL = [0.0, 0.0, 0.0]
Left_Front_Up_SEL = [0.0, 0.0, 0.0]
Right_Back_Down_SEL = [0.0, 0.0, 0.0]
flag_first = True
@ -42,78 +131,89 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
return False
for obj, bb_world in objs:
Left_Up_Front = bb_world[1]
Right_Down_Back = bb_world[7]
if bb_quality:
GBB = GlobalBB_HQ(obj)
else:
GBB = GlobalBB_LQ(bb_world)
Left_Front_Up = GBB[0]
Right_Back_Down = GBB[1]
# Active Center
if obj == bpy.context.active_object:
center_active_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
center_active_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
center_active_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
center_active_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
center_active_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
center_active_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0
size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2.0
size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2.0
size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2.0
size_active_x = (Right_Back_Down[0] - Left_Front_Up[0]) / 2.0
size_active_y = (Right_Back_Down[1] - Left_Front_Up[1]) / 2.0
size_active_z = (Left_Front_Up[2] - Right_Back_Down[2]) / 2.0
# Selection Center
if flag_first:
flag_first = False
Left_Up_Front_SEL[0] = Left_Up_Front[0]
Left_Up_Front_SEL[1] = Left_Up_Front[1]
Left_Up_Front_SEL[2] = Left_Up_Front[2]
Left_Front_Up_SEL[0] = Left_Front_Up[0]
Left_Front_Up_SEL[1] = Left_Front_Up[1]
Left_Front_Up_SEL[2] = Left_Front_Up[2]
Right_Down_Back_SEL[0] = Right_Down_Back[0]
Right_Down_Back_SEL[1] = Right_Down_Back[1]
Right_Down_Back_SEL[2] = Right_Down_Back[2]
Right_Back_Down_SEL[0] = Right_Back_Down[0]
Right_Back_Down_SEL[1] = Right_Back_Down[1]
Right_Back_Down_SEL[2] = Right_Back_Down[2]
else:
# X axis
if Left_Up_Front[0] < Left_Up_Front_SEL[0]:
Left_Up_Front_SEL[0] = Left_Up_Front[0]
if Left_Front_Up[0] < Left_Front_Up_SEL[0]:
Left_Front_Up_SEL[0] = Left_Front_Up[0]
# Y axis
if Left_Up_Front[1] < Left_Up_Front_SEL[1]:
Left_Up_Front_SEL[1] = Left_Up_Front[1]
if Left_Front_Up[1] < Left_Front_Up_SEL[1]:
Left_Front_Up_SEL[1] = Left_Front_Up[1]
# Z axis
if Left_Up_Front[2] > Left_Up_Front_SEL[2]:
Left_Up_Front_SEL[2] = Left_Up_Front[2]
if Left_Front_Up[2] > Left_Front_Up_SEL[2]:
Left_Front_Up_SEL[2] = Left_Front_Up[2]
# X axis
if Right_Down_Back[0] > Right_Down_Back_SEL[0]:
Right_Down_Back_SEL[0] = Right_Down_Back[0]
if Right_Back_Down[0] > Right_Back_Down_SEL[0]:
Right_Back_Down_SEL[0] = Right_Back_Down[0]
# Y axis
if Right_Down_Back[1] > Right_Down_Back_SEL[1]:
Right_Down_Back_SEL[1] = Right_Down_Back[1]
if Right_Back_Down[1] > Right_Back_Down_SEL[1]:
Right_Back_Down_SEL[1] = Right_Back_Down[1]
# Z axis
if Right_Down_Back[2] < Right_Down_Back_SEL[2]:
Right_Down_Back_SEL[2] = Right_Down_Back[2]
if Right_Back_Down[2] < Right_Back_Down_SEL[2]:
Right_Back_Down_SEL[2] = Right_Back_Down[2]
center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2.0
center_sel_y = (Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1]) / 2.0
center_sel_z = (Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2]) / 2.0
center_sel_x = (Left_Front_Up_SEL[0] + Right_Back_Down_SEL[0]) / 2.0
center_sel_y = (Left_Front_Up_SEL[1] + Right_Back_Down_SEL[1]) / 2.0
center_sel_z = (Left_Front_Up_SEL[2] + Right_Back_Down_SEL[2]) / 2.0
# Main Loop
for obj, bb_world in objs:
bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box]
if bb_quality:
GBB = GlobalBB_HQ(obj)
else:
GBB = GlobalBB_LQ(bb_world)
Left_Front_Up = GBB[0]
Right_Back_Down = GBB[1]
Left_Up_Front = bb_world[1]
Right_Down_Back = bb_world[7]
center_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0
center_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0
center_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0
center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0
center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0
center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0
positive_x = Right_Back_Down[0]
positive_y = Right_Back_Down[1]
positive_z = Left_Front_Up[2]
positive_x = Right_Down_Back[0]
positive_y = Right_Down_Back[1]
positive_z = Left_Up_Front[2]
negative_x = Left_Up_Front[0]
negative_y = Left_Up_Front[1]
negative_z = Right_Down_Back[2]
negative_x = Left_Front_Up[0]
negative_y = Left_Front_Up[1]
negative_z = Right_Back_Down[2]
obj_loc = obj.location
@ -228,7 +328,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
return True
from bpy.props import EnumProperty
from bpy.props import EnumProperty, BoolProperty
class AlignObjects(bpy.types.Operator):
@ -237,6 +337,11 @@ class AlignObjects(bpy.types.Operator):
bl_label = "Align Objects"
bl_options = {'REGISTER', 'UNDO'}
bb_quality = BoolProperty(
name="High Quality",
description="Enables high quality calculation of the bounding box for perfect results on complex shape meshes with rotation/scale (Slow)",
default=False)
align_mode = EnumProperty(items=(
('OPT_1', "Negative Sides", ""),
('OPT_2', "Centers", ""),
@ -269,10 +374,10 @@ class AlignObjects(bpy.types.Operator):
def execute(self, context):
align_axis = self.align_axis
ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to)
ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to, self.bb_quality)
if not ret:
self.report({'WARNING'}, "No objects with bound-box selected")
return {'CANCELLED'}
else:
return {'FINISHED'}
return {'FINISHED'}

@ -747,14 +747,8 @@ def packIslands(islandList):
def VectoQuat(vec):
a3 = vec.normalized()
up = Vector((0.0, 0.0, 1.0))
if abs(a3.dot(up)) == 1.0:
up = Vector((0.0, 1.0, 0.0))
a1 = a3.cross(up).normalized()
a2 = a3.cross(a1)
return Matrix((a1, a2, a3)).to_quaternion()
vec = vec.normalized()
return vec.to_track_quat('Z', 'X' if abs(vec.x) > 0.5 else 'Y').inverted()
class thickface(object):

@ -174,6 +174,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel):
row.prop(mat, "use_transparency")
sub = row.column()
sub.prop(mat, "offset_z")
sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
row = layout.row()
@ -199,6 +200,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel):
col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_cast_buffer_shadows")
col.prop(mat, "use_cast_approximate")
col.prop(mat, "pass_index")
class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
@ -729,7 +731,8 @@ class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel):
col.prop(mat, "use_vertex_color_paint")
col.prop(mat, "use_vertex_color_light")
col.prop(mat, "use_object_color")
col.prop(mat, "pass_index")
if simple_material(base_mat):
col.prop(mat, "pass_index")
class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel):

@ -88,15 +88,15 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
if not hasattr(context, "texture_slot"):
if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
return False
return ((context.material or context.world or context.lamp or context.brush or context.texture or context.particle_system or isinstance(context.space_data.pin_id, bpy.types.ParticleSettings))
and (engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
slot = context.texture_slot
node = context.texture_node
slot = getattr(context, "texture_slot", None)
node = getattr(context, "texture_node", None)
space = context.space_data
tex = context.texture
idblock = context_tex_datablock(context)
@ -393,7 +393,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
idblock = context_tex_datablock(context)
tex = context.texture
slot = context.texture_slot
slot = getattr(context, "texture_slot", None)
split = layout.split()
@ -408,7 +408,7 @@ class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
col = split.column()
#Only for Material based textures, not for Lamp/World...
if isinstance(idblock, bpy.types.Material):
if slot and isinstance(idblock, bpy.types.Material):
col.prop(tex, "use_normal_map")
row = col.row()
row.active = tex.use_normal_map

@ -135,9 +135,10 @@ class NODE_MT_node(bpy.types.Menu):
layout.operator("transform.resize")
layout.separator()
layout.operator("node.duplicate_move")
layout.operator("node.delete")
layout.operator("node.delete_reconnect")
layout.separator()
layout.operator("node.link_make")

@ -890,6 +890,16 @@ class USERPREF_PT_addons(bpy.types.Panel):
return True
return False
@staticmethod
def draw_error(layout, message):
lines = message.split("\n")
box = layout.box()
rowsub = box.row()
rowsub.label(lines[0])
rowsub.label(icon='ERROR')
for l in lines[1:]:
box.label(l)
def draw(self, context):
layout = self.layout
@ -910,6 +920,14 @@ class USERPREF_PT_addons(bpy.types.Panel):
col = split.column()
# set in addon_utils.modules(...)
if addon_utils.error_duplicates:
self.draw_error(col,
"Multiple addons using the same name found!\n"
"likely a problem with the script search path.\n"
"(see console for details)",
)
filter = context.window_manager.addon_filter
search = context.window_manager.addon_search.lower()
support = context.window_manager.addon_support

@ -0,0 +1,33 @@
# exports each selected object into its own file
import bpy
import os
# export to blend file location
basedir = os.path.dirname(bpy.data.filepath)
if not basedir:
raise Exception("Blend file is not saved")
selection = bpy.context.selected_objects
bpy.ops.object.select_all(action='DESELECT')
for obj in selection:
obj.select = True
name = bpy.path.clean_name(obj.name)
fn = os.path.join(basedir, name)
bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True)
## Can be used for multiple formats
# bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True)
obj.select = False
print("written:", fn)
for obj in selection:
obj.select = True

@ -26,8 +26,8 @@
set(INC
.
../../../intern/guardedalloc
../blenlib
../../../intern/guardedalloc
)
set(INC_SYS

@ -24,10 +24,10 @@
set(INC
.
../blenlib
../makesdna
../editors/include
../blenkernel
../blenlib
../editors/include
../makesdna
../../../intern/guardedalloc
)
@ -50,7 +50,9 @@ set(SRC
)
if(WITH_INTERNATIONAL)
list(APPEND INC_SYS ${GETTEXT_INC})
list(APPEND INC_SYS
${GETTEXT_INC}
)
add_definitions(-DINTERNATIONAL)
endif()

@ -32,8 +32,10 @@ endif()
set(INC
.
../avi
../blenfont
../blenlib
../blenloader
../editors/include
../gpu
../ikplugin
../imbuf
@ -41,18 +43,19 @@ set(INC
../makesrna
../modifiers
../nodes
../editors/include
../render/extern/include
../../../intern/bsp/extern ../blenfont
../../../intern/bsp/extern
../../../intern/decimation/extern
../../../intern/elbeem/extern
../../../intern/guardedalloc
../../../intern/iksolver/extern
../../../intern/memutil
../../../intern/mikktspace
../../../intern/opennl/extern
../../../intern/smoke/extern
../../../intern/mikktspace
../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h
# XXX - BAD LEVEL CALL WM_api.h
../windowmanager
)
set(INC_SYS
@ -243,12 +246,16 @@ if(WITH_AUDASPACE)
endif()
if(WITH_BULLET)
list(APPEND INC ../../../extern/bullet2/src)
list(APPEND INC
../../../extern/bullet2/src
)
add_definitions(-DUSE_BULLET)
endif()
if(WITH_MOD_CLOTH_ELTOPO)
list(APPEND INC ../../../extern/eltopo)
list(APPEND INC
../../../extern/eltopo
)
add_definitions(-DWITH_ELTOPO)
endif()
@ -277,20 +284,32 @@ if(WITH_IMAGE_HDR)
endif()
if(WITH_CODEC_QUICKTIME)
list(APPEND INC ../quicktime)
list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS})
list(APPEND INC
../quicktime
)
list(APPEND INC_SYS
${QUICKTIME_INCLUDE_DIRS}
)
add_definitions(-DWITH_QUICKTIME)
endif()
if(WITH_CODEC_FFMPEG)
list(APPEND INC ../../../intern/ffmpeg)
list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS})
list(APPEND INC
../../../intern/ffmpeg
)
list(APPEND INC_SYS
${FFMPEG_INCLUDE_DIRS}
)
add_definitions(-DWITH_FFMPEG)
endif()
if(WITH_PYTHON)
list(APPEND INC ../python)
list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS})
list(APPEND INC
../python
)
list(APPEND INC_SYS
${PYTHON_INCLUDE_DIRS}
)
add_definitions(-DWITH_PYTHON)
if(WITH_PYTHON_SECURITY)
@ -306,17 +325,25 @@ if(NOT WITH_MOD_FLUID)
add_definitions(-DDISABLE_ELBEEM)
endif()
if(WITH_MOD_SMOKE)
add_definitions(-DWITH_SMOKE)
endif()
if(WITH_JACK)
add_definitions(-DWITH_JACK)
endif()
if(WITH_LZO)
list(APPEND INC_SYS ../../../extern/lzo/minilzo)
list(APPEND INC_SYS
../../../extern/lzo/minilzo
)
add_definitions(-DWITH_LZO)
endif()
if(WITH_LZMA)
list(APPEND INC_SYS ../../../extern/lzma)
list(APPEND INC_SYS
../../../extern/lzma
)
add_definitions(-DWITH_LZMA)
endif()

@ -21,6 +21,8 @@ incs += ' ' + env['BF_ZLIB_INC']
defs = [ 'GLEW_STATIC' ]
defs.append('WITH_SMOKE') # TODO, make optional
if env['WITH_BF_PYTHON']:
incs += ' ../python'
incs += ' ' + env['BF_PYTHON_INC']

@ -432,6 +432,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n
ima->gen_x= width;
ima->gen_y= height;
ima->gen_type= uvtestgrid;
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@ -2172,7 +2173,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
/* UV testgrid or black or solid etc */
if(ima->gen_x==0) ima->gen_x= 1024;
if(ima->gen_y==0) ima->gen_y= 1024;
ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color);
ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok= IMA_OK_LOADED;
}

@ -3987,7 +3987,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
/* clear everythin on start frame */
if((int)cfra == startframe) {
if(cfra == startframe) {
BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, startframe);
cache->flag &= ~PTCACHE_REDO_NEEDED;

@ -516,6 +516,7 @@ static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra))
return clmd->clothObject ? clmd->clothObject->numverts : 0;
}
#ifdef WITH_SMOKE
/* Smoke functions */
static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
{
@ -652,6 +653,11 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
}
}
}
#else // WITH_SMOKE
static int ptcache_smoke_totpoint(void *UNUSED(smoke_v), int UNUSED(cfra)) { return 0; };
static void ptcache_smoke_read(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) {}
static int ptcache_smoke_write(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; }
#endif // WITH_SMOKE
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)

@ -3233,9 +3233,10 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
{
char name[sizeof(seq_a->name)];
if(seq_a->len != seq_b->len)
if(seq_a->len != seq_b->len) {
*error_str= "Strips must be the same length";
return 0;
}
/* type checking, could be more advanced but disalow sound vs non-sound copy */
if(seq_a->type != seq_b->type) {

@ -140,6 +140,19 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
#define TRI_UVOFFSET (1./4.)
/* Stubs to use when smoke is disabled */
#ifndef WITH_SMOKE
struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; }
struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; }
void smoke_free(struct FLUID_3D *UNUSED(fluid)) {}
void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {}
void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {}
void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {}
long long smoke_get_mem_req(int UNUSED(xres), int UNUSED(yres), int UNUSED(zres), int UNUSED(amplify)) { return 0; }
void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) {}
#endif // WITH_SMOKE
static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm)
{
if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
@ -805,6 +818,9 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
// forward decleration
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
#ifdef WITH_SMOKE
static int get_lamp(Scene *scene, float *light)
{
Base *base_tmp = NULL;
@ -1646,3 +1662,4 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
}
}
#endif // WITH_SMOKE

@ -36,9 +36,6 @@
#include "BKE_animsys.h"
static int force_device = -1;
struct bSound* sound_new_file(struct Main *bmain, const char *filename)
{
bSound* sound = NULL;
@ -98,6 +95,8 @@ void sound_free(struct bSound* sound)
#ifdef WITH_AUDASPACE
static int force_device = -1;
#ifdef WITH_JACK
static void sound_sync_callback(void* data, int mode, float time)
{
@ -581,7 +580,7 @@ void sound_play_scene(struct Scene *UNUSED(scene)) {}
void sound_stop_scene(struct Scene *UNUSED(scene)) {}
void sound_seek_scene(struct bContext *UNUSED(C)) {}
float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; }
int sound_scene_playing(struct Scene *UNUSED(scene)) { return 0; }
int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; }

@ -26,10 +26,10 @@
set(INC
.
../makesdna
../blenkernel
../blenloader
../gpu
../makesdna
../../../intern/ghost
../../../intern/guardedalloc
)
@ -138,7 +138,9 @@ set(SRC
)
if(WITH_BINRELOC)
list(APPEND INC_SYS "${BINRELOC_INCLUDE_DIRS}")
list(APPEND INC_SYS
${BINRELOC_INCLUDE_DIRS}
)
add_definitions(-DWITH_BINRELOC)
endif()

@ -1680,7 +1680,7 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
if(GetModuleFileName(0, fullname, maxlen)) {
if(!BLI_exists(fullname)) {
printf("path can't be found: \"%.*s\"\n", maxlen, fullname);
MessageBox(NULL, "path constains invalid characters or is too long (see console)", "Error", MB_OK);
MessageBox(NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK);
}
return;
}

@ -26,8 +26,8 @@
set(INC
.
../blenlib
../blenkernel
../blenlib
../makesdna
../makesrna
../render/extern/include

@ -75,6 +75,7 @@
#include "DNA_node_types.h"
#include "DNA_object_fluidsim.h" // NT
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_property_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
@ -3161,9 +3162,37 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
if(part->effector_weights)
part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
dw = part->dupliweights.first;
for(; dw; dw=dw->next)
dw->ob = newlibadr(fd, part->id.lib, dw->ob);
if(part->dupliweights.first) {
int index_ok = 0;
/* check for old files without indices (all indexes 0) */
dw = part->dupliweights.first;
if(part->dupliweights.first == part->dupliweights.last) {
/* special case for only one object in the group */
index_ok = 1;
}
else {
for(; dw; dw=dw->next) {
if(dw->index > 0) {
index_ok = 1;
break;
}
}
}
if(index_ok) {
/* if we have indexes, let's use them */
dw = part->dupliweights.first;
for(; dw; dw=dw->next) {
GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
dw->ob = go ? go->ob : NULL;
}
}
else {
/* otherwise try to get objects from own library (won't work on library linked groups) */
for(; dw; dw=dw->next)
dw->ob = newlibadr(fd, part->id.lib, dw->ob);
}
}
if(part->boids) {
BoidState *state = part->boids->states.first;
@ -10252,8 +10281,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
sce->gm.attrib = sce->r.attrib;
//Stereo
sce->gm.xsch = sce->r.xsch;
sce->gm.ysch = sce->r.ysch;
sce->gm.stereomode = sce->r.stereomode;
/* reassigning stereomode NO_STEREO and DOME to a separeted flag*/
if (sce->gm.stereomode == 1){ //1 = STEREO_NOSTEREO

@ -837,6 +837,7 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
{
ParticleSettings *part;
ParticleDupliWeight *dw;
GroupObject *go;
int a;
part= idbase->first;
@ -851,8 +852,16 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase)
writestruct(wd, DATA, "EffectorWeights", 1, part->effector_weights);
dw = part->dupliweights.first;
for(; dw; dw=dw->next)
for(; dw; dw=dw->next) {
/* update indices */
dw->index = 0;
go = part->dup_group->gobject.first;
while(go && go->ob != dw->ob) {
go=go->next;
dw->index++;
}
writestruct(wd, DATA, "ParticleDupliWeight", 1, dw);
}
if(part->boids && part->phystype == PART_PHYS_BOIDS) {
BoidState *state = part->boids->states.first;

@ -28,9 +28,9 @@ set(INC
.
..
../blenlib
../blenloader
../imbuf
../makesdna
../blenloader
../../../intern/guardedalloc
)
@ -50,7 +50,9 @@ set(SRC
)
if(WITH_CODEC_QUICKTIME)
list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS})
list(APPEND INC_SYS
${QUICKTIME_INCLUDE_DIRS}
)
add_definitions(-DWITH_QUICKTIME)
endif()

@ -28,13 +28,13 @@ remove_strict_flags()
set(INC
.
../blenlib
../blenkernel
../blenlib
../blenloader
../windowmanager
../editors/include
../makesdna
../makesrna
../editors/include
../windowmanager
../../../intern/guardedalloc
)

@ -19,39 +19,42 @@
#
# ***** END GPL LICENSE BLOCK *****
add_subdirectory(animation)
add_subdirectory(armature)
add_subdirectory(curve)
if(WITH_BLENDER)
add_subdirectory(animation)
add_subdirectory(armature)
add_subdirectory(curve)
add_subdirectory(gpencil)
add_subdirectory(interface)
add_subdirectory(mesh)
add_subdirectory(metaball)
add_subdirectory(object)
add_subdirectory(physics)
add_subdirectory(render)
add_subdirectory(screen)
add_subdirectory(sculpt_paint)
add_subdirectory(sound)
add_subdirectory(space_action)
add_subdirectory(space_api)
add_subdirectory(space_buttons)
add_subdirectory(space_console)
add_subdirectory(space_file)
add_subdirectory(space_graph)
add_subdirectory(space_image)
add_subdirectory(space_info)
add_subdirectory(space_logic)
add_subdirectory(space_nla)
add_subdirectory(space_node)
add_subdirectory(space_outliner)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
add_subdirectory(space_sound)
add_subdirectory(space_text)
add_subdirectory(space_time)
add_subdirectory(space_userpref)
add_subdirectory(space_view3d)
add_subdirectory(transform)
add_subdirectory(util)
add_subdirectory(uvedit)
endif()
add_subdirectory(datafiles)
add_subdirectory(gpencil)
add_subdirectory(interface)
add_subdirectory(mesh)
add_subdirectory(metaball)
add_subdirectory(object)
add_subdirectory(physics)
add_subdirectory(render)
add_subdirectory(screen)
add_subdirectory(sculpt_paint)
add_subdirectory(sound)
add_subdirectory(space_action)
add_subdirectory(space_api)
add_subdirectory(space_buttons)
add_subdirectory(space_console)
add_subdirectory(space_file)
add_subdirectory(space_graph)
add_subdirectory(space_image)
add_subdirectory(space_info)
add_subdirectory(space_logic)
add_subdirectory(space_nla)
add_subdirectory(space_node)
add_subdirectory(space_outliner)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
add_subdirectory(space_sound)
add_subdirectory(space_text)
add_subdirectory(space_time)
add_subdirectory(space_userpref)
add_subdirectory(space_view3d)
add_subdirectory(transform)
add_subdirectory(util)
add_subdirectory(uvedit)

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -27,50 +27,61 @@ set(INC_SYS
)
# blender and player
set(SRC
Bfont.c
bfont.ttf.c
bmonofont.ttf.c
startup.blend.c
preview.blend.c
)
if(NOT WITH_HEADLESS)
if(WITH_BLENDER)
# blender only
list(APPEND SRC
splash.png.c
blenderbuttons.c
# brushes
add.png.c
blob.png.c
blur.png.c
clay.png.c
clone.png.c
crease.png.c
darken.png.c
draw.png.c
fill.png.c
flatten.png.c
grab.png.c
inflate.png.c
layer.png.c
lighten.png.c
mix.png.c
multiply.png.c
nudge.png.c
pinch.png.c
prvicons.c
scrape.png.c
smear.png.c
smooth.png.c
snake_hook.png.c
soften.png.c
subtract.png.c
texdraw.png.c
thumb.png.c
twist.png.c
vertexdraw.png.c
startup.blend.c
bmonofont.ttf.c
)
if(NOT WITH_HEADLESS)
# blender UI only
list(APPEND SRC
# blends
preview.blend.c
# images
splash.png.c
blenderbuttons.c
# brushes
add.png.c
blob.png.c
blur.png.c
clay.png.c
clone.png.c
crease.png.c
darken.png.c
draw.png.c
fill.png.c
flatten.png.c
grab.png.c
inflate.png.c
layer.png.c
lighten.png.c
mix.png.c
multiply.png.c
nudge.png.c
pinch.png.c
prvicons.c
scrape.png.c
smear.png.c
smooth.png.c
snake_hook.png.c
soften.png.c
subtract.png.c
texdraw.png.c
thumb.png.c
twist.png.c
vertexdraw.png.c
)
endif()
endif()
blender_add_lib(bf_editor_datafiles "${SRC}" "${INC}" "${INC_SYS}")

File diff suppressed because it is too large Load Diff

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna

@ -23,8 +23,8 @@ set(INC
../include
../../blenfont
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../gpu
../../imbuf
../../makesdna

@ -22,13 +22,13 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
)

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../render/extern/include

@ -22,16 +22,16 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../gpu
../../ikplugin
../../imbuf
../../makesdna
../../makesrna
../../python
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
)

@ -860,6 +860,10 @@ static void finish_images(MultiresBakeRender *bkr)
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
ibuf->userflags|= IB_BITMAPDIRTY;
if(ibuf->rect_float)
ibuf->userflags|= IB_RECT_INVALID;
if(ibuf->mipmap[0]) {
ibuf->userflags|= IB_MIPMAP_INVALID;
imb_freemipmapImBuf(ibuf);
@ -966,9 +970,10 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
Mesh *me= (Mesh*)ob->data;
*lvl= mmd->lvl;
if(ob->mode==OB_MODE_SCULPT) *lvl= mmd->sculptlvl;
else *lvl= mmd->lvl;
if(mmd->lvl==0) {
if(*lvl==0) {
DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob);
dm= CDDM_copy(tmp_dm);
tmp_dm->release(tmp_dm);
@ -976,7 +981,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
MultiresModifierData tmp_mmd= *mmd;
DerivedMesh *cddm= CDDM_from_mesh(me, ob);
tmp_mmd.lvl= mmd->lvl;
tmp_mmd.lvl= *lvl;
dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0, 0);
cddm->release(cddm);
}

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -722,15 +722,17 @@ typedef struct FluidBakeJob {
static void fluidbake_free(void *customdata)
{
FluidBakeJob *fb= customdata;
FluidBakeJob *fb= (FluidBakeJob *)customdata;
MEM_freeN(fb);
}
/* called by fluidbake, only to check job 'stop' value */
static int fluidbake_breakjob(void *UNUSED(customdata))
static int fluidbake_breakjob(void *customdata)
{
//FluidBakeJob *fb= (FluidBakeJob *)customdata;
//return *(fb->stop);
FluidBakeJob *fb= (FluidBakeJob *)customdata;
if(fb->stop && *(fb->stop))
return 1;
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
@ -741,7 +743,7 @@ static int fluidbake_breakjob(void *UNUSED(customdata))
/* called by fluidbake, wmJob sends notifier */
static void fluidbake_updatejob(void *customdata, float progress)
{
FluidBakeJob *fb= customdata;
FluidBakeJob *fb= (FluidBakeJob *)customdata;
*(fb->do_update)= 1;
*(fb->progress)= progress;
@ -749,7 +751,7 @@ static void fluidbake_updatejob(void *customdata, float progress)
static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
FluidBakeJob *fb= customdata;
FluidBakeJob *fb= (FluidBakeJob *)customdata;
fb->stop= stop;
fb->do_update = do_update;
@ -764,7 +766,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update,
static void fluidbake_endjob(void *customdata)
{
FluidBakeJob *fb= customdata;
FluidBakeJob *fb= (FluidBakeJob *)customdata;
if (fb->settings) {
MEM_freeN(fb->settings);

@ -51,8 +51,12 @@ set(SRC
)
if(WITH_CODEC_QUICKTIME)
list(APPEND INC ../../quicktime)
list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS})
list(APPEND INC
../../quicktime
)
list(APPEND INC_SYS
${QUICKTIME_INCLUDE_DIRS}
)
add_definitions(-DWITH_QUICKTIME)
endif()
@ -60,4 +64,8 @@ if(WITH_OPENMP)
add_definitions(-DPARALLEL=1)
endif()
if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()
blender_add_lib(bf_editor_render "${SRC}" "${INC}" "${INC_SYS}")

@ -171,6 +171,7 @@ static Main *pr_main= NULL;
void ED_preview_init_dbase(void)
{
#ifndef WITH_HEADLESS
BlendFileData *bfd;
extern int datatoc_preview_blend_size;
extern char datatoc_preview_blend[];
@ -184,6 +185,7 @@ void ED_preview_init_dbase(void)
MEM_freeN(bfd);
}
G.fileflags= fileflags;
#endif
}
void ED_preview_free_dbase(void)

@ -23,8 +23,8 @@ set(INC
../include
../../blenfont
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna

@ -22,14 +22,14 @@
set(INC
../include
../../blenkernel
../../blenloader
../../imbuf
../../gpu
../../blenlib
../../blenloader
../../gpu
../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
)

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -218,7 +218,7 @@ static int buttons_context_path_modifier(ButsContextPath *path)
return 0;
}
static int buttons_context_path_material(ButsContextPath *path)
static int buttons_context_path_material(ButsContextPath *path, int for_texture)
{
Object *ob;
PointerRNA *ptr= &path->ptr[path->len-1];
@ -236,6 +236,9 @@ static int buttons_context_path_material(ButsContextPath *path)
ma= give_current_material(ob, ob->actcol);
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
path->len++;
if(for_texture && give_current_material_texture_node(ma))
return 1;
ma= give_node_material(ma);
if(ma) {
@ -432,7 +435,7 @@ static int buttons_context_path_texture(ButsContextPath *path)
}
}
/* try material */
if(buttons_context_path_material(path)) {
if(buttons_context_path_material(path, 1)) {
ma= path->ptr[path->len-1].data;
if(ma) {
@ -524,7 +527,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
found= buttons_context_path_particle(path);
break;
case BCONTEXT_MATERIAL:
found= buttons_context_path_material(path);
found= buttons_context_path_material(path, 0);
break;
case BCONTEXT_TEXTURE:
found= buttons_context_path_texture(path);

@ -28,8 +28,8 @@ set(INC
../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
)

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -23,13 +23,13 @@ set(INC
../include
../../blenfont
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
)

@ -804,6 +804,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
col= uiLayoutColumn(split, 1);
uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}

@ -500,7 +500,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene;
Object *obedit;
Image *ima;
float size, min[2], max[2], d[2];
float size, min[2], max[2], d[2], aspx, aspy;
int width, height;
/* retrieve state */
@ -511,6 +511,10 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ima= ED_space_image(sima);
ED_space_image_size(sima, &width, &height);
ED_image_aspect(ima, &aspx, &aspy);
width= width*aspx;
height= height*aspy;
/* get bounds */
if(!ED_uvedit_minmax(scene, ima, obedit, min, max))

@ -23,8 +23,8 @@ set(INC
../include
../../blenfont
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna

@ -21,13 +21,13 @@
set(INC
../include
../interface
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager
../../editors/interface
../../../../intern/guardedalloc
)

@ -22,8 +22,8 @@
set(INC
../include
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../makesdna
../../makesrna
../../windowmanager

@ -23,14 +23,14 @@ set(INC
../include
../../blenfont
../../blenkernel
../../blenloader
../../blenlib
../../blenloader
../../imbuf
../../makesdna
../../makesrna
../../nodes
../../windowmanager
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
../../../../intern/opennl/extern
)

@ -461,6 +461,7 @@ static void node_update_group(const bContext *C, bNodeTree *UNUSED(ntree), bNode
}
/* note: in cmp_util.c is similar code, for node_compo_pass_on() */
/* note: in node_edit.c is similar code, for untangle node */
static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
{
bNodeSocket *valsock= NULL, *colsock= NULL, *vecsock= NULL;

@ -2000,12 +2000,13 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float
/* ****************** Duplicate *********************** */
static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
static int node_duplicate_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode= CTX_wm_space_node(C);
bNodeTree *ntree= snode->edittree;
bNode *node, *newnode, *lastnode;
bNodeLink *link, *newlink, *lastlink;
int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs");
ED_preview_kill_jobs(C);
@ -2033,10 +2034,11 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
*/
lastlink = ntree->links.last;
for (link=ntree->links.first; link; link=link->next) {
/* this creates new links between copied nodes,
* as well as input links from unselected (when fromnode==NULL) !
/* This creates new links between copied nodes.
* If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)!
*/
if (link->tonode && (link->tonode->flag & NODE_SELECT)) {
if (link->tonode && (link->tonode->flag & NODE_SELECT)
&& (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) {
newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
newlink->flag = link->flag;
newlink->tonode = link->tonode->new_node;
@ -2096,6 +2098,8 @@ void NODE_OT_duplicate(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
}
/* *************************** add link op ******************** */
@ -2114,9 +2118,9 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL
if(tlink) {
/* try to move the existing link to the next available socket */
if (tlink->tonode) {
/* is there a free input socket with same type? */
/* is there a free input socket with the target type? */
for(sock= tlink->tonode->inputs.first; sock; sock= sock->next) {
if(sock->type==tlink->fromsock->type)
if(sock->type==tlink->tosock->type)
if(nodeCountSocketLinks(snode->edittree, sock) < sock->limit)
break;
}
@ -2906,6 +2910,117 @@ void NODE_OT_delete(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ****************** Delete with reconnect ******************* */
/* note: in cmp_util.c is similar code, for node_compo_pass_on() */
/* used for disabling node (similar code in node_draw.c for disable line) */
static void node_delete_reconnect(bNodeTree* tree, bNode* node) {
bNodeLink *link, *next;
bNodeSocket *valsocket= NULL, *colsocket= NULL, *vecsocket= NULL;
bNodeSocket *deliveringvalsocket= NULL, *deliveringcolsocket= NULL, *deliveringvecsocket= NULL;
bNode *deliveringvalnode= NULL, *deliveringcolnode= NULL, *deliveringvecnode= NULL;
bNodeSocket *sock;
/* test the inputs */
for(sock= node->inputs.first; sock; sock= sock->next) {
int type = sock->type;
if(type==SOCK_VALUE && valsocket==NULL) valsocket = sock;
if(type==SOCK_VECTOR && vecsocket==NULL) vecsocket = sock;
if(type==SOCK_RGBA && colsocket==NULL) colsocket = sock;
}
// we now have the input sockets for the 'data types'
// now find the output sockets (and nodes) in the tree that delivers data to these input sockets
for(link= tree->links.first; link; link=link->next) {
if (valsocket != NULL) {
if (link->tosock == valsocket) {
deliveringvalnode = link->fromnode;
deliveringvalsocket = link->fromsock;
}
}
if (vecsocket != NULL) {
if (link->tosock == vecsocket) {
deliveringvecnode = link->fromnode;
deliveringvecsocket = link->fromsock;
}
}
if (colsocket != NULL) {
if (link->tosock == colsocket) {
deliveringcolnode = link->fromnode;
deliveringcolsocket = link->fromsock;
}
}
}
// we now have the sockets+nodes that fill the inputsockets be aware for group nodes these can be NULL
// now make the links for all outputlinks of the node to be reconnected
for(link= tree->links.first; link; link=next) {
next= link->next;
if (link->fromnode == node) {
sock = link->fromsock;
switch(sock->type) {
case SOCK_VALUE:
if (deliveringvalsocket) {
link->fromnode = deliveringvalnode;
link->fromsock = deliveringvalsocket;
}
break;
case SOCK_VECTOR:
if (deliveringvecsocket) {
link->fromnode = deliveringvecnode;
link->fromsock = deliveringvecsocket;
}
break;
case SOCK_RGBA:
if (deliveringcolsocket) {
link->fromnode = deliveringcolnode;
link->fromsock = deliveringcolsocket;
}
break;
}
}
}
if(node->id)
node->id->us--;
nodeFreeNode(tree, node);
}
static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceNode *snode= CTX_wm_space_node(C);
bNode *node, *next;
ED_preview_kill_jobs(C);
for(node= snode->edittree->nodes.first; node; node= next) {
next= node->next;
if(node->flag & SELECT) {
node_delete_reconnect(snode->edittree, node);
}
}
node_tree_verify_groups(snode->nodetree);
snode_notify(C, snode);
snode_dag_update(C, snode);
return OPERATOR_FINISHED;
}
void NODE_OT_delete_reconnect(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Delete with reconnect";
ot->description = "Delete nodes; will reconnect nodes as if deletion was muted";
ot->idname= "NODE_OT_delete_reconnect";
/* api callbacks */
ot->exec= node_delete_reconnect_exec;
ot->poll= ED_operator_node_active;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ****************** Show Cyclic Dependencies Operator ******************* */
static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op))

@ -94,8 +94,6 @@ static void do_node_add(bContext *C, void *UNUSED(arg), int event)
if(node->flag & NODE_TEST) node->flag |= NODE_SELECT;
}
snode_autoconnect(snode, 1, 0);
/* deselect after autoconnection */
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & NODE_TEST) node->flag &= ~NODE_SELECT;

@ -114,6 +114,7 @@ int node_render_changed_exec(bContext *, wmOperator *);
void NODE_OT_duplicate(struct wmOperatorType *ot);
void NODE_OT_delete(struct wmOperatorType *ot);
void NODE_OT_delete_reconnect(struct wmOperatorType *ot);
void NODE_OT_resize(struct wmOperatorType *ot);
void NODE_OT_link(struct wmOperatorType *ot);

Some files were not shown because too many files have changed in this diff Show More