2014-04-15 00:55:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2014-04-18 18:21:34 +02:00
|
|
|
#ifndef INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
|
|
|
|
#define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
|
2014-04-15 00:55:07 +02:00
|
|
|
|
|
|
|
#include <GL/glew.h>
|
2015-04-23 13:44:47 +03:00
|
|
|
#include <vcl/dllapi.h>
|
2014-04-18 15:24:25 +02:00
|
|
|
#include <vcl/bitmapex.hxx>
|
2014-04-15 00:55:07 +02:00
|
|
|
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
|
2014-12-22 19:10:59 +01:00
|
|
|
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
|
2014-11-04 17:31:12 -05:00
|
|
|
# include <prex.h>
|
|
|
|
# include "GL/glxew.h"
|
|
|
|
# include <postx.h>
|
|
|
|
#endif
|
|
|
|
|
2015-04-23 13:44:47 +03:00
|
|
|
class VCL_DLLPUBLIC OpenGLHelper
|
2014-04-15 00:55:07 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 14:48:48 +01:00
|
|
|
static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble = "" );
|
2014-04-15 00:55:07 +02:00
|
|
|
|
2014-08-04 12:04:10 +02:00
|
|
|
/**
|
2014-08-11 10:18:04 +02:00
|
|
|
* The caller is responsible for allocate the memory for the RGBA buffer, before call
|
|
|
|
* this method. RGBA buffer size is assumed to be 4*width*height.
|
|
|
|
* Since OpenGL uses textures flipped relative to BitmapEx storage this method
|
2014-09-17 08:04:36 +02:00
|
|
|
* also adds the possibility to mirror the bitmap vertically at the same time.
|
2014-08-04 12:04:10 +02:00
|
|
|
**/
|
2014-09-17 08:04:36 +02:00
|
|
|
static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer, const bool bFlip = false);
|
2014-04-27 20:25:52 +02:00
|
|
|
static BitmapEx ConvertBGRABufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight);
|
2014-05-09 00:31:05 +02:00
|
|
|
static void renderToFile(long nWidth, long nHeight, const OUString& rFileName);
|
2014-04-29 08:27:58 +03:00
|
|
|
|
|
|
|
static const char* GLErrorString(GLenum errorCode);
|
2014-05-21 00:41:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The caller is responsible for deleting the buffer objects identified by
|
2014-05-21 14:23:07 +02:00
|
|
|
* nFramebufferId, nRenderbufferDepthId and nRenderbufferColorId
|
2014-08-08 04:52:38 +02:00
|
|
|
* @param bRenderbuffer true => off-screen rendering, false => rendering to texture
|
|
|
|
* This also affects whether to free with glDeleteRenderbuffers or glDeleteTextures
|
2014-05-21 00:41:37 +02:00
|
|
|
*/
|
2014-08-08 04:52:38 +02:00
|
|
|
static void createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId,
|
2014-08-08 05:05:11 +02:00
|
|
|
GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId, bool bRenderbuffer = true);
|
2014-07-20 14:20:35 +02:00
|
|
|
|
|
|
|
// Get OpenGL version (needs a context)
|
|
|
|
static float getGLVersion();
|
2014-08-18 15:38:04 +02:00
|
|
|
|
|
|
|
static void checkGLError(const char* aFile, size_t nLine);
|
2014-11-02 00:12:21 +01:00
|
|
|
|
2014-11-20 09:52:03 +01:00
|
|
|
/**
|
|
|
|
* checks if the device/driver pair is on our OpenGL blacklist
|
|
|
|
*/
|
|
|
|
static bool isDeviceBlacklisted();
|
2014-11-02 00:12:21 +01:00
|
|
|
/**
|
|
|
|
* checks if the system supports all features that are necessary for the OpenGL VCL support
|
|
|
|
*/
|
|
|
|
static bool supportsVCLOpenGL();
|
2014-11-04 17:31:12 -05:00
|
|
|
|
2014-11-10 16:02:31 +00:00
|
|
|
/**
|
|
|
|
* Returns true if VCL has OpenGL rendering enabled
|
|
|
|
*/
|
|
|
|
static bool isVCLOpenGLEnabled();
|
|
|
|
|
2014-12-22 19:10:59 +01:00
|
|
|
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
|
2014-11-04 17:31:12 -05:00
|
|
|
static bool GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI);
|
2014-11-08 13:14:14 -05:00
|
|
|
static GLXFBConfig GetPixmapFBConfig( Display* pDisplay, bool& bInverted );
|
2014-11-04 17:31:12 -05:00
|
|
|
#endif
|
2014-04-15 00:55:07 +02:00
|
|
|
};
|
|
|
|
|
2014-08-18 15:38:04 +02:00
|
|
|
#define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
|
|
|
|
|
2014-04-15 00:55:07 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|