diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-10-19 21:37:16 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-19 22:22:58 +0200 |
commit | 91cec51b991406893e16412b14f05aba2eb4c193 (patch) | |
tree | 984786f65ca7092e9d041ce5d6aec5fa5ab440b6 | |
parent | 00b21fba57ca9fb850f1d37b6b27e744c3670907 (diff) | |
download | serenity-91cec51b991406893e16412b14f05aba2eb4c193.zip |
LibGL: Correctly normalize different vertex attribute type pointers
According to the OpenGL 2.0 spec ยง 2.8, the data for each attribute type
pointer is normalized according to the type. The only exception to this
is `glVertexAttribPointer` which accepts a `normalized` parameter, but
we have not yet implemented that API.
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/Texture.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/Vertex.cpp | 17 |
3 files changed, 15 insertions, 15 deletions
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 876e9e5ae4..bcac8232ff 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -81,7 +81,7 @@ struct ContextParameter { struct VertexAttribPointer { GLint size { 4 }; GLenum type { GL_FLOAT }; - bool normalize { true }; + bool normalize; GLsizei stride { 0 }; void const* pointer { 0 }; }; diff --git a/Userland/Libraries/LibGL/Texture.cpp b/Userland/Libraries/LibGL/Texture.cpp index 4a20ca6a7e..300183d314 100644 --- a/Userland/Libraries/LibGL/Texture.cpp +++ b/Userland/Libraries/LibGL/Texture.cpp @@ -305,17 +305,6 @@ void GLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) m_current_vertex_tex_coord[0] = { s, t, r, q }; } -void GLContext::gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer) -{ - RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); - RETURN_WITH_ERROR_IF(!(size == 1 || size == 2 || size == 3 || size == 4), GL_INVALID_VALUE); - RETURN_WITH_ERROR_IF(!(type == GL_SHORT || type == GL_INT || type == GL_FLOAT || type == GL_DOUBLE), GL_INVALID_ENUM); - RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE); - - auto& tex_coord_pointer = m_client_tex_coord_pointer[m_client_active_texture]; - tex_coord_pointer = { .size = size, .type = type, .stride = stride, .pointer = pointer }; -} - void GLContext::gl_tex_env(GLenum target, GLenum pname, GLfloat param) { APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_tex_env, target, pname, param); diff --git a/Userland/Libraries/LibGL/Vertex.cpp b/Userland/Libraries/LibGL/Vertex.cpp index 62397c0f24..f7e5a91c3d 100644 --- a/Userland/Libraries/LibGL/Vertex.cpp +++ b/Userland/Libraries/LibGL/Vertex.cpp @@ -117,7 +117,7 @@ void GLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, void c GL_INVALID_ENUM); RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE); - m_client_color_pointer = { .size = size, .type = type, .stride = stride, .pointer = pointer }; + m_client_color_pointer = { .size = size, .type = type, .normalize = true, .stride = stride, .pointer = pointer }; } void GLContext::gl_draw_arrays(GLenum mode, GLint first, GLsizei count) @@ -253,7 +253,18 @@ void GLContext::gl_normal_pointer(GLenum type, GLsizei stride, void const* point GL_INVALID_ENUM); RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE); - m_client_normal_pointer = { .size = 3, .type = type, .stride = stride, .pointer = pointer }; + m_client_normal_pointer = { .size = 3, .type = type, .normalize = true, .stride = stride, .pointer = pointer }; +} + +void GLContext::gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer) +{ + RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); + RETURN_WITH_ERROR_IF(!(size == 1 || size == 2 || size == 3 || size == 4), GL_INVALID_VALUE); + RETURN_WITH_ERROR_IF(!(type == GL_SHORT || type == GL_INT || type == GL_FLOAT || type == GL_DOUBLE), GL_INVALID_ENUM); + RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE); + + auto& tex_coord_pointer = m_client_tex_coord_pointer[m_client_active_texture]; + tex_coord_pointer = { .size = size, .type = type, .normalize = false, .stride = stride, .pointer = pointer }; } void GLContext::gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w) @@ -278,7 +289,7 @@ void GLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, void RETURN_WITH_ERROR_IF(!(type == GL_SHORT || type == GL_INT || type == GL_FLOAT || type == GL_DOUBLE), GL_INVALID_ENUM); RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE); - m_client_vertex_pointer = { .size = size, .type = type, .stride = stride, .pointer = pointer }; + m_client_vertex_pointer = { .size = size, .type = type, .normalize = false, .stride = stride, .pointer = pointer }; } } |