mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibGL: Implement glVertexPointer
This commit is contained in:
parent
886f154c2a
commit
07b9cba6e6
6 changed files with 43 additions and 0 deletions
|
@ -13,6 +13,7 @@ set(SOURCES
|
|||
GLTexture.cpp
|
||||
GLUtils.cpp
|
||||
GLVert.cpp
|
||||
GLVertexArrays.cpp
|
||||
SoftwareGLContext.cpp
|
||||
SoftwareRasterizer.cpp
|
||||
DepthBuffer.cpp
|
||||
|
|
|
@ -141,6 +141,7 @@ extern "C" {
|
|||
#define GL_INT 0x1404
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_DOUBLE 0x140A
|
||||
|
||||
// Format enums
|
||||
#define GL_COLOR_INDEX 0x1900
|
||||
|
@ -356,6 +357,7 @@ GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
|
|||
GLAPI void glDepthMask(GLboolean flag);
|
||||
GLAPI void glEnableClientState(GLenum cap);
|
||||
GLAPI void glDisableClientState(GLenum cap);
|
||||
GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
virtual void gl_depth_mask(GLboolean flag) = 0;
|
||||
virtual void gl_enable_client_state(GLenum cap) = 0;
|
||||
virtual void gl_disable_client_state(GLenum cap) = 0;
|
||||
virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
|
15
Userland/Libraries/LibGL/GLVertexArrays.cpp
Normal file
15
Userland/Libraries/LibGL/GLVertexArrays.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
extern GL::GLContext* g_gl_context;
|
||||
|
||||
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
|
||||
{
|
||||
g_gl_context->gl_vertex_pointer(size, type, stride, pointer);
|
||||
}
|
|
@ -1447,6 +1447,20 @@ void SoftwareGLContext::gl_disable_client_state(GLenum cap)
|
|||
}
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
|
||||
{
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
RETURN_WITH_ERROR_IF(!(size == 1 || size == 2 || 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);
|
||||
|
||||
m_client_vertex_pointer.size = size;
|
||||
m_client_vertex_pointer.type = type;
|
||||
m_client_vertex_pointer.stride = stride;
|
||||
m_client_vertex_pointer.pointer = pointer;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
|
|
@ -76,6 +76,7 @@ public:
|
|||
virtual void gl_depth_mask(GLboolean flag) override;
|
||||
virtual void gl_enable_client_state(GLenum cap) override;
|
||||
virtual void gl_disable_client_state(GLenum cap) override;
|
||||
virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
|
||||
|
||||
virtual void present() override;
|
||||
|
||||
|
@ -223,6 +224,15 @@ private:
|
|||
GLenum mode { GL_COMPILE };
|
||||
};
|
||||
Optional<CurrentListing> m_current_listing_index;
|
||||
|
||||
struct VertexAttribPointer {
|
||||
GLint size { 4 };
|
||||
GLenum type { GL_FLOAT };
|
||||
GLsizei stride { 0 };
|
||||
const void* pointer { 0 };
|
||||
};
|
||||
|
||||
VertexAttribPointer m_client_vertex_pointer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue