17 #ifndef DGL_OPENGL_HPP_INCLUDED
18 #define DGL_OPENGL_HPP_INCLUDED
20 #include "ImageBase.hpp"
21 #include "ImageBaseWidgets.hpp"
26 #undef DGL_CALLBACK_DEFINED
27 #undef DGL_WINGDIAPI_DEFINED
29 #ifdef DISTRHO_OS_WINDOWS
32 # define APIENTRY __stdcall
37 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
38 # define WINGDIAPI __declspec(dllimport)
39 # elif defined(__LCC__)
40 # define WINGDIAPI __stdcall
42 # define WINGDIAPI extern
44 # define DGL_WINGDIAPI_DEFINED
49 # if defined(_MSC_VER)
50 # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
51 # define CALLBACK __stdcall
56 # define CALLBACK __stdcall
58 # define DGL_CALLBACK_DEFINED
64 #endif // DISTRHO_OS_WINDOWS
70 # include <OpenGL/gl.h>
72 # ifndef DISTRHO_OS_WINDOWS
73 # define GL_GLEXT_PROTOTYPES
76 # include <GL/glext.h>
82 #if defined(GL_BGR_EXT) && !defined(GL_BGR)
83 # define GL_BGR GL_BGR_EXT
86 #if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
87 # define GL_BGRA GL_BGRA_EXT
90 #ifndef GL_CLAMP_TO_BORDER
91 # define GL_CLAMP_TO_BORDER 0x812D
97 #ifdef DGL_CALLBACK_DEFINED
99 # undef DGL_CALLBACK_DEFINED
102 #ifdef DGL_WINGDIAPI_DEFINED
104 # undef DGL_WINGDIAPI_DEFINED
121 ImageFormat asDISTRHOImageFormat(
const GLenum format)
126 return kImageFormatGrayscale;
128 return kImageFormatBGR;
130 return kImageFormatBGRA;
132 return kImageFormatRGB;
134 return kImageFormatRGBA;
137 return kImageFormatNull;
141 GLenum asOpenGLImageFormat(
const ImageFormat format)
145 case kImageFormatNull:
147 case kImageFormatGrayscale:
149 case kImageFormatBGR:
151 case kImageFormatBGRA:
153 case kImageFormatRGB:
155 case kImageFormatRGBA:
188 OpenGLImage(
const char* rawData, uint width, uint height, ImageFormat format = kImageFormatBGRA);
212 ImageFormat format = kImageFormatBGRA) noexcept
override;
225 inline void loadFromMemory(
const char* rdata, uint w, uint h, ImageFormat fmt = kImageFormatBGRA)
237 DISTRHO_DEPRECATED_BY(
"OpenGLImage(const char*, uint, uint, ImageFormat)")
238 explicit OpenGLImage(
const char* rawData, uint width, uint height, GLenum glFormat);
245 DISTRHO_DEPRECATED_BY(
"OpenGLImage(const char*, const Size<uint>&, ImageFormat)")
252 DISTRHO_DEPRECATED_BY(
"draw(const GraphicsContext&)")
259 DISTRHO_DEPRECATED_BY(
"drawAt(const GraphicsContext&, int, int)")
260 void drawAt(
int x,
int y);
266 DISTRHO_DEPRECATED_BY(
"drawAt(const GraphicsContext&, const Point<int>&)")
274 GLenum
getType() const noexcept {
return GL_UNSIGNED_BYTE; }