diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-08-20 22:09:32 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-08-20 22:09:32 +0300 |
commit | eb717ee9794a0e3c217f7e6f32904a115fc6e9e1 (patch) | |
tree | 83ac32c64bdafd3fb8e722e52989742b4366fdb9 /source/blender/gpu/intern/gpu_immediate.c | |
parent | 1e6b3ef1a1e257741fb4c982a1cb4854d49a1713 (diff) |
Gawain: more immediate mode functions
Scanned Blender code for commonly used glVertex, glColor functions.
Implemented immVertex, immAttrib versions of these to ease transition
away from legacy OpenGL.
Diffstat (limited to 'source/blender/gpu/intern/gpu_immediate.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 3065a3eb63f..d250bcc78f9 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -571,6 +571,39 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z) data[2] = z; } +void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w) + { + Attrib* attrib = imm.vertex_format.attribs + attrib_id; + +#if TRUST_NO_ONE + assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib->comp_type == GL_FLOAT); + assert(attrib->comp_ct == 4); + assert(imm.vertex_idx < imm.vertex_ct); + assert(imm.primitive != GL_NONE); // make sure we're between a Begin/End pair +#endif + + setAttribValueBit(attrib_id); + + float* data = (float*)(imm.vertex_data + attrib->offset); +// printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); + + data[0] = x; + data[1] = y; + data[2] = z; + data[3] = w; + } + +void immAttrib3fv(unsigned attrib_id, const float data[3]) + { + immAttrib3f(attrib_id, data[0], data[1], data[2]); + } + +void immAttrib4fv(unsigned attrib_id, const float data[4]) + { + immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]); + } + void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned char b) { Attrib* attrib = imm.vertex_format.attribs + attrib_id; @@ -616,6 +649,11 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned data[3] = a; } +void immAttrib3ubv(unsigned attrib_id, const unsigned char data[3]) + { + immAttrib3ub(attrib_id, data[0], data[1], data[2]); + } + void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]) { immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]); @@ -669,6 +707,12 @@ void immVertex3f(unsigned attrib_id, float x, float y, float z) immEndVertex(); } +void immVertex2fv(unsigned attrib_id, const float data[2]) + { + immAttrib2f(attrib_id, data[0], data[1]); + immEndVertex(); + } + void immVertex3fv(unsigned attrib_id, const float data[3]) { immAttrib3f(attrib_id, data[0], data[1], data[2]); |