LibGL: Implement glActiveTexture
This commit is contained in:
parent
52e5d3c961
commit
573c1c82f7
Notes:
sideshowbarker
2024-07-18 17:07:32 +09:00
Author: https://github.com/Quaker762 Commit: https://github.com/SerenityOS/serenity/commit/573c1c82f7e Pull-request: https://github.com/SerenityOS/serenity/pull/7586 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/sunverwerth ✅
5 changed files with 51 additions and 0 deletions
|
@ -161,6 +161,40 @@ extern "C" {
|
|||
// Texture targets
|
||||
#define GL_TEXTURE_2D 0x0DE1
|
||||
|
||||
// Texture Unit indices
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#define GL_TEXTURE1 0x84C1
|
||||
#define GL_TEXTURE2 0x84C2
|
||||
#define GL_TEXTURE3 0x84C3
|
||||
#define GL_TEXTURE4 0x84C4
|
||||
#define GL_TEXTURE5 0x84C5
|
||||
#define GL_TEXTURE6 0x84C6
|
||||
#define GL_TEXTURE7 0x84C7
|
||||
#define GL_TEXTURE8 0x84C8
|
||||
#define GL_TEXTURE9 0x84C9
|
||||
#define GL_TEXTURE10 0x84CA
|
||||
#define GL_TEXTURE11 0x84CB
|
||||
#define GL_TEXTURE12 0x84CC
|
||||
#define GL_TEXTURE13 0x84CD
|
||||
#define GL_TEXTURE14 0x84CE
|
||||
#define GL_TEXTURE15 0x84CF
|
||||
#define GL_TEXTURE16 0x84D0
|
||||
#define GL_TEXTURE17 0x84D1
|
||||
#define GL_TEXTURE18 0x84D2
|
||||
#define GL_TEXTURE19 0x84D3
|
||||
#define GL_TEXTURE20 0x84D4
|
||||
#define GL_TEXTURE21 0x84D5
|
||||
#define GL_TEXTURE22 0x84D6
|
||||
#define GL_TEXTURE23 0x84D7
|
||||
#define GL_TEXTURE24 0x84D8
|
||||
#define GL_TEXTURE25 0x84D9
|
||||
#define GL_TEXTURE26 0x84DA
|
||||
#define GL_TEXTURE27 0x84DB
|
||||
#define GL_TEXTURE28 0x84DC
|
||||
#define GL_TEXTURE29 0x84DD
|
||||
#define GL_TEXTURE30 0x84DE
|
||||
#define GL_TEXTURE31 0x84DF
|
||||
|
||||
// Texture Environment and Parameters
|
||||
#define GL_NEAREST 0x2600
|
||||
#define GL_LINEAR 0x2601
|
||||
|
@ -259,6 +293,7 @@ GLAPI void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
|
|||
GLAPI void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data);
|
||||
GLAPI void glTexCoord2f(GLfloat s, GLfloat t);
|
||||
GLAPI void glBindTexture(GLenum target, GLuint texture);
|
||||
GLAPI void glActiveTexture(GLenum texture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
virtual void gl_tex_image_2d(GLenum target, GLint level, GLint internal_format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data) = 0;
|
||||
virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = 0;
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
|
||||
virtual void gl_active_texture(GLenum texture) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
|
|
@ -29,3 +29,10 @@ void glBindTexture(GLenum target, GLuint texture)
|
|||
{
|
||||
g_gl_context->gl_bind_texture(target, texture);
|
||||
}
|
||||
|
||||
// Note: This is an _extremely_ misleading API name. This sets the active
|
||||
// texture unit, NOT the active texture itself...
|
||||
void glActiveTexture(GLenum texture)
|
||||
{
|
||||
g_gl_context->gl_active_texture(texture);
|
||||
}
|
||||
|
|
|
@ -1286,6 +1286,13 @@ void SoftwareGLContext::gl_bind_texture(GLenum target, GLuint texture)
|
|||
}
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_active_texture(GLenum texture)
|
||||
{
|
||||
RETURN_WITH_ERROR_IF(texture < GL_TEXTURE0 || texture > GL_TEXTURE31, GL_INVALID_ENUM);
|
||||
|
||||
m_active_texture_unit = &m_texture_units.at(texture - GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
virtual void gl_tex_image_2d(GLenum target, GLint level, GLint internal_format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* data) override;
|
||||
virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) override;
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) override;
|
||||
virtual void gl_active_texture(GLenum texture) override;
|
||||
|
||||
virtual void present() override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue