summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
AgeCommit message (Collapse)Author
2022-03-10Libraries: Use default constructors/destructors in LibGLLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-10LibGL: Keep track of active matrix and stackJelle Raaijmakers
This simplifies a lot of code in `GLContext` and prevents potential errors when testing against the current matrix mode.
2022-03-10LibGL: Only normalize in `glRotate*` if possibleJelle Raaijmakers
Vectors of length 0 cannot be normalized, so prevent dividing by zero in the `glRotate*` API. This fixes the skybox rendering of Quake2.
2022-03-09LibGL: Merge GLContext and SoftwareGLContextStephan Unverwerth
This merges GLContext and SoftwareGLContext into a single GLContext class. Since the hardware abstraction is handled via the GPU device interface we do not need the virtual base of GLContext anymore. All context handling functionality from the old GLContext has been moved into the new version. All methods in GLContext are now non virtual and the class is marked as final.
2022-03-08LibGL: Better handling of texture targets and default texturesJelle Raaijmakers
We were lacking support for default textures (i.e. calling `glBindTexture` with a `texture` argument of `0`) which caused our Quake2 port to render red screens whenever a video was playing. Every texture unit is now initialized with a default 2D texture. Additionally, we had this concept of a "currently bound target" on our texture units which is not how OpenGL wants us to handle targets. Calling `glBindTexture` should set the texture for the provided target only, making it sort of an alias for future operations on the same target. Finally, `glDeleteTextures` should not remove the bound texture from the target in the texture unit, but it should reset it to the default texture.
2022-03-08LibGL: East-const `glTex*` methodsJelle Raaijmakers
2022-03-08LibGL: Remove duplicate `public:` from `Texture2D.h`Jelle Raaijmakers
2022-03-06LibGL: Implement `glNormalPointer`Jelle Raaijmakers
Used for `glDrawArrays` and `glDrawElements`, the normal pointer should point to sets of X, Y and Z values.
2022-03-06LibGL: Support local viewer light modelJelle Raaijmakers
We already had the implementation, but we were erroneously rejecting `GL_LIGHT_MODEL_LOCAL_VIEWER` as a parameter to `glLightModel`.
2022-03-06LibGL: Clean up reading floats and doubles from pointersJelle Raaijmakers
No functional changes, just removal of superfluous braces.
2022-03-06LibGL: Set sampler config to dirty if modifying tex envJelle Raaijmakers
2022-03-05LibGL: Implement lighting parameter error checkingJelle Raaijmakers
2022-03-04LibGfx: Rename Color::from_rgba() => Color::from_argb()Andreas Kling
This matches the rename of RGBA32 to ARGB32. It also makes more sense when you see it used with 32-bit hexadecimal literals: Before: Color::from_rgba(0xaarrggbb) After: Color::from_argb(0xaarrggbb)
2022-03-04LibGfx: Rename RGBA32 => ARGB32Andreas Kling
The ARGB32 typedef is used for 32-bit #AARRGGBB quadruplets. As such, the name RGBA32 was misleading, so let's call it ARGB32 instead. Since endianness is a thing, let's not encode any assumptions about byte order in the name of this type. ARGB32 is basically a "machine word" of color.
2022-03-03LibGL: Fix interpretation of mipmap filtering modesStephan Unverwerth
GL_LINEAR_MIPMAP_NEAREST means choose nearest mipmap level, interpolate texels linearly. GL_NEAREST_MIPMAP_LINEAR means choose the two closest mipmap levels, sample the texels unfiltered and linearly interpolate based on the fractional value of the mipmap level. Previously we had this backwards.
2022-02-22LibGL: Set correct matrices in `glFrustum` and `glOrtho`Jelle Raaijmakers
We were erroneously setting the projection matrix when `GL_MODELVIEW` was supplied.
2022-02-22LibGL: Improve `glFrustum` precision and error handlingJelle Raaijmakers
Do not convert to float too early. Additionally, handle some error cases for the input parameters.
2022-02-22LibGL: Clamp color in `glClearColor` to 0..1Jelle Raaijmakers
2022-02-22LibGL: Implement `glClearDepthf` and store as floatJelle Raaijmakers
Our API still specifies it as a double, but internally we communicate a float to the rasterizer. Additionally, clamp the value to 0..1 as described in the spec.
2022-02-22LibGL: Ignore stack on projection and model view matrix retrievalJelle Raaijmakers
Our implementation keeps the top-most item on the matrix stacks in a member variable, so we can always use that instead of considering the actual stack. Additionally, the current matrix mode should not influence retrieving the projection or model view matrix.
2022-02-22LibGL: East-const two methods in `Texture2D`Jelle Raaijmakers
No functional changes.
2022-02-22LibGL+LibSoftGPU: Use more expressive `is_power_of_two`Jelle Raaijmakers
2022-02-22LibGL: Use `clamp<float>` for depth rangeJelle Raaijmakers
We get `double`s as input, so convert them to `float` first.
2022-02-22LibSoftGPU: Generalize pixel buffers and standardize on BGRA8888Jelle Raaijmakers
Between the OpenGL client and server, a lot of data type and color conversion needs to happen. We are performing these conversions both in `LibSoftGPU` and `LibGL`, which is not ideal. Additionally, some concepts like the color, depth and stencil buffers should share their logic but have separate implementations. This is the first step towards generalizing our `LibSoftGPU` frame buffer: a generalized `Typed3DBuffer` is introduced for arbitrary 3D value storage and retrieval, and `Typed2DBuffer` wraps around it to provide in an easy-to-use 2D pixel buffer. The color, depth and stencil buffers are replaced by `Typed2DBuffer` and are now managed by the new `FrameBuffer` class. The `Image` class now uses multiple `Typed3DBuffer`s for layers and mipmap levels. Additionally, the textures are now always stored as BGRA8888, only converting between formats when reading or writing pixels. Ideally this refactor should have no functional changes, but some graphical glitches in Grim Fandango seem to be fixed and most OpenGL ports get an FPS boost on my machine. :^)
2022-02-22LibGL: Remove superfluous `AK::dbgln` aliasJelle Raaijmakers
2022-02-22LibGL: Allow all primitives in `glBegin()`Jelle Raaijmakers
We check for primitive support in `glEnd()`, so we do not need to preemptively reject the mode in `glBegin()`. This allows `glBegin()` to be invoked with `GL_POINTS`, for example.
2022-01-27LibGL: Set rasterizer material state without copyingLenny Maiorani
Each of the material faces is copied member by member then the copied material state is passed by `const&` to another function, then destroyed. This is changed to simply passing the material state directly without copying.
2022-01-27LibGL: Set rasterizer light state without copyingLenny Maiorani
There is a loop over the lights in which each light state is copied member by member then the copied light state is passed by `const&` to another function, then destroyed. This is changed to simply passing the light state directly without copying.
2022-01-26LibGL: Implement `glMateriali{v}`Jesse Buhagiar
2022-01-26LibGL: Implement `glLighti{v}`Jesse Buhagiar
2022-01-26LibGL: Correctly set scene ambient in `glLightModelfv`Jesse Buhagiar
This was only passing in the `R` value to the scene's ambient color, which is incorrect.
2022-01-26LibGL: Implement `glLightModeliv`Jesse Buhagiar
2022-01-26LibGL: Implement `glGetMaterial`Jesse Buhagiar
2022-01-26LibGL: Implement `glGetLight`Jesse Buhagiar
2022-01-21LibGL: Fix incorrect GL_DECAL constant valueLuke Wilde
The constant value for GL_DECAL is 0x2101 instead of 0x2102. This was tripping up Half-Life when making the water texture transparent when under water. The Half-Life port uses its own OpenGL header, meaning this error wasn't hidden by us.
2022-01-20LibGL+LibSoftGPU: Clean up some `for` loopsJelle Raaijmakers
2022-01-20LibGL: Rename `GLMat.cpp` to `GLMatrix.cpp`Jelle Raaijmakers
2022-01-20LibGL: Transpose matrix in `glGetDoublev` and `glGetFloatv`Jelle Raaijmakers
We were returning row-major matrices when OpenGL clients are expecting column-major instead.
2022-01-20LibGL: Use 4 hex characters for error code constants in `gl.h`Jelle Raaijmakers
2022-01-20LibGL: Report GL errors to debug consoleJelle Raaijmakers
2022-01-20LibGL: Stub `GL_BACK` implementation for `glPolygonMode`Jelle Raaijmakers
This prevents overwriting the front face mode when providing `GL_BACK` as a parameter.
2022-01-20LibGL+LibSoftGPU: Implement `GL_POLYGON_OFFSET_FILL` capabilityJelle Raaijmakers
2022-01-20LibGL: Implement `glColor4b`Jelle Raaijmakers
2022-01-20LibGL: Correct values for `GL_BGR` and `GL_BGRA`Jelle Raaijmakers
2022-01-19LibGL+LibSoftGPU: Support generation of multiple texture coordinatesStephan Unverwerth
2022-01-19LibGL: Also track active texture unit indexStephan Unverwerth
In addition to tracking a pointer to the active texture unit we also track its index in the array.
2022-01-19LibGL: Track multiple current texture coordinates in GLContextStephan Unverwerth
Previously we only had a single current texture coordinate, set by the glTexCoord family of functions. Since we now can have multiple texture coordinates we track a vector of current texture coordinates and set the requested one in glMultiTexCoord(). glTexCoord() Always sets the first texture coordinate.
2022-01-19LibGL: Handle multiple texture coordinates in client stateStephan Unverwerth
This now tracks one vertex attribute pointer per texture unit and calls glMultiTexCoord() to set the texture coordinates for the correct texture unit.
2022-01-19LibGL+LibSoftGPU: Add multiple texture coordinates to vertex structStephan Unverwerth
We now have one set of texture coordinates per texture unit. Texture coordinate generation and texture coordinate assignment is currently only stubbed. This will be rectified in another commit.
2022-01-19LibGL: Add stubs for multitexturing and announce GL_ARB_multitextureStephan Unverwerth
This makes glquake recognize multitexture support and choose the multitexture rendering path.