Kaydet (Commit) f0bd1c69 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

OGFrameGrabber: use a BGRA buffer

Change-Id: Ie827ba98a6ff65d63eb61df1d90e18919de86395
üst 99a034f9
......@@ -15,6 +15,10 @@
#include <vcl/salbtype.hxx>
#include <vcl/bmpacc.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
#include <boost/scoped_array.hpp>
using namespace com::sun::star;
namespace avmedia { namespace ogl {
......@@ -32,26 +36,9 @@ OGLFrameGrabber::~OGLFrameGrabber()
uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double fMediaTime )
throw ( uno::RuntimeException, std::exception )
{
// TODO: libgltf should provide an RGBA buffer, not just an RGB one. See: OpenGLRender::GetAsBitmap().
char* pBuffer = new char[m_pHandle->viewport.width * m_pHandle->viewport.height * 3];
gltf_renderer_get_bitmap(m_pHandle, fMediaTime, pBuffer, m_pHandle->viewport.width, m_pHandle->viewport.height);
Bitmap aBitmap( Size(m_pHandle->viewport.width, m_pHandle->viewport.height), 24 );
{
Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
size_t nCurPos = 0;
for( int y = 0; y < m_pHandle->viewport.height; ++y)
{
Scanline pScan = pWriteAccess->GetScanline(y);
for( int x = 0; x < m_pHandle->viewport.width; ++x )
{
*pScan++ = pBuffer[nCurPos];
*pScan++ = pBuffer[nCurPos+1];
*pScan++ = pBuffer[nCurPos+2];
nCurPos += 3;
}
}
}
delete [] pBuffer;
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(), m_pHandle->viewport.width, m_pHandle->viewport.height, GL_BGRA);
BitmapEx aBitmap = OpenGLHelper::ConvertBGRABufferToBitmapEx(pBuffer.get(), m_pHandle->viewport.width, m_pHandle->viewport.height);
return Graphic( aBitmap ).GetXGraphic();
}
......
......@@ -26,6 +26,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,libgltf,\
external/libgltf/patches/avoid_c++11.patch \
external/libgltf/patches/json_charbuffer_used_as_cstring.patch \
external/libgltf/patches/shader_charbuffer_used_as_cstring.patch \
external/libgltf/patches/format_parameter_for_bitmap.patch \
))
# vim: set noet sw=4 ts=4:
diff -ur libgltf.org/inc/libgltf.h libgltf/inc/libgltf.h
--- libgltf.org/inc/libgltf.h 2014-04-27 14:10:06.191988313 +0200
+++ libgltf/inc/libgltf.h 2014-04-27 14:12:03.171983919 +0200
@@ -47,7 +47,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, long width, long height, GLenum format);
/** Start playing the glTF animation to the current openGLcontext. */
extern "C"
@@ -80,4 +80,4 @@
/** Query where exactly the animation is, in seconds. */
extern "C"
double gltf_animation_get_time(glTFHandle *handle);
-#endif
\ No newline at end of file
+#endif
diff -ur libgltf.org/src/libgltf.cpp libgltf/src/libgltf.cpp
--- libgltf.org/src/libgltf.cpp 2014-04-27 14:10:06.192988313 +0200
+++ libgltf/src/libgltf.cpp 2014-04-27 14:12:06.648983788 +0200
@@ -70,10 +70,10 @@
extern "C"
void gltf_renderer_get_bitmap(glTFHandle *handle, double time,
- char* buffer, long width, long height)
+ char* buffer, long width, long height, GLenum format)
{
class 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-04-27 14:10:06.192988313 +0200
+++ libgltf/src/RenderScene.cpp 2014-04-27 14:11:03.199986172 +0200
@@ -630,7 +630,7 @@
return pCamera;
}
-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);
@@ -647,7 +647,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-04-27 14:10:06.192988313 +0200
+++ libgltf/src/RenderScene.h 2014-04-27 14:13:41.291980233 +0200
@@ -91,7 +91,7 @@
void render(void* lpParam);
void releaseRender(void* lpParam);
CPhysicalCamera* getCamera();
- void renderToBuffer(glTFViewport* pViewpoit, unsigned char * buffer);
+ void renderToBuffer(glTFViewport* pViewpoit, unsigned char * buffer, GLenum format);
void renderRotateCamera(double horizontal, double vertical,
double planar, double time);
void renderMoveCamera(double x, double y, double z, double time);
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