Files
MobileGL/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h
T
swung0x48 0cada09aa7 [Feat] (MG_Impl/GLImpl): implement 8 packed glVertexAttribP*ui current-value setters
glVertexAttribP{1,2,3,4}ui and their *uiv forms set the CURRENT generic
vertex attribute value from a packed 2_10_10_10_REV word (they are the
packed members of the immediate VertexAttrib* family, not the array-format
path), so they funnel into SetCurrentVertexAttributeFloat and reuse the
existing index validation.

- Add DecodePacked2101010: unpacks x=[0..9], y=[10..19], z=[20..29] (10-bit)
  and w=[30..31] (2-bit) from one 32-bit word. Signed fields are two's-
  complement (sign-extended per width); normalized conversion uses the
  GL 3.3 (2c+1)/(2^b-1) form (10-bit /1023, 2-bit /3), matching the
  existing NormalizeSigned* helpers -- NOT the GL 4.2 clamp form.
- type accepts only GL_INT_2_10_10_10_REV / GL_UNSIGNED_INT_2_10_10_10_REV
  (GL_INVALID_ENUM otherwise; the 4.4-era 10F_11F_11F_REV is not legal in
  3.3). P1/P2/P3 consume the first 1/2/3 components; the rest take the
  (0,0,0,1) defaults and are cleared each call. The *uiv forms dereference
  a single packed word, not an array.

Tests: 4 VertexArrayTest cases (unsigned decode, signed GL-3.3 formula,
component-count/defaults, type/index/uiv validation). The signed test is
mutation-verified: z==0 -> 1/1023 fails against the GL 4.2 form.
VertexArrayTest 38/38, SanityTest 30/30.
2026-07-10 23:07:13 -04:00

120 lines
7.7 KiB
C++

// MobileGL - MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h
// Copyright (c) 2025-2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
#pragma once
#include <Includes.h>
namespace MobileGL::MG_Impl::GLImpl {
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */
void VertexAttrib1f(GLuint index, GLfloat x);
void VertexAttrib1fv(GLuint index, const GLfloat* v);
void VertexAttrib2f(GLuint index, GLfloat x, GLfloat y);
void VertexAttrib2fv(GLuint index, const GLfloat* v);
void VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z);
void VertexAttrib3fv(GLuint index, const GLfloat* v);
void VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void VertexAttrib4fv(GLuint index, const GLfloat* v);
void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
void VertexAttribI4iv(GLuint index, const GLint* v);
void VertexAttribI4uiv(GLuint index, const GLuint* v);
// Packed current-value setters (GL_INT_/GL_UNSIGNED_INT_2_10_10_10_REV). Decode one packed word
// into the first 1/2/3/4 components of the generic attribute's float current value.
void VertexAttribP1ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);
void VertexAttribP2ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);
void VertexAttribP3ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);
void VertexAttribP4ui(GLuint index, GLenum type, GLboolean normalized, GLuint value);
void VertexAttribP1uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
void VertexAttribP2uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
void VertexAttribP3uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
void VertexAttribP4uiv(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
void VertexAttrib4Nub(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
void VertexAttrib4Nubv(GLuint index, const GLubyte* v);
void VertexAttrib4ubv(GLuint index, const GLubyte* v);
// Float-domain current-value setters that funnel into VertexAttrib4f. The d/s/bv/iv/uiv/usv
// forms are value-preserving (only the 4N* forms normalize per GL 3.3 Core Eq 2.1/2.2).
void VertexAttrib1d(GLuint index, GLdouble x);
void VertexAttrib2d(GLuint index, GLdouble x, GLdouble y);
void VertexAttrib3d(GLuint index, GLdouble x, GLdouble y, GLdouble z);
void VertexAttrib4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
void VertexAttrib1dv(GLuint index, const GLdouble* v);
void VertexAttrib2dv(GLuint index, const GLdouble* v);
void VertexAttrib3dv(GLuint index, const GLdouble* v);
void VertexAttrib4dv(GLuint index, const GLdouble* v);
void VertexAttrib1s(GLuint index, GLshort x);
void VertexAttrib2s(GLuint index, GLshort x, GLshort y);
void VertexAttrib3s(GLuint index, GLshort x, GLshort y, GLshort z);
void VertexAttrib4s(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
void VertexAttrib1sv(GLuint index, const GLshort* v);
void VertexAttrib2sv(GLuint index, const GLshort* v);
void VertexAttrib3sv(GLuint index, const GLshort* v);
void VertexAttrib4sv(GLuint index, const GLshort* v);
void VertexAttrib4bv(GLuint index, const GLbyte* v);
void VertexAttrib4iv(GLuint index, const GLint* v);
void VertexAttrib4uiv(GLuint index, const GLuint* v);
void VertexAttrib4usv(GLuint index, const GLushort* v);
void VertexAttrib4Nbv(GLuint index, const GLbyte* v);
void VertexAttrib4Nsv(GLuint index, const GLshort* v);
void VertexAttrib4Niv(GLuint index, const GLint* v);
void VertexAttrib4Nusv(GLuint index, const GLushort* v);
void VertexAttrib4Nuiv(GLuint index, const GLuint* v);
// Pure-integer current-value setters that funnel into VertexAttribI4i / VertexAttribI4ui and
// write the integer view, never the float one.
void VertexAttribI1i(GLuint index, GLint x);
void VertexAttribI2i(GLuint index, GLint x, GLint y);
void VertexAttribI3i(GLuint index, GLint x, GLint y, GLint z);
void VertexAttribI1ui(GLuint index, GLuint x);
void VertexAttribI2ui(GLuint index, GLuint x, GLuint y);
void VertexAttribI3ui(GLuint index, GLuint x, GLuint y, GLuint z);
void VertexAttribI1iv(GLuint index, const GLint* v);
void VertexAttribI2iv(GLuint index, const GLint* v);
void VertexAttribI3iv(GLuint index, const GLint* v);
void VertexAttribI1uiv(GLuint index, const GLuint* v);
void VertexAttribI2uiv(GLuint index, const GLuint* v);
void VertexAttribI3uiv(GLuint index, const GLuint* v);
void VertexAttribI4bv(GLuint index, const GLbyte* v);
void VertexAttribI4sv(GLuint index, const GLshort* v);
void VertexAttribI4ubv(GLuint index, const GLubyte* v);
void VertexAttribI4usv(GLuint index, const GLushort* v);
void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
void GetVertexAttribdv(GLuint index, GLenum pname, GLdouble* params);
void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer);
void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params);
void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params);
void CreateVertexArrays(GLsizei n, GLuint* arrays);
void DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
void EnableVertexArrayAttrib(GLuint vaobj, GLuint index);
void VertexArrayElementBuffer(GLuint vaobj, GLuint buffer);
void VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
void VertexArrayAttribFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized,
GLuint relativeoffset);
void VertexArrayAttribIFormat(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
void VertexArrayAttribBinding(GLuint vaobj, GLuint attribindex, GLuint bindingindex);
void VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingindex, GLuint divisor);
void VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count, const GLuint* buffers,
const GLintptr* offsets, const GLsizei* strides);
void BindVertexBuffer(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
void BindVertexBuffers(GLuint first, GLsizei count, const GLuint* buffers, const GLintptr* offsets,
const GLsizei* strides);
void VertexAttribFormat(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
void VertexAttribIFormat(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
void VertexAttribBinding(GLuint attribindex, GLuint bindingindex);
void VertexBindingDivisor(GLuint bindingindex, GLuint divisor);
void VertexAttribDivisor(GLuint index, GLuint divisor);
GLboolean IsVertexArray(GLuint array);
void DisableVertexAttribArray(GLuint index);
void EnableVertexAttribArray(GLuint index);
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
const void* pointer);
void BindVertexArray(GLuint array);
void DeleteVertexArrays(GLsizei n, const GLuint* arrays);
void GenVertexArrays(GLsizei n, GLuint* arrays);
} // namespace MobileGL::MG_Impl::GLImpl