瀏覽代碼

LibGL: Add stubs for multitexturing and announce GL_ARB_multitexture

This makes glquake recognize multitexture support and choose the
multitexture rendering path.
Stephan Unverwerth 3 年之前
父節點
當前提交
044582b0ce

+ 5 - 0
Userland/Libraries/LibGL/GL/gl.h

@@ -571,6 +571,8 @@ GLAPI void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r);
 GLAPI void glTexCoord3fv(GLfloat const* v);
 GLAPI void glTexCoord3fv(GLfloat const* v);
 GLAPI void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
 GLAPI void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
 GLAPI void glTexCoord4fv(const GLfloat* v);
 GLAPI void glTexCoord4fv(const GLfloat* v);
+GLAPI void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
+GLAPI void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t);
 GLAPI void glTexParameteri(GLenum target, GLenum pname, GLint param);
 GLAPI void glTexParameteri(GLenum target, GLenum pname, GLint param);
 GLAPI void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
 GLAPI void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
 GLAPI void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
 GLAPI void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
@@ -586,6 +588,9 @@ GLAPI void glGetIntegerv(GLenum pname, GLint* data);
 GLAPI void glDepthMask(GLboolean flag);
 GLAPI void glDepthMask(GLboolean flag);
 GLAPI void glEnableClientState(GLenum cap);
 GLAPI void glEnableClientState(GLenum cap);
 GLAPI void glDisableClientState(GLenum cap);
 GLAPI void glDisableClientState(GLenum cap);
+GLAPI void glClientActiveTextureARB(GLenum target);
+GLAPI void glClientActiveTexture(GLenum target);
+
 GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
 GLAPI void glVertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
 GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
 GLAPI void glColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
 GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);
 GLAPI void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void* pointer);

+ 2 - 0
Userland/Libraries/LibGL/GLContext.h

@@ -69,6 +69,7 @@ public:
     virtual void gl_tex_sub_image_2d(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data) = 0;
     virtual void gl_tex_sub_image_2d(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data) = 0;
     virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) = 0;
     virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) = 0;
     virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = 0;
     virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = 0;
+    virtual void gl_multi_tex_coord(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) = 0;
     virtual void gl_tex_env(GLenum target, GLenum pname, GLfloat param) = 0;
     virtual void gl_tex_env(GLenum target, GLenum pname, GLfloat param) = 0;
     virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
     virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
     virtual GLboolean gl_is_texture(GLuint texture) = 0;
     virtual GLboolean gl_is_texture(GLuint texture) = 0;
@@ -76,6 +77,7 @@ public:
     virtual void gl_depth_mask(GLboolean flag) = 0;
     virtual void gl_depth_mask(GLboolean flag) = 0;
     virtual void gl_enable_client_state(GLenum cap) = 0;
     virtual void gl_enable_client_state(GLenum cap) = 0;
     virtual void gl_disable_client_state(GLenum cap) = 0;
     virtual void gl_disable_client_state(GLenum cap) = 0;
+    virtual void gl_client_active_texture(GLenum target) = 0;
     virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
     virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
     virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
     virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
     virtual void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;
     virtual void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) = 0;

+ 10 - 0
Userland/Libraries/LibGL/GLUtils.cpp

@@ -135,6 +135,16 @@ void glDisableClientState(GLenum cap)
     g_gl_context->gl_disable_client_state(cap);
     g_gl_context->gl_disable_client_state(cap);
 }
 }
 
 
+void glClientActiveTextureARB(GLenum target)
+{
+    glClientActiveTexture(target);
+}
+
+void glClientActiveTexture(GLenum target)
+{
+    g_gl_context->gl_client_active_texture(target);
+}
+
 void glDepthRange(GLdouble min, GLdouble max)
 void glDepthRange(GLdouble min, GLdouble max)
 {
 {
     g_gl_context->gl_depth_range(min, max);
     g_gl_context->gl_depth_range(min, max);

+ 10 - 0
Userland/Libraries/LibGL/GLVert.cpp

@@ -195,6 +195,16 @@ void glTexCoord4fv(const GLfloat* v)
     g_gl_context->gl_tex_coord(v[0], v[1], v[2], v[3]);
     g_gl_context->gl_tex_coord(v[0], v[1], v[2], v[3]);
 }
 }
 
 
+void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
+{
+    glMultiTexCoord2f(target, s, t);
+}
+
+void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t)
+{
+    g_gl_context->gl_multi_tex_coord(target, s, t, 0.0f, 1.0f);
+}
+
 void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
 void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
 {
 {
     g_gl_context->gl_normal(nx, ny, nz);
     g_gl_context->gl_normal(nx, ny, nz);

+ 15 - 1
Userland/Libraries/LibGL/SoftwareGLContext.cpp

@@ -621,7 +621,6 @@ void SoftwareGLContext::gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w
     m_vertex_list.append(vertex);
     m_vertex_list.append(vertex);
 }
 }
 
 
-// FIXME: We need to add `r` and `q` to our GLVertex?!
 void SoftwareGLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
 void SoftwareGLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
 {
 {
     APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_tex_coord, s, t, r, q);
     APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_tex_coord, s, t, r, q);
@@ -629,6 +628,13 @@ void SoftwareGLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
     m_current_vertex_tex_coord = { s, t, r, q };
     m_current_vertex_tex_coord = { s, t, r, q };
 }
 }
 
 
+void SoftwareGLContext::gl_multi_tex_coord(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+    APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_multi_tex_coord, target, s, t, r, q);
+
+    m_current_vertex_tex_coord = { s, t, r, q };
+}
+
 void SoftwareGLContext::gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 void SoftwareGLContext::gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
 {
     APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_viewport, x, y, width, height);
     APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_viewport, x, y, width, height);
@@ -2031,6 +2037,11 @@ void SoftwareGLContext::gl_disable_client_state(GLenum cap)
     }
     }
 }
 }
 
 
+void SoftwareGLContext::gl_client_active_texture(GLenum target)
+{
+    (void)target;
+}
+
 void SoftwareGLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer)
 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(m_in_draw_state, GL_INVALID_OPERATION);
@@ -3264,6 +3275,9 @@ void SoftwareGLContext::build_extension_string()
     if (m_device_info.supports_npot_textures)
     if (m_device_info.supports_npot_textures)
         extensions.append("GL_ARB_texture_non_power_of_two");
         extensions.append("GL_ARB_texture_non_power_of_two");
 
 
+    if (m_device_info.num_texture_units > 1)
+        extensions.append("GL_ARB_multitexture");
+
     m_extensions = String::join(" ", extensions);
     m_extensions = String::join(" ", extensions);
 }
 }
 
 

+ 2 - 0
Userland/Libraries/LibGL/SoftwareGLContext.h

@@ -100,6 +100,7 @@ public:
     virtual void gl_tex_sub_image_2d(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data) override;
     virtual void gl_tex_sub_image_2d(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* data) override;
     virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) override;
     virtual void gl_tex_parameter(GLenum target, GLenum pname, GLfloat param) override;
     virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) override;
     virtual void gl_tex_coord(GLfloat s, GLfloat t, GLfloat r, GLfloat q) override;
+    virtual void gl_multi_tex_coord(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) override;
     virtual void gl_tex_env(GLenum target, GLenum pname, GLfloat param) override;
     virtual void gl_tex_env(GLenum target, GLenum pname, GLfloat param) override;
     virtual void gl_bind_texture(GLenum target, GLuint texture) override;
     virtual void gl_bind_texture(GLenum target, GLuint texture) override;
     virtual GLboolean gl_is_texture(GLuint texture) override;
     virtual GLboolean gl_is_texture(GLuint texture) override;
@@ -107,6 +108,7 @@ public:
     virtual void gl_depth_mask(GLboolean flag) override;
     virtual void gl_depth_mask(GLboolean flag) override;
     virtual void gl_enable_client_state(GLenum cap) override;
     virtual void gl_enable_client_state(GLenum cap) override;
     virtual void gl_disable_client_state(GLenum cap) override;
     virtual void gl_disable_client_state(GLenum cap) override;
+    virtual void gl_client_active_texture(GLenum target) override;
     virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
     virtual void gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
     virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
     virtual void gl_color_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
     virtual void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;
     virtual void gl_tex_coord_pointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override;