mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 11:27:35 +00:00
LibGL: Implement glRasterPos2i
This commit is contained in:
parent
78d0674228
commit
4eb6295a57
6 changed files with 41 additions and 1 deletions
|
@ -7,6 +7,7 @@ set(SOURCES
|
|||
GLBlend.cpp
|
||||
GLColor.cpp
|
||||
GLContext.cpp
|
||||
GLDraw.cpp
|
||||
GLFog.cpp
|
||||
GLLights.cpp
|
||||
GLLists.cpp
|
||||
|
|
|
@ -451,6 +451,7 @@ GLAPI void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
|||
GLAPI void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
GLAPI void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
|
||||
GLAPI void glNormal3fv(GLfloat const* v);
|
||||
GLAPI void glRasterPos2i(GLint x, GLint y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) = 0;
|
||||
virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = 0;
|
||||
virtual void gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) = 0;
|
||||
virtual void gl_raster_pos(GLfloat x, GLfloat y, GLfloat z, GLfloat w) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
|
15
Userland/Libraries/LibGL/GLDraw.cpp
Normal file
15
Userland/Libraries/LibGL/GLDraw.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Jelle Raaijmakers <jelle@gmta.nl>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
extern GL::GLContext* g_gl_context;
|
||||
|
||||
void glRasterPos2i(GLint x, GLint y)
|
||||
{
|
||||
g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.0f, 1.0f);
|
||||
}
|
|
@ -2248,6 +2248,15 @@ void SoftwareGLContext::gl_normal(GLfloat nx, GLfloat ny, GLfloat nz)
|
|||
m_current_vertex_normal = { nx, ny, nz };
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_raster_pos(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
||||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_raster_pos, x, y, z, w);
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
m_current_raster_position.window_coordinates = { x, y, z };
|
||||
m_current_raster_position.clip_coordinate_value = w;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) override;
|
||||
virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) override;
|
||||
virtual void gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) override;
|
||||
virtual void gl_raster_pos(GLfloat x, GLfloat y, GLfloat z, GLfloat w) override;
|
||||
virtual void present() override;
|
||||
|
||||
private:
|
||||
|
@ -269,7 +270,8 @@ private:
|
|||
decltype(&SoftwareGLContext::gl_scissor),
|
||||
decltype(&SoftwareGLContext::gl_stencil_func_separate),
|
||||
decltype(&SoftwareGLContext::gl_stencil_op_separate),
|
||||
decltype(&SoftwareGLContext::gl_normal)>;
|
||||
decltype(&SoftwareGLContext::gl_normal),
|
||||
decltype(&SoftwareGLContext::gl_raster_pos)>;
|
||||
|
||||
using ExtraSavedArguments = Variant<
|
||||
FloatMatrix4x4>;
|
||||
|
@ -305,6 +307,17 @@ private:
|
|||
u8 m_pack_alignment { 4 };
|
||||
GLsizei m_unpack_row_length { 0 };
|
||||
u8 m_unpack_alignment { 4 };
|
||||
|
||||
struct RasterPosition {
|
||||
FloatVector3 window_coordinates { 0.0f, 0.0f, 0.0f };
|
||||
float clip_coordinate_value { 1.0f };
|
||||
float eye_coordinate_distance { 0.0f };
|
||||
bool valid { true };
|
||||
FloatVector4 color_rgba { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
float color_index { 1.0f };
|
||||
FloatVector4 texture_coordinates { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
};
|
||||
RasterPosition m_current_raster_position;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue