Kaydet (Commit) 6403f2b5 authored tarafından Zolnai Tamás's avatar Zolnai Tamás Kaydeden (comit) Zolnai Tamás

Update libgltf: new build system and various fixes

Building:
- The new tarball has reasonable build system so
build libgltf as external package instead of compiling
source files directly.
- Freetype dependancy is removed

Improvements comes with the new libgltf
- Can rotate the models too (orbit mode)
- Two camera handling mode: walkthrough and orbit
(press M to change).
- gltf_animation_set_time() works
- FPS can be displayed without freetype (press F)

Additional notes:
- There were some bugs/regressions which are fixed
during the integration (see patches).
- License files are uddated now.
- libgltf building is enabled only on those platforms
on which gltf support actually works (windows and linux)

Change-Id: Ia6c9c4da53a9b4fedba0d73aa5791489f8ad424b
Reviewed-on: https://gerrit.libreoffice.org/9895Reviewed-by: 's avatarZolnai Tamás <zolnaitamas2000@gmail.com>
Tested-by: 's avatarZolnai Tamás <zolnaitamas2000@gmail.com>
üst 076e4afc
......@@ -142,6 +142,7 @@ endif # SYSTEM_MDDS
ifneq ($(SYSTEM_GLM),)
gb_LinkTarget__use_glm_headers :=
gb_ExternalProject__use_glm_headers :=
else
......@@ -154,6 +155,11 @@ $(call gb_LinkTarget_set_include,$(1),\
endef
define gb_ExternalProject__use_glm_headers
$(call gb_ExternalProject_get_preparation_target,$(1)) :| $(call gb_UnpackedTarball_get_final_target,glm)
endef
endif
ifeq (SANE,$(filter SANE,$(BUILD_TYPE)))
......@@ -239,6 +245,8 @@ $(call gb_LinkTarget_add_libs,$(1),$(GLEW_LIBS))
endef
gb_ExternalProject__use_glew :=
else # !SYSTEM_GLEW
$(eval $(call gb_Helper_register_packages_for_install,ooo,\
......@@ -264,6 +272,11 @@ endif
endef
define gb_ExternalProject__use_glew
$(call gb_ExternalProject_use_external_project,$(1),glew)
endef
endif # SYSTEM_GLEW
define gb_LinkTarget__use_iconv
......@@ -1274,7 +1287,7 @@ endef
gb_ExternalProject__use_freetype :=
else ifneq (,$(or $(findstring ANDROID,$(OS)),$(ENABLE_GLTF)))
else ifeq ($(OS),ANDROID)
define gb_LinkTarget__use_freetype_headers
$(call gb_LinkTarget_use_external_project,$(1),freetype)
......@@ -3258,7 +3271,6 @@ endif # SYSTEM_NSS
endif # DESKTOP
ifeq ($(ENABLE_GLTF),TRUE)
define gb_LinkTarget__use_libgltf
......@@ -3267,9 +3279,23 @@ $(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
)
$(call gb_LinkTarget_use_static_libraries,$(1),\
libgltf \
ifeq ($(COM),MSC)
$(call gb_LinkTarget_add_libs,$(1),\
$(call gb_UnpackedTarball_get_dir,libgltf)/build/win32/$(if $(MSVC_USE_DEBUG_RUNTIME),Debug/libgltf.lib,Release/libgltf.lib) \
)
else
$(call gb_LinkTarget_add_libs,$(1),\
$(call gb_UnpackedTarball_get_dir,libgltf)/src/.libs/libgltf-0.0$(gb_StaticLibrary_PLAINEXT) \
)
endif
$(call gb_LinkTarget_use_external_project,$(1),libgltf)
endef
define gb_ExternalProject__use_libgltf
$(call gb_ExternalProject_use_external_project,$(1),libgltf)
endef
define gb_LinkTarget__use_opencollada_parser
......
......@@ -27,7 +27,6 @@ $(eval $(call gb_Library_use_externals,avmedia,\
boost_headers \
glew \
mesa_headers \
zlib \
))
$(eval $(call gb_Library_use_libraries,avmedia,\
......
......@@ -16,11 +16,9 @@ $(eval $(call gb_Library_use_sdk_api,avmediaogl))
$(eval $(call gb_Library_use_externals,avmediaogl, \
boost_headers \
libgltf \
glew \
glm_headers \
mesa_headers \
glew \
zlib \
freetype \
))
$(eval $(call gb_Library_use_libraries,avmediaogl,\
......@@ -50,8 +48,6 @@ $(eval $(call gb_Library_add_exception_objects,avmediaogl,\
ifeq ($(strip $(OS)),WNT)
$(eval $(call gb_Library_use_system_win32_libs,avmediaogl,\
opengl32 \
gdi32 \
glu32 \
))
else ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_use_system_darwin_frameworks,avmediaogl,\
......@@ -59,10 +55,7 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,avmediaogl,\
))
else ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,avmediaogl,\
-ldl \
-lGL \
-lGLU \
-lX11 \
))
endif
......
......@@ -28,6 +28,7 @@ OGLPlayer::OGLPlayer()
: Player_BASE(m_aMutex)
, m_pHandle(NULL)
, m_pOGLWindow(NULL)
, m_bIsRendering(false)
{
}
......@@ -141,8 +142,14 @@ void SAL_CALL OGLPlayer::start() throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
assert(m_pHandle);
// gltf_animation_start play animation from the time 0.0,
// but OGLPlayer::start used as play from that time where it was stopped before
double fTime = gltf_animation_get_time(m_pHandle);
gltf_animation_start(m_pHandle);
gltf_animation_set_time(m_pHandle, fTime);
m_aTimer.Start();
m_bIsRendering = true;
}
void SAL_CALL OGLPlayer::stop() throw ( uno::RuntimeException, std::exception )
......@@ -151,13 +158,19 @@ void SAL_CALL OGLPlayer::stop() throw ( uno::RuntimeException, std::exception )
assert(m_pHandle);
m_aTimer.Stop();
gltf_animation_stop(m_pHandle);
m_bIsRendering = false;
}
sal_Bool SAL_CALL OGLPlayer::isPlaying() throw ( uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
assert(m_pHandle);
return (sal_Bool)gltf_animation_is_playing(m_pHandle);
// Here isPlaying means model is rendered in the window and
// able to interact with the user (e.g. moving camera)
if( getDuration() > 0.0 )
return gltf_animation_is_playing(m_pHandle);
else
return m_bIsRendering;
}
double SAL_CALL OGLPlayer::getDuration() throw ( uno::RuntimeException, std::exception )
......@@ -169,18 +182,16 @@ double SAL_CALL OGLPlayer::getDuration() throw ( uno::RuntimeException, std::exc
void SAL_CALL OGLPlayer::setMediaTime( double fTime ) throw ( uno::RuntimeException, std::exception )
{
// TODO: doesn't work, but cause problem in playing
osl::MutexGuard aGuard(m_aMutex);
assert(m_pHandle);
(void) fTime;
//gltf_animation_set_time(m_pHandle, fTime);
gltf_animation_set_time(m_pHandle, fTime);
}
double SAL_CALL OGLPlayer::getMediaTime() throw ( ::com::sun::star::uno::RuntimeException, std::exception )
{
osl::MutexGuard aGuard(m_aMutex);
assert(m_pHandle);
return 0.0; //gltf_animation_get_time(m_pHandle);
return gltf_animation_get_time(m_pHandle);
}
void SAL_CALL OGLPlayer::setPlaybackLoop( sal_Bool bSet ) throw ( uno::RuntimeException, std::exception )
......@@ -264,6 +275,9 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
SAL_WARN("avmedia.opengl", "Error occured while parsing *.json file! Error code: " << nRet);
return uno::Reference< media::XPlayerWindow >();
}
// The background color is white by default, but we need to separate the
// OpenGL window from the main window so set background color to grey
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
m_pOGLWindow = new OGLWindow(*m_pHandle, m_aContext, *pChildWindow->GetParent());
return uno::Reference< media::XPlayerWindow >( m_pOGLWindow );
}
......@@ -291,6 +305,7 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
SAL_WARN("avmedia.opengl", "Error occured while parsing *.json file! Error code: " << nRet);
return uno::Reference< media::XFrameGrabber >();
}
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
OGLFrameGrabber *pFrameGrabber = new OGLFrameGrabber( *m_pHandle );
return uno::Reference< media::XFrameGrabber >( pFrameGrabber );
}
......
......@@ -64,6 +64,7 @@ private:
OpenGLContext m_aContext;
AutoTimer m_aTimer;
OGLWindow* m_pOGLWindow;
bool m_bIsRendering;
};
} // namespace ogl
......
......@@ -20,6 +20,7 @@ OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, Window& rEve
, m_rEventHandler( rEventHandlerParent )
, m_bVisible ( false )
, m_aLastMousePos(Point())
, m_bIsOrbitMode( false )
{
}
......@@ -249,33 +250,36 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
glm::vec3 vStrafe = glm::cross(vView-vEye, vUp);
vStrafe = glm::normalize(vStrafe);
vStrafe *= 25.0f;
glm::vec3 vMup = glm::cross(vView-vEye,glm::vec3(1.f,0.f,0.f) );
glm::vec3 vMup = glm::cross(vView-vEye,glm::vec3(1.0f,0.0f,0.0f) );
vMup = glm::normalize(vMup);
vMup *= 25.0f;
if(nCode == KEY_Q)vMoveBy += vMove*(0.0005f*fModelSize);
if(nCode == KEY_E)vMoveBy -= vMove*(0.0005f*fModelSize);
if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize);
if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*fModelSize);
if(nCode == KEY_W)vMoveBy -= vMup*(0.0005f*fModelSize);
if(nCode == KEY_S)vMoveBy += vMup*(0.0005f*fModelSize);
if(nCode == KEY_W)vMoveBy += vMove*(0.005f*fModelSize);
if(nCode == KEY_S)vMoveBy -= vMove*(0.005f*fModelSize);
if( !m_bIsOrbitMode )
{
if(nCode == KEY_A)vMoveBy -= vStrafe*(0.005f*fModelSize);
if(nCode == KEY_D)vMoveBy += vStrafe*(0.005f*fModelSize);
}
}
gltf_renderer_move_camera(&m_rHandle, vMoveBy.x, vMoveBy.y, vMoveBy.z, 0.0);
}
}
}
// TODO: Clean this mess up after libgltf gets a working camera handling
else if( pEvent->GetId() == VCLEVENT_WINDOW_KEYUP )
{
KeyEvent* pKeyEvt = (KeyEvent*)pEvent->GetData();
if(pKeyEvt)
{
const sal_uInt16 nCode = pKeyEvt->GetKeyCode().GetCode();
if (nCode == KEY_Q || nCode == KEY_E ||
nCode == KEY_A || nCode == KEY_D ||
nCode == KEY_W || nCode == KEY_S )
else if(nCode == KEY_M)
{
gltf_renderer_move_camera(&m_rHandle, 0.0, 0.0, 0.0, 0.0);
if(m_bIsOrbitMode)
{
gltf_orbit_view_stop(&m_rHandle);
m_bIsOrbitMode = false;
}
else
{
gltf_orbit_mode_start(&m_rHandle);
m_bIsOrbitMode = true;
}
}
else if(nCode == KEY_F)
{
gltf_render_FPS_enable(&m_rHandle);
}
}
}
......@@ -303,14 +307,32 @@ IMPL_LINK(OGLWindow, CameraHandler, VclWindowEvent*, pEvent)
else
fSensitivity = 540.0 / fSensitivity;
long nDeltaX = m_aLastMousePos.X()-aCurPos.X();
long nDeltaY = aCurPos.Y()-m_aLastMousePos.Y();
// TODO: It seems this method just moves the camera but not rotate it.
gltf_renderer_rotate_camera(&m_rHandle, (float)nDeltaX*fSensitivity, (float)nDeltaY*fSensitivity, 0.0, 0.0);
long nDeltaX = m_aLastMousePos.X()-aCurPos.X();
long nDeltaY = m_aLastMousePos.Y()-aCurPos.Y();
if( m_bIsOrbitMode )
{
fSensitivity *= 5;
gltf_renderer_rotate_model(&m_rHandle, (float)nDeltaX*fSensitivity, (float)nDeltaY*fSensitivity, 0.0);
}
else
{
// Filter out too small deltas to avoid rewrite rotation parameter with 0
// before rotation is done
if( nDeltaX != 0 || nDeltaY != 0 )
gltf_renderer_rotate_camera(&m_rHandle, (float)nDeltaX*fSensitivity, (float)nDeltaY*fSensitivity, 0.0);
}
m_aLastMousePos = aCurPos;
}
}
else if( pEvent->GetId() == VCLEVENT_WINDOW_MOUSEBUTTONUP )
{
MouseEvent* pMouseEvt = (MouseEvent*)pEvent->GetData();
if(pMouseEvt && pMouseEvt->IsLeft() && pMouseEvt->GetClicks() == 1)
{
gltf_renderer_stop_rotate_model(&m_rHandle);
}
}
return 0;
}
......
......@@ -70,6 +70,7 @@ private:
Window& m_rEventHandler;
bool m_bVisible;
Point m_aLastMousePos;
bool m_bIsOrbitMode;
};
} // namespace ogl
......
......@@ -10516,25 +10516,12 @@ dnl ===================================================================
dnl Check whether to enable glTF support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable glTF support])
if test "$ENABLE_RELEASE_BUILD" = "TRUE"; then
if test $_os == iOS -o $_os == Android -o $_os = Darwin; then
enable_gltf=no
fi
fi
ENABLE_GLTF=
if test "x$enable_gltf" != "xno"; then
if test "x$enable_gltf" != "xno" -a $_os != Darwin -a $_os != iOS -a $_os != Android; then
ENABLE_GLTF=TRUE
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_FEATURE_GLTF,1)
BUILD_TYPE="$BUILD_TYPE LIBGLTF"
if test "$test_freetype" = "no"; then
BUILD_TYPE="$BUILD_TYPE FREETYPE"
if test "$COM" = "MSC"; then
test -n "${MSVC_USE_DEBUG_RUNTIME}" && FREETYPE_LIB_DEBUGLIB_SUFFIX="_D"
FREETYPE_LIBS="${WORKDIR}/UnpackedTarball/freetype/objs/win32/vc2010/freetype248$FREETYPE_LIB_DEBUGLIB_SUFFIX.lib"
fi
fi
# otherwise build fails in collada2gltf external because of std::shared_ptr
if test "$have_std_shared_ptr" = "yes"; then
BUILD_TYPE="$BUILD_TYPE COLLADA2GLTF"
......
......@@ -87,7 +87,7 @@ export LIBATOMIC_OPS_TARBALL := libatomic_ops-7_2d.zip
export LIBEOT_MD5SUM := aa24f5dd2a2992f4a116aa72af817548
export LIBEOT_TARBALL := libeot-0.01.tar.bz2
export LIBEXTTEXTCAT_TARBALL := ae330b9493bd4503ac390106ff6060d7-libexttextcat-3.4.3.tar.bz2
export LIBGLTF_TARBALL := 3c62598ccbecb65998bf7602bb09a791-libgltf.tar.bz2
export LIBGLTF_TARBALL := 9c8d3455e0d8ef51269784e9a473feeb-libgltf.tar.bz2
export LIBLANGTAG_TARBALL := 36271d3fa0d9dec1632029b6d7aac925-liblangtag-0.5.1.tar.bz2
export LIBXMLSEC_TARBALL := 1f24ab1d39f4a51faf22244c94a6203f-xmlsec1-1.2.14.tar.gz
export LIBXML_TARBALL := 9c0cfef285d5c4a5c80d00904ddab380-libxml2-2.9.1.tar.gz
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_ExternalProject_ExternalProject,libgltf))
$(eval $(call gb_ExternalProject_use_autoconf,libgltf,build))
$(eval $(call gb_ExternalProject_register_targets,libgltf,\
build \
))
$(eval $(call gb_ExternalProject_use_externals,libgltf,\
boost_headers \
glew \
glm_headers \
))
ifeq ($(COM),MSC)
AdditionalIncludes :=
ifeq ($(SYSTEM_BOOST),)
AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,boost)"
AdditionalIncludes += "$(SRCDIR)/config_host"
endif
ifeq ($(SYSTEM_GLEW),)
AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,glew)/include"
endif
ifeq ($(SYSTEM_GLM),)
AdditionalIncludes += "$(call gb_UnpackedTarball_get_dir,glm)"
endif
empty :=
space := $(empty) $(empty)
$(call gb_ExternalProject_get_state_target,libgltf,build) :
$(call gb_ExternalProject_run,build,\
msbuild.exe libgltf.vcxproj \
/p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
$(if $(filter 110,$(VCVER)),/p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) \
/p:VisualStudioVersion=11.0) \
'/p:AdditionalIncludeDirectories=$(subst $(space),;,$(subst /,\,$(strip $(AdditionalIncludes))))' \
/p:AdditionalLibraryDirectories=$(if $(SYSTEM_GLEW),,"$(subst /,\,$(call gb_UnpackedTarball_get_dir,glew))\lib\$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release)\Win32") \
,build/win32)
else
$(call gb_ExternalProject_get_state_target,libgltf,build) :
$(call gb_ExternalProject_run,build,\
export PKG_CONFIG="" \
&& ./configure \
--disable-debug \
--disable-werror \
BOOST_CFLAGS="$(if $(SYSTEM_BOOST),$(BOOST_CPPFLAGS),-I$(call gb_UnpackedTarball_get_dir,boost))" \
GLEW_CFLAGS="$(if $(SYSTEM_GLEW),$(GLEW_CFLAGS),-I$(call gb_UnpackedTarball_get_dir,glew)/include)" \
GLM_CFLAGS="$(if $(SYSTEM_GLM),$(GLM_CFLAGS),-I$(call gb_UnpackedTarball_get_dir,glm))" \
&& $(MAKE) \
)
endif
# vim: set noet sw=4 ts=4:
......@@ -10,7 +10,7 @@
$(eval $(call gb_Module_Module,libgltf))
$(eval $(call gb_Module_add_targets,libgltf,\
StaticLibrary_libgltf \
ExternalProject_libgltf \
UnpackedTarball_libgltf \
))
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_StaticLibrary_StaticLibrary,libgltf))
$(eval $(call gb_StaticLibrary_set_warnings_not_errors,libgltf))
$(eval $(call gb_StaticLibrary_use_unpacked,libgltf,libgltf))
$(eval $(call gb_StaticLibrary_set_generated_cxx_suffix,libgltf,cpp))
# Avoid warnings
$(eval $(call gb_StaticLibrary_add_cxxflags,libgltf,-w))
$(eval $(call gb_StaticLibrary_use_externals,libgltf,\
boost_headers \
glm_headers \
mesa_headers \
glew \
zlib \
))
$(eval $(call gb_StaticLibrary_set_include,libgltf,\
-I$(call gb_UnpackedTarball_get_dir,libgltf)/inc \
$$(INCLUDE) \
))
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,libgltf,\
UnpackedTarball/libgltf/src/Camera \
UnpackedTarball/libgltf/src/Common \
UnpackedTarball/libgltf/src/libgltf \
UnpackedTarball/libgltf/src/LoadScene \
UnpackedTarball/libgltf/src/RenderScene \
UnpackedTarball/libgltf/src/Shaders \
UnpackedTarball/libgltf/src/Texture \
))
# vim: set noet sw=4 ts=4:
......@@ -16,12 +16,16 @@ $(eval $(call gb_UnpackedTarball_set_patchflags,libgltf,--binary))
$(eval $(call gb_UnpackedTarball_set_patchlevel,libgltf,1))
$(eval $(call gb_UnpackedTarball_add_patches,libgltf,\
external/libgltf/patches/include_path_glew.patch \
external/libgltf/patches/include_path_freetype.patch \
external/libgltf/patches/openmp-disable.patch \
external/libgltf/patches/rgba_textures.patch \
external/libgltf/patches/deallocation_fix.patch \
external/libgltf/patches/init_scene_set_handle.patch \
external/libgltf/patches/extend_get_bitmap_for_rgba_ones.patch \
external/libgltf/patches/wrong_duration_caused_by_uninitialized_member.patch \
external/libgltf/patches/wrong_media_time_caused_by_missing_fmod.patch \
external/libgltf/patches/wrong_animation_state_when_set_time_to_null.patch \
external/libgltf/patches/no_effect_of_set_looping.patch \
external/libgltf/patches/wrong_media_time_at_first_run_caused_by_uninitilized_member.patch \
external/libgltf/patches/no_animation_in_orbit_mode.patch \
external/libgltf/patches/walkthrough_mode_affects_orbit_mode_unexpectedly.patch \
external/libgltf/patches/move_fps_closer_to_the_corner.patch \
))
# vim: set noet sw=4 ts=4:
diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
--- libgltf.org/src/LoadScene.cpp 2014-05-28 15:35:48.232375923 +0200
+++ libgltf/src/LoadScene.cpp 2014-05-28 15:36:02.600375314 +0200
@@ -144,7 +144,7 @@
free(gHandle->files);
gHandle->files = NULL;
}
- delete gHandle;
+ free(gHandle);
return true;
}
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 18:49:46.603119797 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 19:00:17.583092627 +0200
@@ -1735,28 +1735,29 @@
void RenderScene::setBitZoom(unsigned char* Dstbuffer,
unsigned char* Srcbuffer,
- glTFViewport* pViewport)
+ glTFViewport* pViewport,
+ int bufferDepth )
{
const int width = pViewport->width;
const int height = pViewport->height;
- const int newLineByte = (width * 3 + 3) / 4 * 4;
- const int lineByte = (width * SSAA * 3 + 3) / 4 * 4;
+ const int newLineByte = width * bufferDepth;
+ const int lineByte = width * SSAA * bufferDepth;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
- for (int k = 0; k < 3; k++)
+ for (int k = 0; k < bufferDepth; k++)
{
long xData = (long)(i * SSAA + 0.5);
long yData = (long)(j * SSAA + 0.5);
if((yData >= 0) && (yData < width * SSAA) &&
(xData >= 0) && (xData < height * SSAA))
{
- *(Dstbuffer + i * newLineByte + j * 3 + k) =
- *(Srcbuffer + xData * lineByte + yData * 3 + k);
+ *(Dstbuffer + i * newLineByte + j * bufferDepth + k) =
+ *(Srcbuffer + xData * lineByte + yData * bufferDepth + k);
}
else
{
- *(Dstbuffer + i * newLineByte + j * 3 + k) = 255;
+ *(Dstbuffer + i * newLineByte + j * bufferDepth + k) = 255;
}
}
}
@@ -1782,12 +1783,20 @@
{
return;
}
- int imageSize = ((width + ((4 - (width % 4)) % 4)) *
- height * 3) + 2;
+
+ int bufferDepth;
+ if( format == GL_RGB || format == GL_BGR )
+ bufferDepth = 3;
+ else if( format == GL_RGBA || format == GL_BGRA )
+ bufferDepth = 4;
+ else
+ return;
+
+ int imageSize = width * height * bufferDepth;
unsigned char *pbuffer = new unsigned char[imageSize];
glReadPixels(0, 0, width, height, format,
GL_UNSIGNED_BYTE, pbuffer);
- setBitZoom(buffer, pbuffer, pViewport);
+ setBitZoom(buffer, pbuffer, pViewport, bufferDepth);
if (pbuffer)
{
delete [] pbuffer;
diff -ur libgltf.org/src/RenderScene.h libgltf/src/RenderScene.h
--- libgltf.org/src/RenderScene.h 2014-06-23 18:49:46.587119798 +0200
+++ libgltf/src/RenderScene.h 2014-06-23 18:59:46.991093944 +0200
@@ -234,7 +234,7 @@
void completeRenderBitmap(glTFViewport* pViewport,
unsigned char* buffer, GLenum format);
void setBitZoom(unsigned char* Dstbuffer,
- unsigned char* Srcbuffer, glTFViewport* pViewport);
+ unsigned char* Srcbuffer, glTFViewport* pViewport, int bufferDepth );
// For animation
void startAnimation();
diff -ur libgltf.org/src/Font.h libgltf/src/Font.h
--- libgltf.org/src/Font.h 2014-05-05 14:35:24.155370405 +0200
+++ libgltf/src/Font.h 2014-05-05 14:35:39.715371069 +0200
@@ -8,7 +8,7 @@
#ifndef FONT_H
#define FONT_H
-#include "freetype/ft2build.h"
+#include "ft2build.h"
#include FT_FREETYPE_H
#include "Texture.h"
diff -ur libgltf/inc/libgltf.h libgltf/inc/libgltf.h
--- libgltf/inc/libgltf.h 2014-05-05 14:26:11.911346850 +0200
+++ libgltf/inc/libgltf.h 2014-05-05 14:27:07.295349212 +0200
@@ -9,7 +9,7 @@
#define LIBGLTF_H
#include <stddef.h>
#include "types.h"
-#include <glew/glew.h>
+#include <GL/glew.h>
#include <glm/glm.hpp>
using namespace glTF;
diff -ur libgltf.org/src/Camera.h libgltf/src/Camera.h
--- libgltf.org/src/Camera.h 2014-05-05 14:26:11.911346850 +0200
+++ libgltf/src/Camera.h 2014-05-05 14:27:07.295349212 +0200
@@ -8,7 +8,7 @@
#ifndef CAMERA_H
#define CAMERA_H
-#include <glew/glew.h>
+#include <GL/glew.h>
#include <glm/glm.hpp>
class CPhysicalCamera
diff -ur libgltf.org/src/Common.h libgltf/src/Common.h
--- libgltf.org/src/Common.h 2014-05-05 14:26:11.911346850 +0200
+++ libgltf/src/Common.h 2014-05-05 14:27:18.927349708 +0200
@@ -7,7 +7,7 @@
*/
#ifndef COMMON_H
#define COMMON_H
-#include <glew/glew.h>
+#include <GL/glew.h>
#include <glm/glm.hpp>
#include <string>
#include <vector>
diff -ur libgltf.org/src/Shaders.h libgltf/src/Shaders.h
--- libgltf.org/src/Shaders.h 2014-05-05 14:26:11.923346850 +0200
+++ libgltf/src/Shaders.h 2014-05-05 14:27:45.483350841 +0200
@@ -8,7 +8,7 @@
#ifndef SHADERS_H
#define SHADERS_H
-#include <glew/glew.h>
+#include <GL/glew.h>
#include <glm/glm.hpp>
#include <string>
diff -ur libgltf.org/src/Texture.h libgltf/src/Texture.h
--- libgltf.org/src/Texture.h 2014-05-05 14:26:11.911346850 +0200
+++ libgltf/src/Texture.h 2014-05-05 14:27:52.927351158 +0200
@@ -11,7 +11,7 @@
#include <string>
#include <vector>
#include <map>
-#include <glew/glew.h>
+#include <GL/glew.h>
#include <glm/glm.hpp>
using namespace std;
diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
--- libgltf.org/src/LoadScene.cpp 2014-06-13 01:13:40.654653289 +0200
+++ libgltf/src/LoadScene.cpp 2014-06-13 01:15:45.034648018 +0200
@@ -148,10 +148,14 @@
--- libgltf.org/src/LoadScene.cpp 2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/LoadScene.cpp 2014-06-23 14:56:04.399723599 +0200
@@ -149,10 +149,14 @@
return true;
}
......@@ -16,12 +16,12 @@ diff -ur libgltf.org/src/LoadScene.cpp libgltf/src/LoadScene.cpp
int status;
- this->pScene = pscene;
{
TRACE_TIME ("parseScene->readBuffers", CPU);
status = this->readBuffers();
if (status < 0)
diff -ur libgltf.org/src/LoadScene.h libgltf/src/LoadScene.h
--- libgltf.org/src/LoadScene.h 2014-06-13 01:13:40.654653289 +0200
+++ libgltf/src/LoadScene.h 2014-06-13 01:16:03.886647220 +0200
@@ -27,7 +27,8 @@
--- libgltf.org/src/LoadScene.h 2014-06-23 14:55:58.079723871 +0200
+++ libgltf/src/LoadScene.h 2014-06-23 14:56:37.303722182 +0200
@@ -21,7 +21,8 @@
public:
glTFHandle* getFileNameInJson(const std::string& jsonFile);
bool releaseFileName();
......@@ -31,41 +31,30 @@ diff -ur libgltf.org/src/LoadScene.h libgltf/src/LoadScene.h
bool parseJsonFile();
void setJsonInfo(const std::string& sbuffer);
void setJsonInfo(const std::string& direct, const std::string& fileName);
@@ -81,4 +82,4 @@
bool is_json_in_buffer;
};
-#endif
\ No newline at end of file
+#endif
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-13 01:13:40.654653289 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-13 01:15:11.222649451 +0200
@@ -561,7 +561,7 @@
--- libgltf.org/src/RenderScene.cpp 2014-06-23 14:55:58.099723870 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 14:56:07.239723477 +0200
@@ -657,16 +657,15 @@
{
return LIBGLTF_PARSE_JSON_ERROR;
}
- int iStatus = mLoadJson.parseScene(&scene);
+ int iStatus = mLoadJson.parseScene();
if (iStatus != LIBGLTF_SUCESS)
{
return iStatus;
@@ -571,12 +571,11 @@
return iStatus;
}
int RenderScene::loadScene(Scene& scene, glTFHandle* handle)
{
- scene.setGltfHandle(handle);
try
{
{
TRACE_TIME ("loadScene->parseScene", CPU);
- int iStatus = mLoadJson.parseScene(&scene);
+ int iStatus = mLoadJson.parseScene();
if (iStatus != LIBGLTF_SUCESS)
{
return iStatus;
@@ -612,7 +611,11 @@
}
- int iStatus = mLoadJson.parseScene(&scene);
+ int iStatus = mLoadJson.parseScene();
return iStatus;
}
catch (boost::property_tree::ptree_error& e)
@@ -694,7 +693,11 @@
return 0;
}
string tmpFileName(jsonfile->filename);
- return mLoadJson.getFileNameInJson(tmpFileName);
......@@ -77,22 +66,15 @@ diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
}
unsigned int RenderScene::bindAttribute(const Attribute* pAttr)
@@ -844,11 +847,6 @@
int RenderScene::initRender(glTFHandle* handle)
@@ -969,11 +972,6 @@
{
initOpengl();
- pScene = new Scene();
- if(0 == pScene)
- if (0 == pScene)
- {
- return LIBGLTF_MEMORY_ERROR;
- }
int iResult = loadScene(*pScene, handle);
if( iResult != LIBGLTF_SUCESS)
if (iResult != LIBGLTF_SUCCESS)
{
@@ -1543,4 +1541,4 @@
int RenderScene::isAnimPlay()
{
return this->mAnimationPlay ? 1 : 0;
-}
\ No newline at end of file
+}
diff -ur libgltf.org/src/FPSCounter.cpp libgltf/src/FPSCounter.cpp
--- libgltf.org/src/FPSCounter.cpp 2014-06-24 18:10:46.317967903 +0200
+++ libgltf/src/FPSCounter.cpp 2014-06-24 18:10:58.629967382 +0200
@@ -104,7 +104,7 @@
++mFrames;
}
- pFont->printFormattedString(pViewport->width - 100, 30, 15, "%d", mFPS);
+ pFont->printFormattedString(pViewport->width - 40, 10, 15, "%d", mFPS);
glEnable(GL_DEPTH_TEST);
}
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-24 16:53:41.030163890 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-24 16:53:44.406163746 +0200
@@ -1848,8 +1848,6 @@
void RenderScene::startAnimation()
{
- if (bAerialView)
- return;
this->mAnimationPlay = true;
mCurrentTime = 0;
mUpdateTimeOut = 0;
@@ -1858,8 +1856,6 @@
void RenderScene::stopAnimation()
{
- if (bAerialView)
- return;
if (pScene->getSkinSize() != 0)
{
this->mAnimationPlay = false;
@@ -1874,10 +1870,6 @@
roCameraY = glm::mat4(1.0);
pCamera->AerialViewY = 0.0;
bAerialView = false;
- if (bAnimation)
- {
- startAnimation();
- }
if (IsAerialMode)
{
pScene->setUseCameraInJson(true);
@@ -1897,10 +1889,6 @@
roCameraX = glm::mat4(1.0);
roCameraY = glm::mat4(1.0);
//Stop animation.
- if (pScene->getSkinSize() != 0)
- {
- this->mAnimationPlay = false;
- }
bAerialView = true;
if (pScene->getUseCameraInJson())
{
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 21:16:55.134739637 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 21:16:58.834739477 +0200
@@ -1976,5 +1976,10 @@
{
bIsTimeAvailable = false;
}
+ if( !mAnimationLoop && mCurrentTime > mDuration )
+ {
+ stopAnimation();
+ setAnimTime(0.0);
+ }
}
--- libgltf/src/RenderScene.h
+++ libgltf/src/RenderScene.h
@@ -16,7 +16,8 @@
#define TRACE_TIME
#endif
-#define OPENMPENABLE 1
+// Needs a configure / etc. detection to see if omp.h is on the system ...
+#define OPENMPENABLE 0
#if OPENMPENABLE
#include <omp.h>
#define WAVESIZE 4
diff -ur libgltf.org/src/Texture.cpp libgltf/src/Texture.cpp
--- libgltf.org/src/Texture.cpp 2014-05-27 16:40:18.625920865 +0200
+++ libgltf/src/Texture.cpp 2014-05-27 16:41:45.601917179 +0200
@@ -60,7 +60,7 @@
bool Texture::loadTexture2DFromBuffer(unsigned char* buffer, int width,
int height)
{
- GLenum format = GL_BGRA;
+ GLenum format = GL_RGBA;
createFromData(buffer, width, height, format, false);
diff -ur libgltf.org/src/Camera.cpp libgltf/src/Camera.cpp
--- libgltf.org/src/Camera.cpp 2014-06-24 17:36:27.870055125 +0200
+++ libgltf/src/Camera.cpp 2014-06-24 17:36:43.514054463 +0200
@@ -243,6 +243,8 @@
if (abs(horizontal) > planar || abs(vertical) > 0.0001)
{
bRotateCameraModel = true;
+ fRotateCameraXSpeed = 0;
+ fRotateCameraYSpeed = 0;
float deltaX = (float)(horizontal * fSensitivity * 0.01f);
float deltaY = (float)(-vertical * fSensitivity * 0.01f);
AerialViewY += -vertical;
diff -ur libgltf.org/src/libgltf.cpp libgltf/src/libgltf.cpp
--- libgltf.org/src/libgltf.cpp 2014-06-23 20:38:35.470838661 +0200
+++ libgltf/src/libgltf.cpp 2014-06-23 20:44:37.042823092 +0200
@@ -235,7 +235,7 @@
RenderScene* renderScene = (RenderScene*)handle->renderer;
if (time <= 0)
{
- renderScene->startAnimation();
+ renderScene->setAnimTime(0.0);
}
else
{
diff -ur libgltf.org/src/Common.cpp libgltf/src/Common.cpp
--- libgltf.org/src/Common.cpp 2014-06-23 20:16:17.746896264 +0200
+++ libgltf/src/Common.cpp 2014-06-23 20:17:50.610892265 +0200
@@ -1037,7 +1037,8 @@
/* -- Scene -- */
Scene::Scene()
- : pRootNode(0)
+ : mDuration(0.0)
+ , pRootNode(0)
, pBuffer(0)
, pGltfHandle(0)
, bUseCameraInJson(false)
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 21:17:51.466737211 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 21:23:23.718722904 +0200
@@ -602,6 +602,7 @@
, roCameraX(1.0f), roCameraY(1.0f)
, initCameraLocalMatrix(1.0f),initCameraGlobalMatrix(1.0f)
, bAnimation(true), pTempMatrix(0)
+ , bIsTimeAvailable(false)
{
mLastModelView = glm::mat4(0.0);
#if ENABLE_FPS
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-06-23 20:35:06.246847670 +0200
+++ libgltf/src/RenderScene.cpp 2014-06-23 20:35:24.366846890 +0200
@@ -1919,7 +1919,9 @@
double RenderScene::getAnimTime()
{
- return mCurrentTime;
+ errno = 0;
+ double time = fmod(this->mCurrentTime, this->mDuration);
+ return errno == EDOM ? 0.0 : time;
}
void RenderScene::setAnimLoop(int loop)
......@@ -1074,6 +1074,54 @@ libfreehand
See MPL Version 2 below
libgltf
The following software may be included in this product: libgltf. Use
of any of this software is governed by the terms of the license below:
License for libgltf except trackbal.h and trackball.cpp source files:
MPL 2
See MPL Version 2 below
License for trackbal.h and trackball.cpp source files:
(c) Copyright 1993, 1994, Silicon Graphics, Inc.
ALL RIGHTS RESERVED
Permission to use, copy, modify, and distribute this software for
any purpose and without fee is hereby granted, provided that the above
copyright notice appear in all copies and that both the copyright notice
and this permission notice appear in supporting documentation, and that
the name of Silicon Graphics, Inc. not be used in advertising
or publicity pertaining to distribution of the software without specific,
written prior permission.
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
US Government Users Restricted Rights
Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer Software
clause at DFARS 252.227-7013 and/or in similar or successor
clauses in the FAR or the DOD or NASA FAR Supplement.
Unpublished-- rights reserved under the copyright laws of the
United States. Contractor/manufacturer is Silicon Graphics,
Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
liblangtag
The following software may be included in this product: liblangtag. Use
......
......@@ -1137,6 +1137,56 @@ of any of this software is governed by the terms of the license
below:</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in"><A HREF="#Mozilla Public License Version 2.0|outline">Jump
to MPL Version </A><A HREF="#Mozilla Public License Version 2.0|outline">2</A></P>
<H2 CLASS="western">ligltf</H2>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">The
following software may be included in this product: libgltf. Use of
any of this software is governed by the terms of the license below:</P>
<H3 CLASS="western">License
for libgltf except trackbal.h and trackball.cpp source files:</H3>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">MPL
2</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in"><A HREF="#Mozilla Public License Version 2.0|outline">Jump
to MPL Version </A><A HREF="#Mozilla Public License Version 2.0|outline">2</A></P>
<H3 CLASS="western">License
for trackbal.h and trackball.cpp source files:</H3>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">(c)
Copyright 1993, 1994, Silicon Graphics, Inc.</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">ALL
RIGHTS RESERVED</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">Permission
to use, copy, modify, and distribute this software for
any purpose and without fee is hereby granted, provided that the above
copyright notice appear in all copies and that both the copyright notice
and this permission notice appear in supporting documentation, and that
the name of Silicon Graphics, Inc. not be used in advertising
or publicity pertaining to distribution of the software without specific,
written prior permission.</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">THE
MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU &quot;AS IS&quot;
AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">US
Government Users Restricted Rights</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">Use,
duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer Software
clause at DFARS 252.227-7013 and/or in similar or successor
clauses in the FAR or the DOD or NASA FAR Supplement.
Unpublished-- rights reserved under the copyright laws of the
United States. Contractor/manufacturer is Silicon Graphics,
Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.</P>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">
OpenGL(TM) is a trademark of Silicon Graphics, Inc.</P>
<H2 CLASS="western">liblangtag</H2>
<P CLASS="western" STYLE="margin-top: 0.12in; margin-bottom: 0.12in">The
following software may be included in this product: liblangtag. Use
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment