Ocean
Loading...
Searching...
No Matches
BitmapContext.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_PLATFORM_GL_WIN_BITMAP_CONTEXT_H
9#define META_OCEAN_PLATFORM_GL_WIN_BITMAP_CONTEXT_H
10
12
14
16
17namespace Ocean
18{
19
20namespace Platform
21{
22
23namespace GL
24{
25
26namespace Win
27{
28
29/**
30 * This class implements an OpenGL context based on a bitmap.
31 * Beware: Only OpenGL 1.1 is supported.<br>
32 * @ingroup platformglwin
33 */
34class OCEAN_PLATFORM_GL_WIN_EXPORT BitmapContext : public Context
35{
36 public:
37
38 /**
39 * Creates a new bitmap framebuffer with default values.
40 */
41 BitmapContext() = default;
42
43 /**
44 * Creates a new bitmap framebuffer with specified dimension, pixel format and pixel origin.
45 * @param width The width of the framebuffer in pixel, with range [0, infinity)
46 * @param height The height of the framebuffer in pixel, with range [0, infinity)
47 * @param pixelFormat The pixel format of the framebuffer
48 * @param pixelOrigin The pixel origin of the framebuffer
49 */
50 BitmapContext(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin);
51
52 /**
53 * Destructs this context.
54 */
55 ~BitmapContext() override;
56
57 /**
58 * Returns the bitmap of this framebuffer.
59 * @return The framebuffer's bitmap
60 */
61 inline const Platform::Win::Bitmap& bitmap() const;
62
63 /**
64 * Sets the size (the OpenGL viewport) of this framebuffer with upper left corner set to (0, 0).
65 * @param width The width of the framebuffer in pixel, with range [0, infinity)
66 * @param height The height of the framebuffer in pixel, with range [0, infinity)
67 * @return True, if succeeded
68 */
69 bool setSize(const unsigned int width, const unsigned int height);
70
71 /**
72 * Makes the OpenGL rendering context of this framebuffer the calling thread's current rendering context or makes the calling thread's current rendering context not longer current.
73 * @see OpenGLFramebuffer::makeCurrent().
74 */
75 void makeCurrent(const bool state = true) override;
76
77 protected:
78
79 /**
80 * Creates the OpenGL context for this framebuffer.
81 * @see Context::createOpenGLContext().
82 */
83 bool createOpenGLContext(const bool initializeOpenGL31 = false, const unsigned int multisamples = 1u) override;
84
85 /**
86 * Releases the OpenGL context of this framebuffer.
87 * @see Context::releaseOpenGLContext().
88 */
89 bool releaseOpenGLContext() override;
90
91 protected:
92
93 /// The bitmap of the framebuffer on which the OpenGL context will be created.
95
96 /// The pixel format of the framebuffer.
97 FrameType::PixelFormat pixelFormat_ = FrameType::FORMAT_UNDEFINED;
98
99 //// The pixel origin of the framebuffer.
100 FrameType::PixelOrigin pixelOrigin_ = FrameType::ORIGIN_INVALID;
101};
102
104{
105 return bitmap_;
106}
107
108}
109
110}
111
112}
113
114}
115
116#endif // META_OCEAN_PLATFORM_GL_WIN_BITMAP_CONTEXT_H
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1046
This class encapsulates an OpenGL context.
Definition platform/gl/Context.h:29
This class implements an OpenGL context based on a bitmap.
Definition BitmapContext.h:35
const Platform::Win::Bitmap & bitmap() const
Returns the bitmap of this framebuffer.
Definition BitmapContext.h:103
Platform::Win::Bitmap bitmap_
The bitmap of the framebuffer on which the OpenGL context will be created.
Definition BitmapContext.h:94
~BitmapContext() override
Destructs this context.
bool releaseOpenGLContext() override
Releases the OpenGL context of this framebuffer.
BitmapContext()=default
Creates a new bitmap framebuffer with default values.
BitmapContext(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin)
Creates a new bitmap framebuffer with specified dimension, pixel format and pixel origin.
bool createOpenGLContext(const bool initializeOpenGL31=false, const unsigned int multisamples=1u) override
Creates the OpenGL context for this framebuffer.
void makeCurrent(const bool state=true) override
Makes the OpenGL rendering context of this framebuffer the calling thread's current rendering context...
bool setSize(const unsigned int width, const unsigned int height)
Sets the size (the OpenGL viewport) of this framebuffer with upper left corner set to (0,...
This class implements a Windows device independent bitmap.
Definition win/Bitmap.h:30
The namespace covering the entire Ocean framework.
Definition Accessor.h:15