mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Feat] (MG_Impl/GLImpl, MG_State): implement glHint, glPointParameter*, glPixelStoref, glGetDoublev
Six pure-state entry points that were stubs or empty // TODO bodies, all backed by new
context state and read back through glGet*.
* glHint: Hint_State was an empty TODO. Store the 4 GL 3.3 core hint targets (LINE_SMOOTH,
POLYGON_SMOOTH, TEXTURE_COMPRESSION, FRAGMENT_SHADER_DERIVATIVE), default GL_DONT_CARE.
Validate target and mode (FASTEST/NICEST/DONT_CARE) -> GL_INVALID_ENUM otherwise. The
compatibility-only targets (GL_PERSPECTIVE_CORRECTION_HINT, GL_POINT_SMOOTH_HINT, GL_FOG_HINT,
GL_GENERATE_MIPMAP_HINT) are rejected. The glGetIntegerv hint cases, previously hardcoded to
GL_DONT_CARE, now read the stored value; glGetBooleanv on a hint is always GL_TRUE.
* glPointParameter{f,i,fv,iv}: the scalar _State bodies were empty TODOs and the *v forms were
stubs. Only the 2 core pnames are accepted: GL_POINT_FADE_THRESHOLD_SIZE (float, default 1.0,
GL_INVALID_VALUE if negative) and GL_POINT_SPRITE_COORD_ORIGIN (GL_LOWER_LEFT/GL_UPPER_LEFT,
default GL_UPPER_LEFT, GL_INVALID_ENUM on a bad value -- note the different error code from the
fade case). The compat pnames (POINT_SIZE_MIN/MAX, POINT_DISTANCE_ATTENUATION) are rejected. All
four forms funnel through one (pname, float) handler. glGetIntegerv(GL_POINT_FADE_THRESHOLD_SIZE)
was hardcoded to 1; it now rounds the stored float, glGetFloatv reads the float directly (keeping
the fractional part), and GL_POINT_SPRITE_COORD_ORIGIN gained a getter case (it had none).
* glPixelStoref: funnels into the existing glPixelStorei state, but converts per type -- boolean
pnames (PACK/UNPACK_SWAP_BYTES/LSB_FIRST) by a zero-test so 0.4 -> TRUE, integer pnames by
round-to-nearest. A blanket round would wrongly turn a fractional true flag into false.
* glGetDoublev: funnels through glGetFloatv and widens, writing exactly the pname's component count
(1/2/4) so a single-component query cannot overrun the caller's buffer. MobileGL stores no native
double state (depth range/clear are float), so widening from float matches its real resolution.
State added to RenderStateParameters + RenderState Set/Get + GLContext wrappers, following the
existing LineWidth/DepthRange pattern. Covered by 4 SanityTest cases (set-then-get round trips, the
core-vs-compat enum rejections, the two different error codes, and the glPixelStoref boolean
zero-test, which was verified to fail against a blanket-round implementation).
This commit is contained in:
@@ -328,6 +328,30 @@ namespace MobileGL::MG_State {
|
||||
return m_renderState.GetLineWidth();
|
||||
}
|
||||
|
||||
void GLContext::SetHint(GLenum target, GLenum mode) {
|
||||
m_renderState.SetHint(target, mode);
|
||||
}
|
||||
|
||||
GLenum GLContext::GetHint(GLenum target) const {
|
||||
return m_renderState.GetHint(target);
|
||||
}
|
||||
|
||||
void GLContext::SetPointFadeThresholdSize(Float size) {
|
||||
m_renderState.SetPointFadeThresholdSize(size);
|
||||
}
|
||||
|
||||
Float GLContext::GetPointFadeThresholdSize() const {
|
||||
return m_renderState.GetPointFadeThresholdSize();
|
||||
}
|
||||
|
||||
void GLContext::SetPointSpriteCoordOrigin(GLenum origin) {
|
||||
m_renderState.SetPointSpriteCoordOrigin(origin);
|
||||
}
|
||||
|
||||
GLenum GLContext::GetPointSpriteCoordOrigin() const {
|
||||
return m_renderState.GetPointSpriteCoordOrigin();
|
||||
}
|
||||
|
||||
void GLContext::SetPointSize(Float size) {
|
||||
m_renderState.SetPointSize(size);
|
||||
}
|
||||
|
||||
@@ -125,6 +125,12 @@ namespace MobileGL {
|
||||
void SetPolygonOffset(Float factor, Float units);
|
||||
Float GetPolygonOffsetFactor() const;
|
||||
Float GetPolygonOffsetUnits() const;
|
||||
void SetHint(GLenum target, GLenum mode);
|
||||
GLenum GetHint(GLenum target) const;
|
||||
void SetPointFadeThresholdSize(Float size);
|
||||
Float GetPointFadeThresholdSize() const;
|
||||
void SetPointSpriteCoordOrigin(GLenum origin);
|
||||
GLenum GetPointSpriteCoordOrigin() const;
|
||||
void SetCapability(CapabilityInput cap, Bool enabled);
|
||||
Bool IsCapabilityEnabled(CapabilityInput cap) const;
|
||||
void SetCapabilityIndexed(CapabilityInput cap, Uint index, Bool enabled);
|
||||
|
||||
@@ -59,6 +59,50 @@ namespace MobileGL {
|
||||
return m_parameters.LineWidth;
|
||||
}
|
||||
|
||||
void RenderState::SetHint(GLenum target, GLenum mode) {
|
||||
GLenum* slot = nullptr;
|
||||
switch (target) {
|
||||
case GL_LINE_SMOOTH_HINT: slot = &m_parameters.LineSmoothHint; break;
|
||||
case GL_POLYGON_SMOOTH_HINT: slot = &m_parameters.PolygonSmoothHint; break;
|
||||
case GL_TEXTURE_COMPRESSION_HINT: slot = &m_parameters.TextureCompressionHint; break;
|
||||
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: slot = &m_parameters.FragmentShaderDerivativeHint; break;
|
||||
default: return;
|
||||
}
|
||||
if (*slot == mode) return;
|
||||
*slot = mode;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
GLenum RenderState::GetHint(GLenum target) const {
|
||||
switch (target) {
|
||||
case GL_LINE_SMOOTH_HINT: return m_parameters.LineSmoothHint;
|
||||
case GL_POLYGON_SMOOTH_HINT: return m_parameters.PolygonSmoothHint;
|
||||
case GL_TEXTURE_COMPRESSION_HINT: return m_parameters.TextureCompressionHint;
|
||||
case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: return m_parameters.FragmentShaderDerivativeHint;
|
||||
default: return GL_DONT_CARE;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderState::SetPointFadeThresholdSize(Float size) {
|
||||
if (m_parameters.PointFadeThresholdSize == size) return;
|
||||
m_parameters.PointFadeThresholdSize = size;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
Float RenderState::GetPointFadeThresholdSize() const {
|
||||
return m_parameters.PointFadeThresholdSize;
|
||||
}
|
||||
|
||||
void RenderState::SetPointSpriteCoordOrigin(GLenum origin) {
|
||||
if (m_parameters.PointSpriteCoordOrigin == origin) return;
|
||||
m_parameters.PointSpriteCoordOrigin = origin;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
GLenum RenderState::GetPointSpriteCoordOrigin() const {
|
||||
return m_parameters.PointSpriteCoordOrigin;
|
||||
}
|
||||
|
||||
void RenderState::SetPointSize(Float size) {
|
||||
if (m_parameters.PointSize == size) return;
|
||||
|
||||
|
||||
@@ -250,6 +250,16 @@ namespace MobileGL {
|
||||
FrontFaceMode FrontFaceModeSetting = FrontFaceMode::CounterClockwise;
|
||||
ProvokingVertexMode ProvokingVertexModeSetting = ProvokingVertexMode::LastVertex;
|
||||
|
||||
// Hints (glHint). All GL 3.3 core hint targets default to GL_DONT_CARE.
|
||||
GLenum LineSmoothHint = GL_DONT_CARE;
|
||||
GLenum PolygonSmoothHint = GL_DONT_CARE;
|
||||
GLenum TextureCompressionHint = GL_DONT_CARE;
|
||||
GLenum FragmentShaderDerivativeHint = GL_DONT_CARE;
|
||||
|
||||
// Point parameters (glPointParameter). Only the two GL 3.3 core pnames.
|
||||
Float PointFadeThresholdSize = 1.0f;
|
||||
GLenum PointSpriteCoordOrigin = GL_UPPER_LEFT;
|
||||
|
||||
// Scissor
|
||||
Bool ColorLogicOpEnabled = false;
|
||||
Bool DebugOutputEnabled = false;
|
||||
@@ -293,6 +303,13 @@ namespace MobileGL {
|
||||
void SetPolygonOffset(Float factor, Float units);
|
||||
Float GetPolygonOffsetFactor() const;
|
||||
Float GetPolygonOffsetUnits() const;
|
||||
// Hints. target must be one of the 4 GL 3.3 core hint targets (validated by the caller).
|
||||
void SetHint(GLenum target, GLenum mode);
|
||||
GLenum GetHint(GLenum target) const;
|
||||
void SetPointFadeThresholdSize(Float size);
|
||||
Float GetPointFadeThresholdSize() const;
|
||||
void SetPointSpriteCoordOrigin(GLenum origin);
|
||||
GLenum GetPointSpriteCoordOrigin() const;
|
||||
|
||||
// Capabilities
|
||||
void SetCapability(CapabilityInput cap, Bool enabled);
|
||||
|
||||
Reference in New Issue
Block a user