mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibGL: Implement glDrawBuffer
This commit is contained in:
parent
b069c1306c
commit
7cbaaf8366
7 changed files with 52 additions and 1 deletions
|
@ -25,6 +25,7 @@ extern "C" {
|
|||
// OpenGL related `defines`
|
||||
#define GL_TRUE 1
|
||||
#define GL_FALSE 0
|
||||
#define GL_NONE 0
|
||||
|
||||
// Matrix Modes
|
||||
#define GL_MODELVIEW 0x0050
|
||||
|
@ -352,6 +353,7 @@ GLAPI void glShadeModel(GLenum mode);
|
|||
GLAPI void glAlphaFunc(GLenum func, GLclampf ref);
|
||||
GLAPI void glHint(GLenum target, GLenum mode);
|
||||
GLAPI void glReadBuffer(GLenum mode);
|
||||
GLAPI void glDrawBuffer(GLenum buffer);
|
||||
GLAPI void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
|
||||
GLAPI void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data);
|
||||
GLAPI void glTexCoord2f(GLfloat s, GLfloat t);
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
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 gl_draw_buffer(GLenum buffer) = 0;
|
||||
virtual void gl_read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) = 0;
|
||||
virtual void gl_tex_image_2d(GLenum target, GLint level, GLint internal_format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data) = 0;
|
||||
virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) = 0;
|
||||
|
|
|
@ -85,6 +85,11 @@ void glReadBuffer(GLenum mode)
|
|||
g_gl_context->gl_read_buffer(mode);
|
||||
}
|
||||
|
||||
void glDrawBuffer(GLenum buffer)
|
||||
{
|
||||
g_gl_context->gl_draw_buffer(buffer);
|
||||
}
|
||||
|
||||
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
|
||||
{
|
||||
g_gl_context->gl_read_pixels(x, y, width, height, format, type, pixels);
|
||||
|
|
|
@ -960,6 +960,46 @@ void SoftwareGLContext::gl_read_buffer(GLenum mode)
|
|||
m_current_read_buffer = mode;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_draw_buffer(GLenum buffer)
|
||||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_draw_buffer, buffer);
|
||||
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
// FIXME: Also allow aux buffers GL_AUX0 through GL_AUX3 here
|
||||
// plus any aux buffer between 0 and GL_AUX_BUFFERS
|
||||
RETURN_WITH_ERROR_IF(buffer != GL_NONE
|
||||
&& buffer != GL_FRONT_LEFT
|
||||
&& buffer != GL_FRONT_RIGHT
|
||||
&& buffer != GL_BACK_LEFT
|
||||
&& buffer != GL_BACK_RIGHT
|
||||
&& buffer != GL_FRONT
|
||||
&& buffer != GL_BACK
|
||||
&& buffer != GL_LEFT
|
||||
&& buffer != GL_RIGHT,
|
||||
GL_INVALID_ENUM);
|
||||
|
||||
// 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.
|
||||
RETURN_WITH_ERROR_IF(buffer != GL_NONE
|
||||
&& buffer != GL_FRONT_LEFT
|
||||
&& buffer != GL_FRONT
|
||||
&& buffer != GL_BACK_LEFT
|
||||
&& buffer != GL_BACK
|
||||
&& buffer != GL_FRONT
|
||||
&& buffer != GL_BACK
|
||||
&& buffer != GL_LEFT,
|
||||
GL_INVALID_OPERATION);
|
||||
|
||||
m_current_draw_buffer = buffer;
|
||||
|
||||
auto rasterizer_options = m_rasterizer.options();
|
||||
rasterizer_options.draw_buffer = m_current_draw_buffer;
|
||||
m_rasterizer.set_options(rasterizer_options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
|
||||
{
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
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 gl_draw_buffer(GLenum buffer) override;
|
||||
virtual void gl_read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) override;
|
||||
virtual void gl_tex_image_2d(GLenum target, GLint level, GLint internal_format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data) override;
|
||||
virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) override;
|
||||
|
@ -152,6 +153,7 @@ private:
|
|||
GLclampf m_alpha_test_ref_value = 0;
|
||||
|
||||
GLenum m_current_read_buffer = GL_BACK;
|
||||
GLenum m_current_draw_buffer = GL_BACK;
|
||||
|
||||
// Client side arrays
|
||||
bool m_client_side_vertex_array_enabled = false;
|
||||
|
|
|
@ -334,7 +334,7 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
|||
}
|
||||
|
||||
// We will not update the color buffer at all
|
||||
if (!options.color_mask)
|
||||
if (!options.color_mask || options.draw_buffer == GL_NONE)
|
||||
continue;
|
||||
|
||||
// Draw the pixels according to the previously generated mask
|
||||
|
|
|
@ -44,6 +44,7 @@ struct RasterizerOptions {
|
|||
GLboolean fog_enabled { false };
|
||||
GLfloat fog_start { 0.0f };
|
||||
GLfloat fog_end { 1.0f };
|
||||
GLenum draw_buffer { GL_BACK };
|
||||
};
|
||||
|
||||
class SoftwareRasterizer final {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue