From 67e5080cb5e9b4db424cbd7b048921936d02e727 Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Tue, 21 Feb 2023 08:02:40 +0700 Subject: [PATCH] tinygl4angle: add VertexAttrib functions Copy from gl4es: https://github.com/ptitSeb/gl4es/blob/3b926be6f2fb47a8befd0604e64008db3 e0d779a/src/gl/wrap/gl4eswraps.c#L670-L704 --- Natives/external/gl4es/tinygl4angle.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Natives/external/gl4es/tinygl4angle.c b/Natives/external/gl4es/tinygl4angle.c index da97fddb..0c36a81e 100644 --- a/Natives/external/gl4es/tinygl4angle.c +++ b/Natives/external/gl4es/tinygl4angle.c @@ -208,3 +208,29 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei widt gles_glTexImage2D(target, level, internalformat, width, height, border, format, type, data); } } + +// VertexArray stuff +#define THUNK(suffix, type, M2) \ +void glVertexAttrib1##suffix (GLuint index, type v0) { GLfloat f[4] = {0,0,0,1}; f[0] =v0; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib2##suffix (GLuint index, type v0, type v1) { GLfloat f[4] = {0,0,0,1}; f[0] =v0; f[1]=v1; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib3##suffix (GLuint index, type v0, type v1, type v2) { GLfloat f[4] = {0,0,0,1}; f[0] =v0; f[1]=v1; f[2]=v2; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib4##suffix (GLuint index, type v0, type v1, type v2, type v3) { GLfloat f[4] = {0,0,0,1}; f[0] =v0; f[1]=v1; f[2]=v2; f[3]=v3; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib1##suffix##v (GLuint index, const type *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib2##suffix##v (GLuint index, const type *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]; f[1]=v[1]; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib3##suffix##v (GLuint index, const type *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]; f[1]=v[1]; f[2]=v[2]; glVertexAttrib4fv(index, f); }; +THUNK(s, GLshort, ); +THUNK(d, GLdouble, _D); +#undef THUNK +void glVertexAttrib4dv (GLuint index, const GLdouble *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]; f[1]=v[1]; f[2]=v[2]; f[3]=v[3]; glVertexAttrib4fv(index, f); }; + +#define THUNK(suffix, type, norm) \ +void glVertexAttrib4##suffix##v (GLuint index, const type *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]; f[1]=v[1]; f[2]=v[2]; f[3]=v[3]; glVertexAttrib4fv(index, f); }; \ +void glVertexAttrib4N##suffix##v (GLuint index, const type *v) { GLfloat f[4] = {0,0,0,1}; f[0] =v[0]/norm; f[1]=v[1]/norm; f[2]=v[2]/norm; f[3]=v[3]/norm; glVertexAttrib4fv(index, f); }; +THUNK(b, GLbyte, 127.0f); +THUNK(ub, GLubyte, 255.0f); +THUNK(s, GLshort, 32767.0f); +THUNK(us, GLushort, 65535.0f); +THUNK(i, GLint, 2147483647.0f); +THUNK(ui, GLuint, 4294967295.0f); +#undef THUNK +void glVertexAttrib4Nub(GLuint index, GLubyte v0, GLubyte v1, GLubyte v2, GLubyte v3) {GLfloat f[4] = {0,0,0,1}; f[0] =v0/255.f; f[1]=v1/255.f; f[2]=v2/255.f; f[3]=v3/255.f; glVertexAttrib4fv(index, f); };