mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
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 :^)
This commit is contained in:
parent
69da279073
commit
c19632128c
5 changed files with 236 additions and 8 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue