Commit graph

85 commits

Author SHA1 Message Date
Jelle Raaijmakers
1056bac49a LibGL: Implement glCallLists 2021-12-12 21:51:08 +01:00
Jelle Raaijmakers
7ac8cd057e LibGL: Implement glMultMatrixf 2021-12-12 21:51:08 +01:00
Jelle Raaijmakers
40724a426f LibGL: Implement glGetDoublev 2021-12-12 21:51:08 +01:00
Jelle Raaijmakers
0be2a76ee7 LibGL: Use simpler syntax for GL_SCISSOR_BOX retrieval 2021-12-11 23:15:24 +01:00
Jelle Raaijmakers
7ad70f623e LibGL: Make glDeleteTextures skip over 0 names
As stated in the manual:
     glDeleteTextures silently ignores 0's and names that do not
     correspond to existing textures.

If we do not skip these 0 names, they end up as invalid free texture
names in our name allocator.
2021-12-11 23:15:24 +01:00
Jelle Raaijmakers
4abd6aa198 LibGL: Remove unnecessary break; from SoftwareGLContext 2021-12-11 23:15:24 +01:00
Jelle Raaijmakers
5e370e6f96 LibGL: Implement GL_(UN)PACK_ALIGNMENT
These enums are used to indicate byte-alignment when reading from and
to textures. The `GL_UNPACK_ROW_LENGTH` value was reimplemented to
support overriding the source data row width.
2021-12-11 23:15:24 +01:00
Jelle Raaijmakers
bed0f3466a LibGL: Remove TextureUnit::unbind_texture() 2021-12-01 10:21:13 +01:00
Jelle Raaijmakers
5788a139d8 LibGL: Implement texture unit texturing states 2021-12-01 10:21:13 +01:00
Jelle Raaijmakers
bb58f6ccab LibGL: Implement glScissor() 2021-11-28 09:20:58 -08:00
Jelle Raaijmakers
a36ee213b9 LibGL: Implement glIsEnabled() 2021-10-17 21:01:52 -07:00
Jelle Raaijmakers
b2627c8b74 LibGL: Implement disabling GL_FOG 2021-10-17 21:01:52 -07:00
Stephan Unverwerth
e7d3483618 LibGL: Implement glTexSubImage2D 2021-09-02 21:00:24 +04:30
Stephan Unverwerth
e34fc4e336 LibGL: Support additional enums in glGetIntegerv
GL_MAX_TETXURE_UNITS: Returns the available units for multitexturing
GL_MAX_TETXURE_SIZE: Returns the maximum width/height for textures
2021-09-02 21:00:24 +04:30
Stephan Unverwerth
7c60f4bbab LibGL: Fix glTexImage2D texture dimension validation
This now verifies that width and height are a power of 2. The previous
check was nonsensical, probably because it was written against a spec
with improper text formatting, turning 2^x into 2*x :^)
2021-09-02 21:00:24 +04:30
Stephan Unverwerth
05a7a4640d LibGL: Allow numerical internal formats in glTexImage2D
Prior to version 1.1 OpenGL only allowed the numbers 1,2,3 and 4 to be
used as internal texture formats. Symbolic constants were introduced
first with the EXT_texture extension and then later adopted into the
core profile.
2021-09-02 21:00:24 +04:30
Stephan Unverwerth
15299b763c LibGL: Implement glPolygonOffset 2021-09-02 21:00:24 +04:30
Stephan Unverwerth
7cbaaf8366 LibGL: Implement glDrawBuffer 2021-09-02 21:00:24 +04:30
Stephan Unverwerth
b54573739c LibGL: Implement glTexEnvf
This controls how fetched texels are combined with the color that was
produced by a preceding texture unit or with the vertex color if it is
the first texture unit.

Currently only a small subset of possible combine modes is implemented
as required by glquake.
2021-08-26 19:54:31 +02:00
Stephan Unverwerth
19a08ff187 LibGL: Implement glPixelStorei
This sets the length of a row for the image to be transferred. This
value is measured in pixels. When a rectangle with a width less than
this value is transferred the remaining pixels of this row are skipped.
2021-08-26 19:53:57 +02:00
Jesse Buhagiar
924d890bfe LibGL: Implement fog effect in Software Rasterizer
We support three of the possible fog modes, EXP, EXP2 and LINEAR.
2021-08-25 23:50:54 +04:30
Jesse Buhagiar
d73cc3d0eb LibGL: Implement glFogi 2021-08-25 23:50:54 +04:30
Jesse Buhagiar
f55d2a22af LibGL: Implement glFogf 2021-08-25 23:50:54 +04:30
Jesse Buhagiar
7f1cd54b80 LibGL: Implement glFogfv
This currently just sets the fog colour in the rasterizer.
2021-08-25 23:50:54 +04:30
Jesse Buhagiar
89eddb5bff LibGL: Implement glPolygonMode
Currently just sets the renderer option for what polygon mode we
want the rasterizer to draw in. GLQuake only uses `GL_FRONT_AND_BACK`
with `GL_FILL` )which implies both back and front facing triangles
are to be filled completely by the rasterizer), so keeping this as
a small stub is perfectly fine for now.
2021-08-20 20:04:06 +04:30
Jesse Buhagiar
68d895eb7c LibGL: Don't crash on invalid pname value in glGetFloatv
This brings `glGetFloatv` more inline with the other `glGet`
functions. We should prevent crashing in the driver as much as
possible and instead let the application deal with the generated
GL error.
2021-08-19 17:08:04 +02:00
Stephan Unverwerth
addbcd42d7 LibGL: Fix triangle winding calculation
Since we operate in screen space where y points down we need to reverse
what is considered clock wise and what is considered counter clockwise.

The rasterizer always expects triangles with a consistent winding order
thus swap 2 vertices if necessary to reverse the winding before passing
the triangle on to the rasterization stage.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
220ac5eb02 LibGL: Fix clipping and interpolate vertex attributes
The previous clipping implementation was problematic especially when
clipping against the near plane. Triangles are now correctly clipped
using homogenous coordinates against all frustum planes.

Texture coordinates and vertex colors are now correctly interpolated.
The earier implementation was just a placeholder.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
894d81c1b8 LibGL: Complete glGetString implementation
GL_VERSION: The spec mandates the following format: x.y or x.y.z
optionally followed by text separated by space.

GL_EXTENSIONS: Return empty string. We do not support any extensions.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
5b9c87a8b5 LibGL: Implement glDepthFunc 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
a97dbd2317 LibGL: Implement glDepthRange 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
e9514cf6c0 LibGL: Fix glVertexPointer argument validation 2021-08-18 20:30:58 +02:00
Stephan Unverwerth
5e27da20f4 LibGL: Fix glTexCoord behaviour
glTexCoord should behave like glColor. It only updates a gl context
variable that contains the current texture coordinates. The vertex is
only actually created once glVertex is called.
2021-08-18 20:30:58 +02:00
Stephan Unverwerth
b6373c2aba LibGL+3DFileViewer: Make glRotatef accept degrees, not radians
This is in accordance with the GL spec. Also adjust rotation values in
3DFileViewer to take the new units into account.
2021-08-18 20:30:58 +02:00
Jesse Buhagiar
8ad42e6771 LibGL: Implement glGetIntegerv 2021-08-18 00:35:26 +02:00
Jesse Buhagiar
0b67369830 LibGL: Implenent glGetBooleanv 2021-08-18 00:35:26 +02:00
Jesse Buhagiar
8157e7740b LibGL: Implement glColorMask 2021-08-15 19:04:10 +01:00
Stephan Unverwerth
949d27f21b LibGL: Implement glDrawElements 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
e64d0d43d2 LibGL: Implement glDrawArrays 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
f776402632 LibGL: Implement glTexCoordPointer 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
f52f40925c LibGL: Implement glColorPointer 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
07b9cba6e6 LibGL: Implement glVertexPointer 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
886f154c2a LibGL: Implement glEnableClientState and glDisableClientState 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
5f863016ca LibGL: Implement glDepthMask 2021-08-14 12:49:29 +02:00
Stephan Unverwerth
b9523e15df LibGL: Implement glTexParameter{i,f}
This currently only implements a subset of this function.
Namely setting wrap, mag and min modes for the GL_TETXURE_2D target.
2021-08-12 18:58:41 +02:00
Hendiadyoin1
ed46d52252 Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.

Also clean up some stale math includes and improper floatingpoint usage.
2021-07-19 16:34:21 +04:30
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
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