summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2021-05-30 16:56:56 +1000
committerLinus Groh <mail@linusgroh.de>2021-05-31 14:59:47 +0100
commit573c1c82f7ea47a33f2899a94a4594e55a3121cc (patch)
tree08b00a89616c9a214d40999722451b3560bebf9a /Userland
parent52e5d3c961711611e6ae74047812515ed3f9a9df (diff)
downloadserenity-573c1c82f7ea47a33f2899a94a4594e55a3121cc.zip
LibGL: Implement glActiveTexture
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h35
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLTexture.cpp7
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp7
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 51 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 3cb027d44a..62af06aab0 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -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
}
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index f4c00ec43a..7f0279f8bd 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -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;
};
diff --git a/Userland/Libraries/LibGL/GLTexture.cpp b/Userland/Libraries/LibGL/GLTexture.cpp
index fbc295ad48..a8dfc6cb2a 100644
--- a/Userland/Libraries/LibGL/GLTexture.cpp
+++ b/Userland/Libraries/LibGL/GLTexture.cpp
@@ -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);
+}
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index 92b415abfd..c6b2b5ff1e 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -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);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 7ad4c77ba8..9d207becd7 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -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;