mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
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.
This commit is contained in:
parent
00b21fba57
commit
91cec51b99
3 changed files with 15 additions and 15 deletions
|
@ -81,7 +81,7 @@ struct ContextParameter {
|
||||||
struct VertexAttribPointer {
|
struct VertexAttribPointer {
|
||||||
GLint size { 4 };
|
GLint size { 4 };
|
||||||
GLenum type { GL_FLOAT };
|
GLenum type { GL_FLOAT };
|
||||||
bool normalize { true };
|
bool normalize;
|
||||||
GLsizei stride { 0 };
|
GLsizei stride { 0 };
|
||||||
void const* pointer { 0 };
|
void const* pointer { 0 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 };
|
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)
|
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);
|
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_tex_env, target, pname, param);
|
||||||
|
|
|
@ -117,7 +117,7 @@ void GLContext::gl_color_pointer(GLint size, GLenum type, GLsizei stride, void c
|
||||||
GL_INVALID_ENUM);
|
GL_INVALID_ENUM);
|
||||||
RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE);
|
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)
|
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);
|
GL_INVALID_ENUM);
|
||||||
RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE);
|
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)
|
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(!(type == GL_SHORT || type == GL_INT || type == GL_FLOAT || type == GL_DOUBLE), GL_INVALID_ENUM);
|
||||||
RETURN_WITH_ERROR_IF(stride < 0, GL_INVALID_VALUE);
|
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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue