Commit graph

29 commits

Author SHA1 Message Date
Erik Biederstadt
61bd1890d2 LibGL: Implement very basic version of glGetFloatv
This is a very basic implementation of glGetfloatv. It will only give a
result when used with GL_MODELVIEW_MATRIX. In the future
 we can update and extend it's functionality.
2021-06-09 10:49:38 +02:00
Jesse Buhagiar
8298e406a4 LibGL: Use Texture Units in Rasterizer and Context
The Context and Software Rasterizer now gets the array of texture units
instead of a single texture object. _Technically_, we now support some
primitive form of multi-texturing, though I'm not entirely sure how well
it will work in its current state.
2021-05-31 14:59:47 +01:00
Jesse Buhagiar
573c1c82f7 LibGL: Implement glActiveTexture 2021-05-31 14:59:47 +01:00
Jesse Buhagiar
52e5d3c961 LibGL: Implement basic texture units
These are merely a way to hold the different texture target bind
points that a texture can be bound to.
2021-05-31 14:59:47 +01:00
Stephan Unverwerth
755393e684 LibGL: Implement glBindTexture()
Textures are now initialized with a nullptr upon generation.
They are only actually created once they are bound to a target.
Currently only the GL_TEXTURE_2D target is supported.
The software rasterizer now allows rendering with or without
a bound TEXTURE_2D.
2021-05-30 00:32:37 +01:00
Stephan Unverwerth
10ceeb092f Everywhere: Use s.unverwerth@serenityos.org :^) 2021-05-29 12:30:08 +01:00
Jesse Buhagiar
e21ba0cd12 LibGL: Implement glTexCoord2f 2021-05-26 16:36:53 +04:30
Jesse Buhagiar
4f324ba4d7 LibGL: Implement Texture State Management
Some very primitive Texture State management. Data can now be
uploaded to textures.
2021-05-26 16:36:53 +04:30
Jesse Buhagiar
21dff6d40b LibGL: Add Texture Name Allocation
Texture names can now be allocated via
`glGenTextures` and deallocated via `glDeleteTextures`.
2021-05-26 16:36:53 +04:30
Stephan Unverwerth
d6c84ca4df LibGL: Implement glReadPixels() stub with argument validation 2021-05-24 19:03:25 +01:00
Stephan Unverwerth
24e74750d5 LibGL: Implement glReadBuffer() 2021-05-24 19:03:25 +01:00
Stephan Unverwerth
eed0bcaf42 LibGL: Implement glHint() 2021-05-20 23:29:56 +02:00
Stephan Unverwerth
1bd754882d LibGL: Implement glAlphaFunc()
This implements glAlphaFunc() for setting alpha test func and ref value
and also allows enabling and disabling GL_ALPHA_TEST
2021-05-16 19:27:23 +02:00
Stephan Unverwerth
d6e8634576 LibGL: Add glBlendFunc() and glShadeModel() to call lists 2021-05-16 15:53:58 +02:00
Stephan Unverwerth
da57563c1c LibGL: Implement glShadeModel()
This turns off interpolation of vertex colors when GL_FLAT is selected.
2021-05-16 15:53:58 +02:00
Stephan Unverwerth
d6e9b433cf LibGL: Add support for GL_BLEND in glEnable() and glDisable() 2021-05-16 00:44:31 +01:00
Stephan Unverwerth
279737642c LibGL: Add defines and stubs for glBlendFunc() 2021-05-16 00:44:31 +01:00
Stephan Unverwerth
2b9ad11bd8 LibGL: Implement glFlush() and glFinish() 2021-05-14 22:15:50 +02:00
Ali Mohammad Pur
720d21411b LibGL: Implement glGenLists and a few friends
This commit implements glGenLists(), glNewList(), glDeleteLists(), and
glCallList().
The 'compiled' records are implemented as a vector of member function
pointers and tuples containing their arguments, and a mechanism is
implemented to allow the recorded calls to copy-capture values from the
time of the call; this is currently only used with glLoadMatrix.
2021-05-11 14:09:17 +01:00
Stephan Unverwerth
a8fc4be47a LibGL: Add supporting code for depth buffer
This adds glClearDepth() and new caps for enabling and disabling
the depth buffer with glEnable() and glDisable()
2021-05-09 15:58:35 +02:00
Jesse Buhagiar
e8cd89a538 LibGL: Move polygon clipping to Clipper class
This code has also been optimised to be much more memory
friendly by removing a _lot_ of extraneous copies. The result
is that, when profiled, it's around 8x faster than the previous
implementation.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-05-08 10:13:22 +02:00
Stephan Unverwerth
5ff248649b LibGL: Add software rasterizer
This is based mostly on Fabian "ryg" Giesen's 2011 blog series
"A trip through the Graphics Pipeline" and Scratchapixel's
"Rasterization: a Practical Implementation".

The rasterizer processes triangles in grid aligned 16x16 pixel blocks,
calculates barycentric coordinates and edge derivatives and interpolates
bilinearly across each block.

This will theoretically allow for better utilization of modern processor
features such as SMT and SIMD, as opposed to a classic scanline based
triangle rasterizer.

This serves as a starting point to get something on the screen.
In the future we might look into properly pipelining the main loop to
make the rasterizer more flexible, enabling us to enable/disable
certain features at the block rather than the pixel level.
2021-05-08 10:13:22 +02:00
Stephan Unverwerth
e6c0600499 LibGL: Add back face culling functions
Adds all needed functions to support back face culling
and implements back face culling in the SoftwareGLContext.
2021-05-08 10:13:22 +02:00
Ali Mohammad Pur
f601f12801 LibGL: Implement glOrtho and underlying functions 2021-05-08 10:13:22 +02:00
Jesse Buhagiar
f07a7f7b94 LibGL: Impement glLoadMatrixf and underlying function 2021-05-08 10:13:22 +02:00
Jesse Buhagiar
ea0df0b5da LibGL: Implement glScalef 2021-05-08 10:13:22 +02:00
Jesse Buhagiar
1959efe063 LibGL: Set GL error on some calls during begin/end
According to the OpenGL 2.x spec, some calls will set the current
global error to `GL_INVALID_OPERATION` if they are used during
a `glBegin`/`glEnd` block.
2021-05-08 10:13:22 +02:00
Jesse Buhagiar
e537e2690a LibGL: Implement glGetError and underlying function
This implements `glGetError` and correctly sets the state machine's
error macro (similar to LibC `errno`) when an invalid operation is
performed. This is reset on completion of a successful operation.
2021-05-08 10:13:22 +02:00
Jesse Buhagiar
4807d32139 LibGL: Implement a basic OpenGL 1.x compatible library
This currently (obviously) doesn't support any actual 3D hardware,
hence all calls are done via software rendering.

Note that any modern constructs such as shaders are unsupported,
as this driver only implements Fixed Function Pipeline functionality.

The library is split into a base GLContext interface and a software
based renderer implementation of said interface. The global glXXX
functions serve as an OpenGL compatible c-style interface to the
currently bound context instance.

Co-authored-by: Stephan Unverwerth <s.unverwerth@gmx.de>
2021-05-08 10:13:22 +02:00