summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-06-25 15:19:41 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-06-29 11:10:54 +0000
commitb8ee401f7a3be5d8a3252983829eb0f5f371280e (patch)
tree1643ec3461c41fb0f1df09366d4211e7b9faa268 /avmedia
parent2387c53dba185b45b0e34beae2a8ddaa315bb689 (diff)
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) Reviewed-on: https://gerrit.libreoffice.org/9895 Reviewed-by: Zolnai Tamás <zolnaitamas2000@gmail.com> Tested-by: Zolnai Tamás <zolnaitamas2000@gmail.com> (cherry picked from commit 6403f2b59b4c83e0899012e5ca0ddd705784350c) Conflicts: avmedia/source/opengl/oglplayer.cxx Change-Id: Ia6c9c4da53a9b4fedba0d73aa5791489f8ad424b libgltf: variable names need module prefix Change-Id: Id144a483fe5576cdd546ac5da87890dc61f964b3 (cherry picked from commit d83e66da94d9c789190c4729c8f0c8464e99ba88) libgltf: add patch to find the headers in WORKDIR Change-Id: I8570511be7c1d6de94ee82e18bad5b00b36d99bb (cherry picked from commit dfe787ef5de1b38e61989507b26ee4b92f25b9d5) libgltf: try to fix the MSVC2010 build Change-Id: I8dde439d19be45d5039904b6e917b17ca0ee4758 (cherry picked from commit 96ff10449464ae9d869fe21dccf193a6eef670c1) glTF rendering: moving in walktrough mode is to fast Change-Id: I2b7869c6c14b69732db864a03a2d9b6638424cf7 (cherry picked from commit f2b5ece0caca18f21f7c8e42a84d451bb399ec35) libgltf: use --with-pick Change-Id: Ide01491460c9c81ed044be762c7dd07e8a5ca575 (cherry picked from commit bb9078e3dee48afc4c2bd8006a892924f8b38b39) libgltf: replace configure patch to avoid using autoreconf Change-Id: Idcab012af9c27c4fed31c07ce230816d1c61d605 (cherry picked from commit c5bb272883e042e38c58847f6eb2a2f94c6ef919) libgltf: try again with this configure patch Touch only the configure but not the configure.ac Change-Id: Iee93036f2378f29530ffae9be8b4324e8425d2ec (cherry picked from commit 211e07c0e02ebfe9cea4b5d97b614a23f8b2012c) libgltf: remove dependencies of config.h.in It seems something is wrong with the files in the libgltf tarball (maybe wrong timestamps?), because config.h.in is always regenerated by make (autoheader). It causes build problems so just remove the deps for this time. Change-Id: I404c29673987d7c8f75ec8fe4978173593c75a2f (cherry picked from commit 3bebda9cd3269d684a3b430e25f17951deaf3d3d) libgltf: fix typo in license Change-Id: I0e5f3afb19c2457c5ccca922e75e617312801ab9 (cherry picked from commit 1d5e875a6c61ddc9fbf0ed09878b7dfb75f89fe3) libgltf: compiler error fixes: missing include and missing namespace Thanks to Rene Engelhard for the report and the fixes. Change-Id: Ia14980bdbcd9e714b1e9cd41f04af9371aa22371 (cherry picked from commit 481a17b6a6fb332935c3e41c077cc5f60b751021) libgltf: it seems gb_SPACE is not that we need here Change-Id: I099f2bb007cdd29db25a99ca84e53115a12379bd (cherry picked from commit c7d6541f5daa59d04accb30c727a83d936f02150) libgltf: fix wrong include path to config_$(gb_Side) Change-Id: I63d1822fd08c997a9432ed09ada6d5299bc658b1 (cherry picked from commit ab028bf00e3e5f8424ea5e746815e8438144e4bf) libgltf: use WHITESPACE Change-Id: I47ca82d5f08431c8af8b8a85cfbfd083ebd6fda0 (cherry picked from commit b05b970daaf69b5b491b847375ee07539de9481f) libgltf: make 'Requires' valid in libgltf-0.0.pc file Thanks to Rene Engelhard for help to make it valid. Plus glu is not used, so remove it. Change-Id: I5e3631e9b3d24c2b1d9044192d7c0a55c234f7c0 (cherry picked from commit 4bdbc1c93bb3b7e6b1f2fc9a700977ccfa3daae4) Change-Id: Ia14980bdbcd9e714b1e9cd41f04af9371aa22371 Reviewed-on: https://gerrit.libreoffice.org/9922 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/Library_avmedia.mk1
-rw-r--r--avmedia/Library_avmediaogl.mk9
-rw-r--r--avmedia/source/opengl/oglplayer.cxx26
-rw-r--r--avmedia/source/opengl/oglplayer.hxx1
-rw-r--r--avmedia/source/opengl/oglwindow.cxx70
-rw-r--r--avmedia/source/opengl/oglwindow.hxx1
6 files changed, 70 insertions, 38 deletions
diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk
index 63e9067ec38c..184c66c7d201 100644
--- a/avmedia/Library_avmedia.mk
+++ b/avmedia/Library_avmedia.mk
@@ -27,7 +27,6 @@ $(eval $(call gb_Library_use_externals,avmedia,\
boost_headers \
glew \
mesa_headers \
- zlib \
))
$(eval $(call gb_Library_use_libraries,avmedia,\
diff --git a/avmedia/Library_avmediaogl.mk b/avmedia/Library_avmediaogl.mk
index afa52ca006d4..3bbebe885b97 100644
--- a/avmedia/Library_avmediaogl.mk
+++ b/avmedia/Library_avmediaogl.mk
@@ -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
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index eaf9e2d7d920..b481943d261f 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -27,6 +27,8 @@ namespace avmedia { namespace ogl {
OGLPlayer::OGLPlayer()
: Player_BASE(m_aMutex)
, m_pHandle(NULL)
+ , m_pOGLWindow(NULL)
+ , m_bIsRendering(false)
{
}
@@ -140,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 )
@@ -150,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 )
@@ -168,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);
}
double SAL_CALL OGLPlayer::getRate() throw ( uno::RuntimeException, std::exception )
@@ -270,6 +282,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 );
}
@@ -297,6 +312,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 );
}
diff --git a/avmedia/source/opengl/oglplayer.hxx b/avmedia/source/opengl/oglplayer.hxx
index e7da91e002e7..579e56b9628f 100644
--- a/avmedia/source/opengl/oglplayer.hxx
+++ b/avmedia/source/opengl/oglplayer.hxx
@@ -65,6 +65,7 @@ private:
OpenGLContext m_aContext;
AutoTimer m_aTimer;
OGLWindow* m_pOGLWindow;
+ bool m_bIsRendering;
};
} // namespace ogl
diff --git a/avmedia/source/opengl/oglwindow.cxx b/avmedia/source/opengl/oglwindow.cxx
index f7f9a23d3d60..ffb0855806f4 100644
--- a/avmedia/source/opengl/oglwindow.cxx
+++ b/avmedia/source/opengl/oglwindow.cxx
@@ -21,6 +21,7 @@ OGLWindow::OGLWindow( glTFHandle& rHandle, OpenGLContext& rContext, Window& rEve
, m_bVisible ( false )
, meZoomLevel( media::ZoomLevel_ORIGINAL )
, m_aLastMousePos(Point())
+ , m_bIsOrbitMode( false )
{
}
@@ -262,33 +263,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.0005f*fModelSize);
+ if(nCode == KEY_S)vMoveBy -= vMove*(0.0005f*fModelSize);
+ if( !m_bIsOrbitMode )
+ {
+ if(nCode == KEY_A)vMoveBy -= vStrafe*(0.0005f*fModelSize);
+ if(nCode == KEY_D)vMoveBy += vStrafe*(0.0005f*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);
}
}
}
@@ -316,14 +320,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;
}
diff --git a/avmedia/source/opengl/oglwindow.hxx b/avmedia/source/opengl/oglwindow.hxx
index db2d867af81a..5a52cca9e3e6 100644
--- a/avmedia/source/opengl/oglwindow.hxx
+++ b/avmedia/source/opengl/oglwindow.hxx
@@ -71,6 +71,7 @@ private:
bool m_bVisible;
com::sun::star::media::ZoomLevel meZoomLevel;
Point m_aLastMousePos;
+ bool m_bIsOrbitMode;
};
} // namespace ogl