libgltf: Update to the new version.

Change-Id: Iffc91425d4395699a1c5f18ac10f5ed065231fdf
This commit is contained in:
Jan Holesovsky 2014-05-12 21:56:26 +02:00
parent 1b0402f87c
commit f933cb0a64
16 changed files with 15 additions and 324 deletions

View File

@ -37,7 +37,7 @@ uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( do
throw ( uno::RuntimeException, std::exception )
{
boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[m_pHandle->viewport.width * m_pHandle->viewport.height * 4]);
gltf_renderer_get_bitmap(m_pHandle, fMediaTime, (char*)pBuffer.get(), GL_BGRA);
gltf_renderer_get_bitmap(&m_pHandle, 1, fMediaTime, (char*)pBuffer.get(), GL_BGRA);
BitmapEx aBitmap = OpenGLHelper::ConvertBGRABufferToBitmapEx(pBuffer.get(), m_pHandle->viewport.width, m_pHandle->viewport.height);
return Graphic( aBitmap ).GetXGraphic();
}

View File

@ -32,7 +32,7 @@ OGLWindow::~OGLWindow()
void SAL_CALL OGLWindow::update() throw (css::uno::RuntimeException, std::exception)
{
m_pContext->makeCurrent();
gltf_prepare_renderer(m_pHandle);
gltf_prepare_renderer(&m_pHandle->viewport);
gltf_renderer(m_pHandle);
gltf_complete_renderer();
m_pContext->swapBuffers();

View File

@ -88,7 +88,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 := 1c366663a8d54d570b8b2f90784814d9-libgltf.tar.bz2
export LIBGLTF_TARBALL := 02faa5e385c7083fc1e9cfbe71470e1f-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

View File

@ -18,16 +18,6 @@ $(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/typedef_used_as_struct.patch \
external/libgltf/patches/avoid_c++11_copy_filestream.patch \
external/libgltf/patches/unneeded_context_handling.patch \
external/libgltf/patches/win_only_variables.patch \
external/libgltf/patches/constify_for_temporaries.patch \
external/libgltf/patches/shader_charbuffer_used_as_cstring.patch \
external/libgltf/patches/get_bitmap_new_syntax.patch \
external/libgltf/patches/remove_extra_include.patch \
external/libgltf/patches/fmod_error_handling.patch \
external/libgltf/patches/extern-C.patch \
))
# vim: set noet sw=4 ts=4:

View File

@ -1,12 +0,0 @@
diff -ur libgltf.org/src/FPSCounter.h libgltf/src/FPSCounter.h
--- libgltf.org/src/FPSCounter.h 2014-05-05 14:36:38.983373597 +0200
+++ libgltf/src/FPSCounter.h 2014-05-05 14:40:20.327383038 +0200
@@ -70,7 +70,7 @@
#endif
#if WRITEFPS2FILE
- FPSFile = ofstream("./FPSCounter.txt");
+ FPSFile.open("./FPSCounter.txt");
#endif
}
~FPSCounter()

View File

@ -1,24 +0,0 @@
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-05-05 14:45:21.447395883 +0200
+++ libgltf/src/RenderScene.cpp 2014-05-05 14:47:14.819400718 +0200
@@ -776,7 +776,7 @@
return;
}
-void RenderScene::updateBoneMatrix(Bone* pBone, glm::mat4& matrix)
+void RenderScene::updateBoneMatrix(Bone* pBone, const glm::mat4& matrix)
{
if (0 == pBone)
{
diff -ur libgltf.org/src/RenderScene.h libgltf/src/RenderScene.h
--- libgltf.org/src/RenderScene.h 2014-05-05 14:45:21.447395883 +0200
+++ libgltf/src/RenderScene.h 2014-05-05 14:47:48.111402138 +0200
@@ -170,7 +170,7 @@
void renderPrimitive(class RenderPrimitive* pPrimitive);
void updateJointInfo(Bone* pBone);
- void updateBoneMatrix(Bone* pBone, glm::mat4& matrix);
+ void updateBoneMatrix(Bone* pBone, const glm::mat4& matrix);
glm::mat4* calcProjectionMatrix();
glm::vec3* calcLightColor();

View File

@ -1,20 +0,0 @@
--- libgltf/inc/libgltf.h
+++ libgltf/inc/libgltf.h
@@ -48,7 +48,6 @@
void gltf_get_camera_pos(glm::vec3 *pos,glm::vec3 *view,glm::vec3 *up);
/*get model center position information*/
-extern "C"
glm::vec3 gltf_get_model_center_pos();
/*get camera position information*/
extern "C"
--- libgltf/src/libgltf.cpp
+++ libgltf/src/libgltf.cpp
@@ -59,7 +59,6 @@
return;
}
-extern "C"
glm::vec3 gltf_get_model_center_pos()
{
return cameraScene->getModelCenterPos();

View File

@ -1,22 +0,0 @@
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-05-06 18:26:20.097144491 +0200
+++ libgltf/src/RenderScene.cpp 2014-05-06 18:26:26.281144733 +0200
@@ -11,6 +11,7 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
+#include <cerrno>
RenderPrimitive::RenderPrimitive()
: mVerterCount(0), mIndicesCount(0)
@@ -979,7 +980,9 @@
double RenderScene::getAnimTime()
{
- return fmod(this->mCurrentTime, this->mDuration);
+ errno = 0;
+ double time = fmod(this->mCurrentTime, this->mDuration);
+ return errno == EDOM ? 0.0 : time;
}
void RenderScene::setAnimLoop(int loop)

View File

@ -1,69 +0,0 @@
diff -ur libgltf.org/inc/libgltf.h libgltf/inc/libgltf.h
--- libgltf.org/inc/libgltf.h 2014-05-06 11:56:54.756228299 +0200
+++ libgltf/inc/libgltf.h 2014-05-06 11:57:55.104230666 +0200
@@ -10,6 +10,7 @@
#include <stddef.h>
#include "types.h"
#include "Common.h"
+#include <GL/glew.h>
#include <glm/glm.hpp>
using namespace glTF;
@@ -66,7 +67,7 @@
/** Get a bitmap of the screen in the given point in time. */
extern "C"
void gltf_renderer_get_bitmap(glTFHandle *handle, double time,
- char* buffer, long width, long height);
+ char* buffer, GLenum format);
/** Start playing the glTF animation to the current openGLcontext. */
extern "C"
diff -ur libgltf.org/src/libgltf.cpp libgltf/src/libgltf.cpp
--- libgltf.org/src/libgltf.cpp 2014-05-06 11:56:54.756228299 +0200
+++ libgltf/src/libgltf.cpp 2014-05-06 11:57:00.620228529 +0200
@@ -95,10 +95,10 @@
extern "C"
void gltf_renderer_get_bitmap(glTFHandle *handle, double time,
- char* buffer, long width, long height)
+ char* buffer, GLenum format)
{
RenderScene* renderScene = (RenderScene*)handle->renderer;
- renderScene->renderToBuffer(&(handle->viewport), (unsigned char*)buffer);
+ renderScene->renderToBuffer(&(handle->viewport), (unsigned char*)buffer, format);
return;
}
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-05-06 11:56:54.756228299 +0200
+++ libgltf/src/RenderScene.cpp 2014-05-06 11:57:03.852228656 +0200
@@ -859,7 +859,7 @@
return sCamera;
}
-void RenderScene::renderToBuffer(glTFViewport* pViewport, unsigned char * buffer)
+void RenderScene::renderToBuffer(glTFViewport* pViewport, unsigned char * buffer, GLenum format)
{
createRenderObj(pViewport->width, pViewport->height);
createTextureObj(pViewport->width, pViewport->height);
@@ -876,7 +876,7 @@
GLenum fbResult = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if( fbResult != GL_FRAMEBUFFER_COMPLETE )
result = false;
- glReadPixels(0, 0, pViewport->width, pViewport->height, GL_BGR,
+ glReadPixels(0, 0, pViewport->width, pViewport->height, format,
GL_UNSIGNED_BYTE, buffer);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &mFBOID);
diff -ur libgltf.org/src/RenderScene.h libgltf/src/RenderScene.h
--- libgltf.org/src/RenderScene.h 2014-05-06 11:56:54.756228299 +0200
+++ libgltf/src/RenderScene.h 2014-05-06 11:57:01.524228565 +0200
@@ -124,7 +124,7 @@
void releaseRender(void* lpParam);
// For bitmap
- void renderToBuffer(glTFViewport* pViewpoit, unsigned char * buffer);
+ void renderToBuffer(glTFViewport* pViewpoit, unsigned char * buffer, GLenum format);
// For animation
void startAnimation();

View File

@ -10,10 +10,3 @@ diff -ur libgltf.org/src/Font.h libgltf/src/Font.h
#include FT_FREETYPE_H
#include "Texture.h"
@@ -49,4 +49,4 @@
FT_Face mFTFace;
unsigned int mShaderId;
};
-#endif
\ No newline at end of file
+#endif

View File

@ -1,3 +1,15 @@
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
@ -10,13 +22,6 @@ diff -ur libgltf.org/src/Camera.h libgltf/src/Camera.h
#include <glm/glm.hpp>
class CPhysicalCamera
@@ -45,4 +45,4 @@
int iForw, iBack, iLeft, iRight;
};
-#endif
\ No newline at end of file
+#endif
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

View File

@ -1,11 +0,0 @@
diff -ur libgltf.org/inc/libgltf.h libgltf/inc/libgltf.h
--- libgltf.org/inc/libgltf.h 2014-05-06 11:59:40.224234787 +0200
+++ libgltf/inc/libgltf.h 2014-05-06 12:00:15.192236159 +0200
@@ -9,7 +9,6 @@
#define LIBGLTF_H
#include <stddef.h>
#include "types.h"
-#include "Common.h"
#include <GL/glew.h>
#include <glm/glm.hpp>
using namespace glTF;

View File

@ -1,94 +0,0 @@
diff -ur libgltf.org/src/Common.cpp libgltf/src/Common.cpp
--- libgltf.org/src/Common.cpp 2014-05-05 15:02:17.155439207 +0200
+++ libgltf/src/Common.cpp 2014-05-05 15:04:25.631444687 +0200
@@ -518,8 +518,10 @@
if(vShaderIdx >= 0 && fShaderIdx >= 0)
{
const char* pvShader = pGltfHandle->files[vShaderIdx]->buffer;
+ size_t ivShaderSize = pGltfHandle->files[vShaderIdx]->size;
const char* pfShader = pGltfHandle->files[fShaderIdx]->buffer;
- mProgramId = mShaderProg.createProgram(pvShader, pfShader);
+ size_t ifShaderSize = pGltfHandle->files[fShaderIdx]->size;
+ mProgramId = mShaderProg.createProgram(pvShader, ivShaderSize, pfShader, ifShaderSize);
}
if (0 != mProgramId)
{
diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp
--- libgltf.org/src/Shaders.cpp 2014-05-05 15:02:17.155439207 +0200
+++ libgltf/src/Shaders.cpp 2014-05-05 15:09:30.143457676 +0200
@@ -105,12 +105,12 @@
return programId;
}
-unsigned int ShaderProgram::createProgram(const char* pvShader, const char* pfShader)
+unsigned int ShaderProgram::createProgram(const char* pvShader, size_t ivShaderSize, const char* pfShader, size_t ifShaderSize)
{
unsigned int programId = glCreateProgram();
- if (!loadShader(programId, pvShader, GL_VERTEX_SHADER))
+ if (!loadShader(programId, pvShader, ivShaderSize, GL_VERTEX_SHADER))
return 0;
- if (!loadShader(programId, pfShader, GL_FRAGMENT_SHADER))
+ if (!loadShader(programId, pfShader, ifShaderSize, GL_FRAGMENT_SHADER))
return 0;
return programId;
@@ -137,7 +137,7 @@
return false;
}
- if (!compileShader(shaderCode.c_str(), shaderId))
+ if (!compileShader(shaderCode.c_str(), shader.length(), shaderId))
{
std::cout << "compileShader : compileShader failed." << std::endl;
return false;
@@ -153,11 +153,11 @@
return true;
}
-bool ShaderProgram::loadShader(unsigned int programId, const char* pShader, int type)
+bool ShaderProgram::loadShader(unsigned int programId, const char* pShader, size_t iSize, int type)
{
unsigned int shaderId = glCreateShader(type);
- if (!compileShader(pShader, shaderId))
+ if (!compileShader(pShader, iSize, shaderId))
{
std::cout << "compileShader : compileShader failed." << std::endl;
return false;
@@ -173,9 +173,10 @@
return true;
}
-bool ShaderProgram::compileShader(const char* pShader, unsigned int shaderId)
+bool ShaderProgram::compileShader(const char* pShader, size_t iSize, unsigned int shaderId)
{
- glShaderSource(shaderId, 1, &pShader, NULL);
+ GLint iGLSize = iSize;
+ glShaderSource(shaderId, 1, &pShader, &iGLSize);
glCompileShader(shaderId);
int iStatus = 0;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &iStatus);
diff -ur libgltf.org/src/Shaders.h libgltf/src/Shaders.h
--- libgltf.org/src/Shaders.h 2014-05-05 15:02:17.155439207 +0200
+++ libgltf/src/Shaders.h 2014-05-05 15:10:26.003460059 +0200
@@ -39,17 +39,17 @@
void setUniform(unsigned int uProgId, const char* name, const glm::mat4 mMatrix);
unsigned int createProgram(const std::string& vName, const std::string& fName);
- unsigned int createProgram(const char* pvShader, const char* pfShader);
+ unsigned int createProgram(const char* pvShader, size_t ivShaderSize, const char* pfShader, size_t ifShaderSize);
void deleteProgram(unsigned int programId);
void useProgram(unsigned int programId);
bool loadShader(unsigned int programId, const std::string& shaderName, int type);
- bool loadShader(unsigned int programId, const char* pShader, int type);
+ bool loadShader(unsigned int programId, const char* pShader, size_t iSize, int type);;
private:
- bool compileShader(const char* pShader, unsigned int shaderId);
+ bool compileShader(const char* pShader, size_t iSize, unsigned int shaderId);
bool linkProgram(unsigned int programId, unsigned int shaderId);

View File

@ -1,14 +0,0 @@
diff -ur libgltf.org/src/Common.h libgltf/src/Common.h
--- libgltf.org/src/Common.h 2014-05-05 14:31:00.483359159 +0200
+++ libgltf/src/Common.h 2014-05-05 14:34:02.055366903 +0200
@@ -536,8 +536,8 @@
unsigned int mCount;
double mMaxTime;
double mMinTime;
- std::vector<struct QuatKey> mTimeRorateVec;
- //std::vector<struct QuatKey> mTimeTransfromVec;
+ std::vector<QuatKey> mTimeRorateVec;
+ //std::vector<QuatKey> mTimeTransfromVec;
};
class Animation

View File

@ -1,18 +0,0 @@
diff -ur libgltf.org/src/RenderScene.cpp libgltf/src/RenderScene.cpp
--- libgltf.org/src/RenderScene.cpp 2014-05-05 14:42:40.523389018 +0200
+++ libgltf/src/RenderScene.cpp 2014-05-05 14:43:01.027389893 +0200
@@ -746,7 +746,6 @@
#if ENABLE_FPS
pFPSCounter->printFPS(&viewport);
#endif
- SwapBuffers(wglGetCurrentDC());
return;
}
@@ -1004,4 +1003,4 @@
int RenderScene::isAnimPlay()
{
return this->mAnimationPlay ? 1 : 0;
-}
\ No newline at end of file
+}

View File

@ -1,13 +0,0 @@
diff -ur libgltf.org/src/FPSCounter.cpp libgltf/src/FPSCounter.cpp
--- libgltf.org/src/FPSCounter.cpp 2014-05-05 14:44:01.711392481 +0200
+++ libgltf/src/FPSCounter.cpp 2014-05-05 14:44:34.495393880 +0200
@@ -119,7 +119,9 @@
if (timeCounter>=TIMETHRESHOLD)
{
FPSFile<<"FPS:"<<mFPS<<"\n";
+#ifdef _WIN32
FPSFile<<"Render Total Time: "<<mTotalTime*1000<<" ms"<<"Draw Time: "<<mGPUTime*1000<<" ms\n";
+#endif
timeCounter = 0;
}
#endif