summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL/SoftwareGLContext.h
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-12-30 00:56:41 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-30 14:24:29 +0100
commitc19632128c84e1190b95d1b18baf56ffe306e192 (patch)
treee48f9903422b8ff627da6739cd2911ae0b101fdd /Userland/Libraries/LibGL/SoftwareGLContext.h
parent69da279073db68b53956e2e2f1c96f86e48ce0c9 (diff)
downloadserenity-c19632128c84e1190b95d1b18baf56ffe306e192.zip
LibGL+LibSoftGPU: Implement texture coordinate generation
Texture coordinate generation is the concept of automatically generating vertex texture coordinates instead of using the provided coordinates (i.e. `glTexCoord`). This commit implements support for: * The `GL_TEXTURE_GEN_Q/R/S/T` capabilities * The `GL_OBJECT_LINEAR`, `GL_EYE_LINEAR`, `GL_SPHERE_MAP`, `GL_REFLECTION_MAP` and `GL_NORMAL_MAP` modes * Object and eye plane coefficients (write-only at the moment) This changeset allows Tux Racer to render its terrain :^)
Diffstat (limited to 'Userland/Libraries/LibGL/SoftwareGLContext.h')
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 1099525e50..e685710004 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -140,6 +140,7 @@ public:
private:
void sync_device_config();
void sync_device_sampler_config();
+ void sync_device_texcoord_config();
private:
template<typename T>
@@ -243,6 +244,42 @@ private:
Vector<TextureUnit, 32> m_texture_units;
TextureUnit* m_active_texture_unit;
+ // Texture coordinate generation state
+ struct TextureCoordinateGeneration {
+ bool enabled { false };
+ GLenum generation_mode { GL_EYE_LINEAR };
+ FloatVector4 object_plane_coefficients;
+ FloatVector4 eye_plane_coefficients;
+ };
+ Array<TextureCoordinateGeneration, 4> m_texture_coordinate_generation {
+ // S
+ TextureCoordinateGeneration {
+ .object_plane_coefficients = { 1.0f, 0.0f, 0.0f, 0.0f },
+ .eye_plane_coefficients = { 1.0f, 0.0f, 0.0f, 0.0f },
+ },
+ // T
+ TextureCoordinateGeneration {
+ .object_plane_coefficients = { 0.0f, 1.0f, 0.0f, 0.0f },
+ .eye_plane_coefficients = { 0.0f, 1.0f, 0.0f, 0.0f },
+ },
+ // R
+ TextureCoordinateGeneration {
+ .object_plane_coefficients = { 0.0f, 0.0f, 0.0f, 0.0f },
+ .eye_plane_coefficients = { 0.0f, 0.0f, 0.0f, 0.0f },
+ },
+ // Q
+ TextureCoordinateGeneration {
+ .object_plane_coefficients = { 0.0f, 0.0f, 0.0f, 0.0f },
+ .eye_plane_coefficients = { 0.0f, 0.0f, 0.0f, 0.0f },
+ },
+ };
+ bool m_texcoord_generation_dirty { true };
+
+ ALWAYS_INLINE TextureCoordinateGeneration& texture_coordinate_generation(GLenum capability)
+ {
+ return m_texture_coordinate_generation[capability - GL_TEXTURE_GEN_S];
+ }
+
SoftGPU::Device m_rasterizer;
SoftGPU::DeviceInfo const m_device_info;
bool m_sampler_config_is_dirty { true };