Kaydet (Commit) 779ae371 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

reuse OpenGLContext in OGL canvas

The only thing that needs to be reimplemented is the pbuffer based
custom sprite rendering. We should use a FBO with a texture backend
for that. This will also save several OpenGL context switches!

Change-Id: I4aef33ae2499e44c8b5f41c296d8721cb94a37a1
üst a7f3c73f
......@@ -43,12 +43,12 @@ $(eval $(call gb_Library_add_exception_objects,oglcanvas,\
$(eval $(call gb_Library_use_externals,oglcanvas,\
boost_headers \
glew \
))
ifeq ($(strip $(OS)),MACOSX)
$(eval $(call gb_Library_use_system_darwin_frameworks,oglcanvas,\
Cocoa \
GLUT \
OpenGL \
))
......
......@@ -25,10 +25,7 @@
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glew.h>
using namespace ::com::sun::star;
......@@ -161,10 +158,10 @@ namespace oglcanvas
// drats. need to render to temp surface before, and then
// composite that to screen
// TODO(P3): buffer pbuffer, maybe even keep content
// (in a texture?)
pBufferContext=maCanvasHelper.getDeviceHelper()->createBufferContext(aSpriteSizePixel);
pBufferContext->startBufferRendering();
// TODO(P3): buffer texture
// TODO: moggi: reimplement as FBO with rendering to texture
pBufferContext = NULL;
// pBufferContext->startBufferRendering();
}
// this ends up in pBufferContext, if that one's "current"
......
......@@ -36,9 +36,7 @@
#include "ogl_texturecache.hxx"
#include "ogl_tools.hxx"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glew.h>
#include <boost/scoped_array.hpp>
......
......@@ -22,10 +22,7 @@
#include <com/sun/star/rendering/ARGBColor.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glew.h>
using namespace ::com::sun::star;
......
......@@ -27,9 +27,6 @@
#include "ogl_canvascustomsprite.hxx"
#include <GL/gl.h>
#include <GL/glext.h>
#define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.OGL"
#define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.OGL"
......
......@@ -10,6 +10,8 @@
#ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
#define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
#include <vcl/opengl/OpenGLContext.hxx>
#include <rtl/ref.hxx>
#include <canvas/elapsedtime.hxx>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
......@@ -20,7 +22,6 @@
#include <set>
class Window;
class SystemChildWindow;
namespace basegfx{ class B2IVector; class B2DHomMatrix; }
......@@ -113,26 +114,11 @@ namespace oglcanvas
/// Get instance of internal texture cache
TextureCache& getTextureCache() const;
// nobody except IBufferContext implementations are supposed
// to use this
bool activatePBufferContext(const ::basegfx::B2IVector& rSize,
unsigned int PBuffer) const;
bool activateWindowContext() const;
bool updatePBufferTexture( const ::basegfx::B2IVector&,
unsigned int ) const;
bool activateWindowContext();
private:
void resize( const ::basegfx::B2IVector& rNewSize );
void compileShader(unsigned int& o_rShaderHandle,
unsigned int eShaderType,
const char* pShaderSourceCode);
void linkShaders(unsigned int& o_rProgramHandle,
unsigned int nVertexProgramId,
unsigned int nFragmentProgramId);
/** Phyical output device
Deliberately not a refcounted reference, because of
......@@ -149,28 +135,16 @@ namespace oglcanvas
/// For the frame counter timings
::canvas::tools::ElapsedTime maLastUpdate;
boost::shared_ptr<SystemChildWindow> mpChildWindow;
void* mpDisplay;
void* mpGLContext;
void* mpGLPBufContext;
void* mpFBConfig;
boost::shared_ptr<TextureCache> mpTextureCache;
unsigned int mnDummyVertexProgram;
unsigned int mnLinearTwoColorGradientFragmentProgram;
unsigned int mnLinearMultiColorGradientFragmentProgram;
unsigned int mnRadialTwoColorGradientFragmentProgram;
unsigned int mnRadialMultiColorGradientFragmentProgram;
unsigned int mnRectangularTwoColorGradientFragmentProgram;
unsigned int mnRectangularMultiColorGradientFragmentProgram;
unsigned int mnLinearTwoColorGradientProgram;
unsigned int mnLinearMultiColorGradientProgram;
unsigned int mnRadialTwoColorGradientProgram;
unsigned int mnRadialMultiColorGradientProgram;
unsigned int mnRectangularTwoColorGradientProgram;
unsigned int mnRectangularMultiColorGradientProgram;
OpenGLContext maContext;
};
}
......
......@@ -13,9 +13,7 @@
#include <com/sun/star/geometry/IntegerSize2D.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/glew.h>
using namespace ::com::sun::star;
......
......@@ -11,7 +11,7 @@
#define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_TOOLS_HXX
#include <sal/config.h>
#include <GL/gl.h>
#include <GL/glew.h>
namespace oglcanvas
......
......@@ -10556,8 +10556,7 @@ if test "x$enable_opengl" = "xno"; then
elif test "$_os" = "Darwin"; then
# We use frameworks on Mac OS X, no need for detail checks
ENABLE_OPENGL=TRUE
ENABLE_OPENGL_CANVAS=
add_warning "openGL canvas not adapted for Mac yet - disabling"
ENABLE_OPENGL_CANVAS=TRUE
SYSTEM_MESA_HEADERS=TRUE
AC_MSG_RESULT([yes])
elif test $_os = WINNT; then
......
......@@ -162,6 +162,9 @@ public:
void setWinSize(const Size& rSize);
GLWindow& getOpenGLWindow() { return m_aGLWin;}
SystemChildWindow* getChildWindow();
const SystemChildWindow* getChildWindow() const;
void renderToFile();
bool isInitialized()
......
......@@ -898,4 +898,14 @@ void OpenGLContext::show()
m_pWindow->Show();
}
SystemChildWindow* OpenGLContext::getChildWindow()
{
return m_pChildWindow;
}
const SystemChildWindow* OpenGLContext::getChildWindow() const
{
return m_pChildWindow;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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