瀏覽代碼

LibGL: Implement glTexCoord2f

Jesse Buhagiar 4 年之前
父節點
當前提交
e21ba0cd12

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

@@ -256,6 +256,7 @@ GLAPI void glHint(GLenum target, GLenum mode);
 GLAPI void glReadBuffer(GLenum mode);
 GLAPI void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
 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);
 
 #ifdef __cplusplus
 }

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

@@ -58,6 +58,7 @@ public:
     virtual void gl_read_buffer(GLenum mode) = 0;
     virtual void gl_read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) = 0;
     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 present() = 0;
 };

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

@@ -140,6 +140,11 @@ void glVertex4sv(const GLshort* v)
     g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
 }
 
+void glTexCoord2f(GLfloat s, GLfloat t)
+{
+    g_gl_context->gl_tex_coord(s, t, 0.0f, 0.0f);
+}
+
 void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
 {
     g_gl_context->gl_rotate(angle, x, y, z);

+ 11 - 0
Userland/Libraries/LibGL/SoftwareGLContext.cpp

@@ -646,6 +646,17 @@ void SoftwareGLContext::gl_vertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w
     m_error = GL_NO_ERROR;
 }
 
+// FIXME: We need to add `r` and `q` to our GLVertex?!
+void SoftwareGLContext::gl_tex_coord(GLfloat s, GLfloat t, GLfloat, GLfloat)
+{
+    auto& vertex = vertex_list.last(); // Get the last created vertex
+
+    vertex.u = s;
+    vertex.v = t;
+
+    m_error = GL_NO_ERROR;
+}
+
 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);

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

@@ -67,6 +67,7 @@ public:
     virtual void gl_read_buffer(GLenum mode) override;
     virtual void gl_read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) override;
     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 present() override;