diff options
author | Stephan Unverwerth <s.unverwerth@gmx.de> | 2021-05-20 23:20:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-20 23:29:56 +0200 |
commit | eed0bcaf420c6250e767d6ef8da12736021e3f06 (patch) | |
tree | 780bb59b6727a203c31819439b5a9458bd9624fe /Userland/Libraries/LibGL | |
parent | 2a16c8bdb8b285209950a4e26b3eee1d95ec1a7a (diff) | |
download | serenity-eed0bcaf420c6250e767d6ef8da12736021e3f06.zip |
LibGL: Implement glHint()
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r-- | Userland/Libraries/LibGL/GL/gl.h | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLUtils.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 30 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 4 |
5 files changed, 55 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index 899ba5335d..46408e70f6 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -92,6 +92,19 @@ extern "C" { #define GL_CW 0x0900 #define GL_CCW 0x0901 +// Hint enums +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF + // Listing enums #define GL_COMPILE 0x1300 #define GL_COMPILE_AND_EXECUTE 0x1301 @@ -190,6 +203,7 @@ GLAPI void glFinish(); GLAPI void glBlendFunc(GLenum sfactor, GLenum dfactor); GLAPI void glShadeModel(GLenum mode); GLAPI void glAlphaFunc(GLenum func, GLclampf ref); +GLAPI void glHint(GLenum target, GLenum mode); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 68cfe60f29..46b120610f 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -52,6 +52,7 @@ public: virtual void gl_blend_func(GLenum src_factor, GLenum dst_factor) = 0; virtual void gl_shade_model(GLenum mode) = 0; virtual void gl_alpha_func(GLenum func, GLclampf ref) = 0; + virtual void gl_hint(GLenum target, GLenum mode) = 0; virtual void present() = 0; }; diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp index d3f37c1ce7..d5f217862c 100644 --- a/Userland/Libraries/LibGL/GLUtils.cpp +++ b/Userland/Libraries/LibGL/GLUtils.cpp @@ -62,10 +62,15 @@ GLenum glGetError() void glFlush() { - return g_gl_context->gl_flush(); + g_gl_context->gl_flush(); } void glFinish() { - return g_gl_context->gl_finish(); + g_gl_context->gl_finish(); +} + +void glHint(GLenum target, GLenum mode) +{ + g_gl_context->gl_hint(target, mode); } diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 8e65c9f70e..7c84dea98a 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -979,6 +979,36 @@ void SoftwareGLContext::gl_alpha_func(GLenum func, GLclampf ref) m_rasterizer.set_options(options); } +void SoftwareGLContext::gl_hint(GLenum target, GLenum mode) +{ + APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_hint, target, mode); + + if (m_in_draw_state) { + m_error = GL_INVALID_OPERATION; + return; + } + + if (target != GL_PERSPECTIVE_CORRECTION_HINT + && target != GL_POINT_SMOOTH_HINT + && target != GL_LINE_SMOOTH_HINT + && target != GL_POLYGON_SMOOTH_HINT + && target != GL_FOG_HINT + && target != GL_GENERATE_MIPMAP_HINT + && target != GL_TEXTURE_COMPRESSION_HINT) { + m_error = GL_INVALID_ENUM; + return; + } + + if (mode != GL_DONT_CARE + && mode != GL_FASTEST + && mode != GL_NICEST) { + m_error = GL_INVALID_ENUM; + return; + } + + // According to the spec implementors are free to ignore glHint. So we do. +} + void SoftwareGLContext::present() { m_rasterizer.blit_to(*m_frontbuffer); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index dcfe95fcd3..8ea205be08 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -58,6 +58,7 @@ public: virtual void gl_blend_func(GLenum src_factor, GLenum dst_factor) override; virtual void gl_shade_model(GLenum mode) override; virtual void gl_alpha_func(GLenum func, GLclampf ref) override; + virtual void gl_hint(GLenum target, GLenum mode) override; virtual void present() override; @@ -170,7 +171,8 @@ private: decltype(&SoftwareGLContext::gl_call_list), decltype(&SoftwareGLContext::gl_blend_func), decltype(&SoftwareGLContext::gl_shade_model), - decltype(&SoftwareGLContext::gl_alpha_func)>; + decltype(&SoftwareGLContext::gl_alpha_func), + decltype(&SoftwareGLContext::gl_hint)>; using ExtraSavedArguments = Variant< FloatMatrix4x4>; |