mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibGL: Implement glReadBuffer()
This commit is contained in:
parent
0c6f019285
commit
24e74750d5
5 changed files with 60 additions and 2 deletions
|
@ -73,9 +73,15 @@ extern "C" {
|
||||||
#define GL_ONE_MINUS_DST_COLOR 0x0307
|
#define GL_ONE_MINUS_DST_COLOR 0x0307
|
||||||
#define GL_SRC_ALPHA_SATURATE 0x0308
|
#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_FRONT 0x0404
|
||||||
#define GL_BACK 0x0405
|
#define GL_BACK 0x0405
|
||||||
|
#define GL_LEFT 0x0406
|
||||||
|
#define GL_RIGHT 0x0407
|
||||||
#define GL_FRONT_AND_BACK 0x0408
|
#define GL_FRONT_AND_BACK 0x0408
|
||||||
|
|
||||||
// Error codes
|
// Error codes
|
||||||
|
@ -204,6 +210,7 @@ GLAPI void glBlendFunc(GLenum sfactor, GLenum dfactor);
|
||||||
GLAPI void glShadeModel(GLenum mode);
|
GLAPI void glShadeModel(GLenum mode);
|
||||||
GLAPI void glAlphaFunc(GLenum func, GLclampf ref);
|
GLAPI void glAlphaFunc(GLenum func, GLclampf ref);
|
||||||
GLAPI void glHint(GLenum target, GLenum mode);
|
GLAPI void glHint(GLenum target, GLenum mode);
|
||||||
|
GLAPI void glReadBuffer(GLenum mode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
virtual void gl_shade_model(GLenum mode) = 0;
|
virtual void gl_shade_model(GLenum mode) = 0;
|
||||||
virtual void gl_alpha_func(GLenum func, GLclampf ref) = 0;
|
virtual void gl_alpha_func(GLenum func, GLclampf ref) = 0;
|
||||||
virtual void gl_hint(GLenum target, GLenum mode) = 0;
|
virtual void gl_hint(GLenum target, GLenum mode) = 0;
|
||||||
|
virtual void gl_read_buffer(GLenum mode) = 0;
|
||||||
|
|
||||||
virtual void present() = 0;
|
virtual void present() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,3 +74,8 @@ void glHint(GLenum target, GLenum mode)
|
||||||
{
|
{
|
||||||
g_gl_context->gl_hint(target, mode);
|
g_gl_context->gl_hint(target, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glReadBuffer(GLenum mode)
|
||||||
|
{
|
||||||
|
g_gl_context->gl_read_buffer(mode);
|
||||||
|
}
|
|
@ -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.
|
// 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()
|
void SoftwareGLContext::present()
|
||||||
{
|
{
|
||||||
m_rasterizer.blit_to(*m_frontbuffer);
|
m_rasterizer.blit_to(*m_frontbuffer);
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
virtual void gl_shade_model(GLenum mode) override;
|
virtual void gl_shade_model(GLenum mode) override;
|
||||||
virtual void gl_alpha_func(GLenum func, GLclampf ref) override;
|
virtual void gl_alpha_func(GLenum func, GLclampf ref) override;
|
||||||
virtual void gl_hint(GLenum target, GLenum mode) override;
|
virtual void gl_hint(GLenum target, GLenum mode) override;
|
||||||
|
virtual void gl_read_buffer(GLenum mode) override;
|
||||||
|
|
||||||
virtual void present() override;
|
virtual void present() override;
|
||||||
|
|
||||||
|
@ -117,6 +118,8 @@ private:
|
||||||
GLenum m_alpha_test_func = GL_ALWAYS;
|
GLenum m_alpha_test_func = GL_ALWAYS;
|
||||||
GLclampf m_alpha_test_ref_value = 0;
|
GLclampf m_alpha_test_ref_value = 0;
|
||||||
|
|
||||||
|
GLenum m_current_read_buffer = GL_BACK;
|
||||||
|
|
||||||
NonnullRefPtr<Gfx::Bitmap> m_frontbuffer;
|
NonnullRefPtr<Gfx::Bitmap> m_frontbuffer;
|
||||||
|
|
||||||
Clipper m_clipper;
|
Clipper m_clipper;
|
||||||
|
@ -172,7 +175,8 @@ private:
|
||||||
decltype(&SoftwareGLContext::gl_blend_func),
|
decltype(&SoftwareGLContext::gl_blend_func),
|
||||||
decltype(&SoftwareGLContext::gl_shade_model),
|
decltype(&SoftwareGLContext::gl_shade_model),
|
||||||
decltype(&SoftwareGLContext::gl_alpha_func),
|
decltype(&SoftwareGLContext::gl_alpha_func),
|
||||||
decltype(&SoftwareGLContext::gl_hint)>;
|
decltype(&SoftwareGLContext::gl_hint),
|
||||||
|
decltype(&SoftwareGLContext::gl_read_buffer)>;
|
||||||
|
|
||||||
using ExtraSavedArguments = Variant<
|
using ExtraSavedArguments = Variant<
|
||||||
FloatMatrix4x4>;
|
FloatMatrix4x4>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue