diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2021-05-24 15:24:49 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-24 19:03:25 +0100 |
commit | 24e74750d5c31c510bc42b3295f3f618026e57bb (patch) | |
tree | 623695fd25263d0329204866d090b75140ca5b2a /Userland/Libraries/LibGL | |
parent | 0c6f0192857265fd0c94cba165a28a448c1ba18b (diff) | |
download | serenity-24e74750d5c31c510bc42b3295f3f618026e57bb.zip |
LibGL: Implement glReadBuffer()
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r-- | Userland/Libraries/LibGL/GL/gl.h | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLUtils.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 41 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 6 |
5 files changed, 60 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index 46408e70f6..b00383a57e 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -73,9 +73,15 @@ extern "C" { #define GL_ONE_MINUS_DST_COLOR 0x0307 #define GL_SRC_ALPHA_SATURATE 0x0308 -// Culled face side +// Sides +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 #define GL_FRONT 0x0404 #define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 #define GL_FRONT_AND_BACK 0x0408 // Error codes @@ -204,6 +210,7 @@ GLAPI void glBlendFunc(GLenum sfactor, GLenum dfactor); GLAPI void glShadeModel(GLenum mode); GLAPI void glAlphaFunc(GLenum func, GLclampf ref); GLAPI void glHint(GLenum target, GLenum mode); +GLAPI void glReadBuffer(GLenum mode); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 46b120610f..c731540c81 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -53,6 +53,7 @@ public: virtual void gl_shade_model(GLenum mode) = 0; virtual void gl_alpha_func(GLenum func, GLclampf ref) = 0; virtual void gl_hint(GLenum target, GLenum mode) = 0; + virtual void gl_read_buffer(GLenum mode) = 0; virtual void present() = 0; }; diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp index d5f217862c..539aacfb32 100644 --- a/Userland/Libraries/LibGL/GLUtils.cpp +++ b/Userland/Libraries/LibGL/GLUtils.cpp @@ -74,3 +74,8 @@ void glHint(GLenum target, GLenum mode) { g_gl_context->gl_hint(target, mode); } + +void glReadBuffer(GLenum mode) +{ + g_gl_context->gl_read_buffer(mode); +}
\ No newline at end of file diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 7c84dea98a..a64d38b427 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -1009,6 +1009,47 @@ void SoftwareGLContext::gl_hint(GLenum target, GLenum mode) // According to the spec implementors are free to ignore glHint. So we do. } +void SoftwareGLContext::gl_read_buffer(GLenum mode) +{ + APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_read_buffer, mode); + + if (m_in_draw_state) { + m_error = GL_INVALID_OPERATION; + return; + } + + // FIXME: Also allow aux buffers GL_AUX0 through GL_AUX3 here + // plus any aux buffer between 0 and GL_AUX_BUFFERS + if (mode != GL_FRONT_LEFT + && mode != GL_FRONT_RIGHT + && mode != GL_BACK_LEFT + && mode != GL_BACK_RIGHT + && mode != GL_FRONT + && mode != GL_BACK + && mode != GL_LEFT + && mode != GL_RIGHT) { + m_error = GL_INVALID_ENUM; + return; + } + + // FIXME: We do not currently have aux buffers, so make it an invalid + // operation to select anything but front or back buffers. Also we do + // not allow selecting the stereoscopic RIGHT buffers since we do not + // have them configured. + if (mode != GL_FRONT_LEFT + && mode != GL_FRONT + && mode != GL_BACK_LEFT + && mode != GL_BACK + && mode != GL_FRONT + && mode != GL_BACK + && mode != GL_LEFT) { + m_error = GL_INVALID_OPERATION; + return; + } + + m_current_read_buffer = mode; +} + void SoftwareGLContext::present() { m_rasterizer.blit_to(*m_frontbuffer); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index 8ea205be08..c368979365 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -59,6 +59,7 @@ public: virtual void gl_shade_model(GLenum mode) override; virtual void gl_alpha_func(GLenum func, GLclampf ref) override; virtual void gl_hint(GLenum target, GLenum mode) override; + virtual void gl_read_buffer(GLenum mode) override; virtual void present() override; @@ -117,6 +118,8 @@ private: GLenum m_alpha_test_func = GL_ALWAYS; GLclampf m_alpha_test_ref_value = 0; + GLenum m_current_read_buffer = GL_BACK; + NonnullRefPtr<Gfx::Bitmap> m_frontbuffer; Clipper m_clipper; @@ -172,7 +175,8 @@ private: decltype(&SoftwareGLContext::gl_blend_func), decltype(&SoftwareGLContext::gl_shade_model), decltype(&SoftwareGLContext::gl_alpha_func), - decltype(&SoftwareGLContext::gl_hint)>; + decltype(&SoftwareGLContext::gl_hint), + decltype(&SoftwareGLContext::gl_read_buffer)>; using ExtraSavedArguments = Variant< FloatMatrix4x4>; |