mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
LibGL: Centralize all context parameters
The `glGet*` family of functions requires that all parameters of different types are transparently converted into each other. For example, you can request a boolean parameter as a float or a list of double values as an integer. It might be considered bad practice to request parameters through the wrongly-typed function, but to be spec- compliant we need to implement this. Introduce a new `::get_context_parameter()` to obtain a parameter value, which is then converted to the right type by the respective `::gl_get_*()` functions.
This commit is contained in:
parent
2af9b625e8
commit
b1ac181537
3 changed files with 153 additions and 82 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "Tex/Texture.h"
|
||||
#include "Tex/TextureUnit.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Tuple.h>
|
||||
#include <AK/Variant.h>
|
||||
|
@ -25,6 +26,18 @@
|
|||
|
||||
namespace GL {
|
||||
|
||||
struct ContextParameter {
|
||||
GLenum type;
|
||||
u8 count { 1 };
|
||||
union {
|
||||
bool boolean_value;
|
||||
GLint integer_value;
|
||||
GLint integer_list[4];
|
||||
GLdouble double_value;
|
||||
GLdouble double_list[4];
|
||||
} value;
|
||||
};
|
||||
|
||||
class SoftwareGLContext : public GLContext {
|
||||
public:
|
||||
SoftwareGLContext(Gfx::Bitmap&);
|
||||
|
@ -135,6 +148,8 @@ private:
|
|||
m_current_listing_index->listing.entries.empend(member, Listing::ArgumentsFor<member> { forward<Args>(args)... });
|
||||
}
|
||||
|
||||
Optional<ContextParameter> get_context_parameter(GLenum pname);
|
||||
|
||||
template<typename T>
|
||||
void get_floating_point(GLenum pname, T* params);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue