forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibGL: Implement
glLightf{v}
and fix gl.h
prototype
This implements the `glLightf{v}` family of functions used to set lighting parameters per light in the GL. It also fixes an incorrect prototype for the user exposed version of `glLightf{v}` in which `params` was not marked as `const`.
- Loading branch information
Showing
8 changed files
with
185 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* | ||
* Copyright (c) 2021, Stephan Unverwerth <[email protected]> | ||
* Copyright (c) 2021, Jelle Raaijmakers <[email protected]> | ||
* Copyright (c) 2022, Jesse Buhagiar <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -19,14 +20,12 @@ void glColorMaterial(GLenum face, GLenum mode) | |
|
||
void glLightf(GLenum light, GLenum pname, GLfloat param) | ||
{ | ||
// FIXME: implement | ||
dbgln_if(GL_DEBUG, "glLightf({}, {}, {}): unimplemented", light, pname, param); | ||
g_gl_context->gl_lightf(light, pname, param); | ||
} | ||
|
||
void glLightfv(GLenum light, GLenum pname, GLfloat* param) | ||
void glLightfv(GLenum light, GLenum pname, GLfloat const* param) | ||
{ | ||
// FIXME: implement | ||
dbgln_if(GL_DEBUG, "glLightfv({}, {}, {}): unimplemented", light, pname, param); | ||
g_gl_context->gl_lightfv(light, pname, param); | ||
} | ||
|
||
void glLightModelf(GLenum pname, GLfloat param) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2022, Jesse Buhagiar <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <LibGfx/Vector3.h> | ||
#include <LibGfx/Vector4.h> | ||
|
||
namespace SoftGPU { | ||
|
||
struct Light { | ||
bool is_enabled { false }; | ||
|
||
// According to the OpenGL 1.5 specification, page 56, all of the parameters | ||
// for the following data members (positions, colors, and reals) are all | ||
// floating point. | ||
Vector4<float> ambient_intensity { 0.0f, 0.0f, 0.0f, 1.0f }; | ||
Vector4<float> diffuse_intensity { 0.0f, 0.0f, 0.0f, 1.0f }; | ||
Vector4<float> specular_intensity { 0.0f, 0.0f, 0.0f, 1.0f }; | ||
Vector4<float> position { 0.0f, 0.0f, 1.0f, 0.0f }; | ||
Vector3<float> spotlight_direction { 0.0f, 0.0f, -1.0f }; | ||
|
||
float spotlight_exponent { 0.0f }; | ||
float spotlight_cutoff_angle { 180.0f }; | ||
float constant_attenuation { 1.0f }; // This is referred to `k0i` in the OpenGL spec | ||
float linear_attenuation { 0.0f }; // This is referred to `k1i` in the OpenGL spec | ||
float quadratic_attenuation { 0.0f }; // This is referred to `k2i` in the OpenGL spec | ||
|
||
float spotlight_cutoff_angle_rads { AK::Pi<float> / 180.0f }; | ||
}; | ||
|
||
} |