mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibGL+LibGPU+LibSoftGPU: Implement point and line drawing
Implement (anti)aliased point drawing and anti-aliased line drawing. Supported through LibGL's `GL_POINTS`, `GL_LINES`, `GL_LINE_LOOP` and `GL_LINE_STRIP`. In order to support this, `LibSoftGPU`s rasterization logic was reworked. Now, any primitive can be drawn by invoking `rasterize()` which takes care of the quad loop and fragment testing logic. Three callbacks need to be passed: * `set_coverage_mask`: the primitive needs to provide initial coverage mask information so fragments can be discarded early. * `set_quad_depth`: fragments survived stencil testing, so depth values need to be set so depth testing can take place. * `set_quad_attributes`: fragments survived depth testing, so fragment shading is going to take place. All attributes like color, tex coords and fog depth need to be set so alpha testing and eventually, fragment rasterization can take place. As of this commit, there are four instantiations of this function: * Triangle rasterization * Points - aliased * Points - anti-aliased * Lines - anti-aliased In order to standardize vertex processing for all primitive types, things like vertex transformation, lighting and tex coord generation are now taking place before clipping.
This commit is contained in:
parent
950ded7ab9
commit
a20bf80b05
13 changed files with 712 additions and 390 deletions
|
@ -133,22 +133,8 @@ void GLContext::gl_end()
|
|||
|
||||
// Make sure we had a `glBegin` before this call...
|
||||
RETURN_WITH_ERROR_IF(!m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
m_in_draw_state = false;
|
||||
|
||||
// FIXME: Add support for the remaining primitive types.
|
||||
if (m_current_draw_mode != GL_TRIANGLES
|
||||
&& m_current_draw_mode != GL_TRIANGLE_FAN
|
||||
&& m_current_draw_mode != GL_TRIANGLE_STRIP
|
||||
&& m_current_draw_mode != GL_QUADS
|
||||
&& m_current_draw_mode != GL_QUAD_STRIP
|
||||
&& m_current_draw_mode != GL_POLYGON) {
|
||||
|
||||
m_vertex_list.clear_with_capacity();
|
||||
dbgln_if(GL_DEBUG, "gl_end(): draw mode {:#x} unsupported", m_current_draw_mode);
|
||||
RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM);
|
||||
}
|
||||
|
||||
Vector<size_t, 32> enabled_texture_units;
|
||||
for (size_t i = 0; i < m_texture_units.size(); ++i) {
|
||||
if (m_texture_units[i].texture_2d_enabled())
|
||||
|
@ -159,6 +145,18 @@ void GLContext::gl_end()
|
|||
|
||||
GPU::PrimitiveType primitive_type;
|
||||
switch (m_current_draw_mode) {
|
||||
case GL_LINE_LOOP:
|
||||
primitive_type = GPU::PrimitiveType::LineLoop;
|
||||
break;
|
||||
case GL_LINE_STRIP:
|
||||
primitive_type = GPU::PrimitiveType::LineStrip;
|
||||
break;
|
||||
case GL_LINES:
|
||||
primitive_type = GPU::PrimitiveType::Lines;
|
||||
break;
|
||||
case GL_POINTS:
|
||||
primitive_type = GPU::PrimitiveType::Points;
|
||||
break;
|
||||
case GL_TRIANGLES:
|
||||
primitive_type = GPU::PrimitiveType::Triangles;
|
||||
break;
|
||||
|
@ -178,7 +176,6 @@ void GLContext::gl_end()
|
|||
}
|
||||
|
||||
m_rasterizer->draw_primitives(primitive_type, m_model_view_matrix, m_projection_matrix, m_texture_matrix, m_vertex_list, enabled_texture_units);
|
||||
|
||||
m_vertex_list.clear_with_capacity();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue