istereo2

annotate src/sanegl.c @ 14:018f997dc646

button done
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 29 Sep 2015 01:11:54 +0300
parents 81d35769f546
children
rev   line source
nuclear@2 1 /*
nuclear@2 2 SaneGL - a small library to bring back sanity to OpenGL ES 2.x
nuclear@2 3 Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org>
nuclear@2 4
nuclear@2 5 This program is free software: you can redistribute it and/or modify
nuclear@2 6 it under the terms of the GNU General Public License as published by
nuclear@2 7 the Free Software Foundation, either version 3 of the License, or
nuclear@2 8 (at your option) any later version.
nuclear@2 9
nuclear@2 10 This program is distributed in the hope that it will be useful,
nuclear@2 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
nuclear@2 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
nuclear@2 13 GNU General Public License for more details.
nuclear@2 14
nuclear@2 15 You should have received a copy of the GNU General Public License
nuclear@2 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
nuclear@2 17 */
nuclear@2 18
nuclear@2 19 #include <stdio.h>
nuclear@2 20 #include <stdlib.h>
nuclear@2 21 #include <string.h>
nuclear@2 22 #include <math.h>
nuclear@2 23 #include <assert.h>
nuclear@6 24
nuclear@6 25 #include "opengl.h"
nuclear@6 26
nuclear@6 27 #ifdef GLDEF
nuclear@6 28 #undef GLDEF
nuclear@6 29 #endif
nuclear@2 30 #include "sanegl.h"
nuclear@2 31
nuclear@2 32 #define MMODE_IDX(x) ((x) - GL_MODELVIEW)
nuclear@2 33 #define MAT_STACK_SIZE 32
nuclear@2 34 #define MAT_IDENT {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
nuclear@2 35
nuclear@2 36 #define MAX_VERTS 512
nuclear@2 37
nuclear@2 38 static void gl_draw_immediate(void);
nuclear@2 39
nuclear@2 40 typedef struct { float x, y; } vec2_t;
nuclear@2 41 typedef struct { float x, y, z; } vec3_t;
nuclear@2 42 typedef struct { float x, y, z, w; } vec4_t;
nuclear@2 43
nuclear@2 44 static int mm_idx = 0;
nuclear@2 45 static float mat_stack[3][MAT_STACK_SIZE][16] = {{MAT_IDENT}, {MAT_IDENT}, {MAT_IDENT}};
nuclear@2 46 static int stack_top[3];
nuclear@2 47 static float mat_mvp[16];
nuclear@2 48 static int mvp_valid;
nuclear@2 49 static int prim = -1;
nuclear@2 50
nuclear@2 51 static vec3_t cur_normal;
nuclear@2 52 static vec4_t cur_color, cur_attrib;
nuclear@2 53 static vec2_t cur_texcoord;
nuclear@2 54
nuclear@2 55 static vec4_t *vert_arr, *col_arr, *attr_arr;
nuclear@2 56 static vec3_t *norm_arr;
nuclear@2 57 static vec2_t *texc_arr;
nuclear@2 58 /*static unsigned int vbuf, cbuf, nbuf, tbuf, abuf;*/
nuclear@2 59 static int vloc, nloc, cloc, tloc, aloc = -1;
nuclear@2 60
nuclear@2 61 static int num_verts, vert_calls;
nuclear@2 62 static int cur_prog;
nuclear@2 63
nuclear@2 64
nuclear@2 65 void gl_matrix_mode(int mm)
nuclear@2 66 {
nuclear@2 67 mm_idx = MMODE_IDX(mm);
nuclear@2 68 }
nuclear@2 69
nuclear@2 70 void gl_push_matrix(void)
nuclear@2 71 {
nuclear@2 72 int top = stack_top[mm_idx];
nuclear@2 73
nuclear@2 74 memcpy(mat_stack[mm_idx][top + 1], mat_stack[mm_idx][top], 16 * sizeof(float));
nuclear@2 75 stack_top[mm_idx]++;
nuclear@2 76 mvp_valid = 0;
nuclear@2 77 }
nuclear@2 78
nuclear@2 79 void gl_pop_matrix(void)
nuclear@2 80 {
nuclear@2 81 stack_top[mm_idx]--;
nuclear@2 82 mvp_valid = 0;
nuclear@2 83 }
nuclear@2 84
nuclear@2 85 void gl_load_identity(void)
nuclear@2 86 {
nuclear@2 87 static const float idmat[] = MAT_IDENT;
nuclear@2 88 int top = stack_top[mm_idx];
nuclear@2 89 float *mat = mat_stack[mm_idx][top];
nuclear@2 90
nuclear@2 91 memcpy(mat, idmat, sizeof idmat);
nuclear@2 92 mvp_valid = 0;
nuclear@2 93 }
nuclear@2 94
nuclear@2 95 void gl_load_matrixf(const float *m)
nuclear@2 96 {
nuclear@2 97 int top = stack_top[mm_idx];
nuclear@2 98 float *mat = mat_stack[mm_idx][top];
nuclear@2 99
nuclear@2 100 memcpy(mat, m, 16 * sizeof *mat);
nuclear@2 101 mvp_valid = 0;
nuclear@2 102 }
nuclear@2 103
nuclear@2 104 #define M(i, j) ((i << 2) + j)
nuclear@2 105
nuclear@2 106 void gl_mult_matrixf(const float *m2)
nuclear@2 107 {
nuclear@2 108 int i, j;
nuclear@2 109 int top = stack_top[mm_idx];
nuclear@2 110 float *m1 = mat_stack[mm_idx][top];
nuclear@2 111 float res[16];
nuclear@2 112
nuclear@2 113 for(i=0; i<4; i++) {
nuclear@2 114 for(j=0; j<4; j++) {
nuclear@2 115 res[M(i,j)] = m1[M(i,0)] * m2[M(0,j)] +
nuclear@2 116 m1[M(i,1)] * m2[M(1,j)] +
nuclear@2 117 m1[M(i,2)] * m2[M(2,j)] +
nuclear@2 118 m1[M(i,3)] * m2[M(3,j)];
nuclear@2 119 }
nuclear@2 120 }
nuclear@2 121
nuclear@2 122 memcpy(m1, res, sizeof res);
nuclear@2 123 mvp_valid = 0;
nuclear@2 124 }
nuclear@2 125
nuclear@2 126 void gl_translatef(float x, float y, float z)
nuclear@2 127 {
nuclear@2 128 float mat[] = MAT_IDENT;
nuclear@2 129
nuclear@2 130 mat[12] = x;
nuclear@2 131 mat[13] = y;
nuclear@2 132 mat[14] = z;
nuclear@2 133
nuclear@2 134 gl_mult_matrixf(mat);
nuclear@2 135 }
nuclear@2 136
nuclear@2 137 void gl_rotatef(float angle, float x, float y, float z)
nuclear@2 138 {
nuclear@2 139 float mat[] = MAT_IDENT;
nuclear@2 140
nuclear@2 141 float angle_rad = M_PI * angle / 180.0;
nuclear@2 142 float sina = sin(angle_rad);
nuclear@2 143 float cosa = cos(angle_rad);
nuclear@2 144 float one_minus_cosa = 1.0 - cosa;
nuclear@2 145 float nxsq = x * x;
nuclear@2 146 float nysq = y * y;
nuclear@2 147 float nzsq = z * z;
nuclear@2 148
nuclear@2 149 mat[0] = nxsq + (1.0 - nxsq) * cosa;
nuclear@2 150 mat[4] = x * y * one_minus_cosa - z * sina;
nuclear@2 151 mat[8] = x * z * one_minus_cosa + y * sina;
nuclear@2 152 mat[1] = x * y * one_minus_cosa + z * sina;
nuclear@2 153 mat[5] = nysq + (1.0 - nysq) * cosa;
nuclear@2 154 mat[9] = y * z * one_minus_cosa - x * sina;
nuclear@2 155 mat[2] = x * z * one_minus_cosa - y * sina;
nuclear@2 156 mat[6] = y * z * one_minus_cosa + x * sina;
nuclear@2 157 mat[10] = nzsq + (1.0 - nzsq) * cosa;
nuclear@2 158
nuclear@2 159 gl_mult_matrixf(mat);
nuclear@2 160 }
nuclear@2 161
nuclear@2 162 void gl_scalef(float x, float y, float z)
nuclear@2 163 {
nuclear@2 164 float mat[] = MAT_IDENT;
nuclear@2 165
nuclear@2 166 mat[0] = x;
nuclear@2 167 mat[5] = y;
nuclear@2 168 mat[10] = z;
nuclear@2 169
nuclear@2 170 gl_mult_matrixf(mat);
nuclear@2 171 }
nuclear@2 172
nuclear@2 173 void gl_ortho(float left, float right, float bottom, float top, float near, float far)
nuclear@2 174 {
nuclear@2 175 float mat[] = MAT_IDENT;
nuclear@2 176
nuclear@2 177 float dx = right - left;
nuclear@2 178 float dy = top - bottom;
nuclear@2 179 float dz = far - near;
nuclear@2 180
nuclear@2 181 float tx = -(right + left) / dx;
nuclear@2 182 float ty = -(top + bottom) / dy;
nuclear@2 183 float tz = -(far + near) / dz;
nuclear@2 184
nuclear@2 185 float sx = 2.0 / dx;
nuclear@2 186 float sy = 2.0 / dy;
nuclear@2 187 float sz = -2.0 / dz;
nuclear@2 188
nuclear@2 189 mat[0] = sx;
nuclear@2 190 mat[5] = sy;
nuclear@2 191 mat[10] = sz;
nuclear@2 192 mat[12] = tx;
nuclear@2 193 mat[13] = ty;
nuclear@2 194 mat[14] = tz;
nuclear@2 195
nuclear@2 196 gl_mult_matrixf(mat);
nuclear@2 197 }
nuclear@2 198
nuclear@2 199 void gl_frustum(float left, float right, float bottom, float top, float near, float far)
nuclear@2 200 {
nuclear@2 201 float mat[] = MAT_IDENT;
nuclear@2 202
nuclear@2 203 float dx = right - left;
nuclear@2 204 float dy = top - bottom;
nuclear@2 205 float dz = far - near;
nuclear@2 206
nuclear@2 207 float a = (right + left) / dx;
nuclear@2 208 float b = (top + bottom) / dy;
nuclear@2 209 float c = -(far + near) / dz;
nuclear@2 210 float d = -2.0 * far * near / dz;
nuclear@2 211
nuclear@2 212 mat[0] = 2.0 * near / dx;
nuclear@2 213 mat[5] = 2.0 * near / dy;
nuclear@2 214 mat[8] = a;
nuclear@2 215 mat[9] = b;
nuclear@2 216 mat[10] = c;
nuclear@2 217 mat[11] = -1.0;
nuclear@2 218 mat[14] = d;
nuclear@2 219
nuclear@2 220 gl_mult_matrixf(mat);
nuclear@2 221 }
nuclear@2 222
nuclear@2 223 void glu_perspective(float vfov, float aspect, float near, float far)
nuclear@2 224 {
nuclear@2 225 float vfov_rad = M_PI * vfov / 180.0;
nuclear@2 226 float x = near * tan(vfov_rad / 2.0);
nuclear@2 227 gl_frustum(-aspect * x, aspect * x, -x, x, near, far);
nuclear@2 228 }
nuclear@2 229
nuclear@2 230 void gl_apply_xform(unsigned int prog)
nuclear@2 231 {
nuclear@2 232 int loc, mvidx, pidx, tidx, mvtop, ptop, ttop;
nuclear@2 233
nuclear@2 234 mvidx = MMODE_IDX(GL_MODELVIEW);
nuclear@2 235 pidx = MMODE_IDX(GL_PROJECTION);
nuclear@2 236 tidx = MMODE_IDX(GL_TEXTURE);
nuclear@2 237
nuclear@2 238 mvtop = stack_top[mvidx];
nuclear@2 239 ptop = stack_top[pidx];
nuclear@2 240 ttop = stack_top[tidx];
nuclear@2 241
nuclear@2 242 assert(prog);
nuclear@2 243
nuclear@2 244 if((loc = glGetUniformLocation(prog, "matrix_modelview")) != -1) {
nuclear@2 245 glUniformMatrix4fv(loc, 1, 0, mat_stack[mvidx][mvtop]);
nuclear@2 246 }
nuclear@2 247
nuclear@2 248 if((loc = glGetUniformLocation(prog, "matrix_projection")) != -1) {
nuclear@2 249 glUniformMatrix4fv(loc, 1, 0, mat_stack[pidx][ptop]);
nuclear@2 250 }
nuclear@2 251
nuclear@2 252 if((loc = glGetUniformLocation(prog, "matrix_texture")) != -1) {
nuclear@2 253 glUniformMatrix4fv(loc, 1, 0, mat_stack[tidx][ttop]);
nuclear@2 254 }
nuclear@2 255
nuclear@2 256 if((loc = glGetUniformLocation(prog, "matrix_normal")) != -1) {
nuclear@2 257 float nmat[9];
nuclear@2 258
nuclear@2 259 nmat[0] = mat_stack[mvidx][mvtop][0];
nuclear@2 260 nmat[1] = mat_stack[mvidx][mvtop][1];
nuclear@2 261 nmat[2] = mat_stack[mvidx][mvtop][2];
nuclear@2 262 nmat[3] = mat_stack[mvidx][mvtop][4];
nuclear@2 263 nmat[4] = mat_stack[mvidx][mvtop][5];
nuclear@2 264 nmat[5] = mat_stack[mvidx][mvtop][6];
nuclear@2 265 nmat[6] = mat_stack[mvidx][mvtop][8];
nuclear@2 266 nmat[7] = mat_stack[mvidx][mvtop][9];
nuclear@2 267 nmat[8] = mat_stack[mvidx][mvtop][10];
nuclear@2 268 glUniformMatrix3fv(loc, 1, 0, nmat);
nuclear@2 269 }
nuclear@2 270
nuclear@2 271 if((loc = glGetUniformLocation(prog, "matrix_modelview_projection")) != -1) {
nuclear@2 272 if(!mvp_valid) {
nuclear@2 273 /* TODO calc mvp */
nuclear@2 274 }
nuclear@2 275 glUniformMatrix4fv(loc, 1, 0, mat_mvp);
nuclear@2 276 }
nuclear@2 277 }
nuclear@2 278
nuclear@2 279
nuclear@2 280 /* immediate mode rendering */
nuclear@2 281 void gl_begin(int p)
nuclear@2 282 {
nuclear@2 283 if(!vert_arr) {
nuclear@2 284 vert_arr = malloc(MAX_VERTS * sizeof *vert_arr);
nuclear@2 285 norm_arr = malloc(MAX_VERTS * sizeof *norm_arr);
nuclear@2 286 texc_arr = malloc(MAX_VERTS * sizeof *texc_arr);
nuclear@2 287 col_arr = malloc(MAX_VERTS * sizeof *col_arr);
nuclear@2 288 attr_arr = malloc(MAX_VERTS * sizeof *attr_arr);
nuclear@2 289 assert(vert_arr && norm_arr && texc_arr && col_arr && attr_arr);
nuclear@2 290 }
nuclear@2 291
nuclear@2 292 prim = p;
nuclear@2 293 num_verts = vert_calls = 0;
nuclear@2 294
nuclear@2 295 glGetIntegerv(GL_CURRENT_PROGRAM, &cur_prog);
nuclear@2 296 assert(cur_prog);
nuclear@2 297
nuclear@2 298 gl_apply_xform(cur_prog);
nuclear@2 299
nuclear@2 300 vloc = glGetAttribLocation(cur_prog, "attr_vertex");
nuclear@2 301 nloc = glGetAttribLocation(cur_prog, "attr_normal");
nuclear@2 302 cloc = glGetAttribLocation(cur_prog, "attr_color");
nuclear@2 303 tloc = glGetAttribLocation(cur_prog, "attr_texcoord");
nuclear@2 304 }
nuclear@2 305
nuclear@2 306 void gl_end(void)
nuclear@2 307 {
nuclear@2 308 if(num_verts > 0) {
nuclear@2 309 gl_draw_immediate();
nuclear@2 310 }
nuclear@2 311 aloc = -1;
nuclear@2 312 }
nuclear@2 313
nuclear@2 314 static void gl_draw_immediate(void)
nuclear@2 315 {
nuclear@2 316 int glprim;
nuclear@2 317
nuclear@2 318 if(vloc == -1) {
nuclear@2 319 fprintf(stderr, "gl_draw_immediate call with vloc == -1\n");
nuclear@2 320 return;
nuclear@2 321 }
nuclear@2 322
nuclear@2 323 glprim = prim == GL_QUADS ? GL_TRIANGLES : prim;
nuclear@2 324
nuclear@2 325 glVertexAttribPointer(vloc, 4, GL_FLOAT, 0, 0, vert_arr);
nuclear@2 326 glEnableVertexAttribArray(vloc);
nuclear@2 327
nuclear@2 328 if(nloc != -1) {
nuclear@2 329 glVertexAttribPointer(nloc, 3, GL_FLOAT, 0, 0, norm_arr);
nuclear@2 330 glEnableVertexAttribArray(nloc);
nuclear@2 331 }
nuclear@2 332
nuclear@2 333 if(cloc != -1) {
nuclear@2 334 glVertexAttribPointer(cloc, 4, GL_FLOAT, 1, 0, col_arr);
nuclear@2 335 glEnableVertexAttribArray(cloc);
nuclear@2 336 }
nuclear@2 337
nuclear@2 338 if(tloc != -1) {
nuclear@2 339 glVertexAttribPointer(tloc, 2, GL_FLOAT, 0, 0, texc_arr);
nuclear@2 340 glEnableVertexAttribArray(tloc);
nuclear@2 341 }
nuclear@2 342
nuclear@2 343 if(aloc != -1) {
nuclear@2 344 glVertexAttribPointer(aloc, 4, GL_FLOAT, 0, 0, attr_arr);
nuclear@2 345 glEnableVertexAttribArray(aloc);
nuclear@2 346 }
nuclear@2 347
nuclear@2 348 glDrawArrays(glprim, 0, num_verts);
nuclear@2 349
nuclear@2 350 glDisableVertexAttribArray(vloc);
nuclear@2 351 if(nloc != -1) {
nuclear@2 352 glDisableVertexAttribArray(nloc);
nuclear@2 353 }
nuclear@2 354 if(cloc != -1) {
nuclear@2 355 glDisableVertexAttribArray(cloc);
nuclear@2 356 }
nuclear@2 357 if(tloc != -1) {
nuclear@2 358 glDisableVertexAttribArray(tloc);
nuclear@2 359 }
nuclear@2 360 if(aloc != -1) {
nuclear@2 361 glDisableVertexAttribArray(aloc);
nuclear@2 362 }
nuclear@2 363 }
nuclear@2 364
nuclear@2 365
nuclear@2 366 void gl_vertex2f(float x, float y)
nuclear@2 367 {
nuclear@2 368 gl_vertex4f(x, y, 0.0f, 1.0f);
nuclear@2 369 }
nuclear@2 370
nuclear@2 371 void gl_vertex3f(float x, float y, float z)
nuclear@2 372 {
nuclear@2 373 gl_vertex4f(x, y, z, 1.0f);
nuclear@2 374 }
nuclear@2 375
nuclear@2 376 void gl_vertex4f(float x, float y, float z, float w)
nuclear@2 377 {
nuclear@2 378 int i, buffer_full;
nuclear@2 379
nuclear@2 380 if(prim == GL_QUADS && vert_calls % 4 == 3) {
nuclear@2 381 for(i=0; i<2; i++) {
nuclear@2 382 if(aloc != -1) {
nuclear@2 383 attr_arr[num_verts] = attr_arr[num_verts - 3 + i];
nuclear@2 384 }
nuclear@2 385 if(cloc != -1) {
nuclear@2 386 col_arr[num_verts] = col_arr[num_verts - 3 + i];
nuclear@2 387 }
nuclear@2 388 if(tloc != -1) {
nuclear@2 389 texc_arr[num_verts] = texc_arr[num_verts - 3 + i];
nuclear@2 390 }
nuclear@2 391 if(nloc != -1) {
nuclear@2 392 norm_arr[num_verts] = norm_arr[num_verts - 3 + i];
nuclear@2 393 }
nuclear@2 394 vert_arr[num_verts] = vert_arr[num_verts - 3 + i];
nuclear@2 395 num_verts++;
nuclear@2 396 }
nuclear@2 397 }
nuclear@2 398
nuclear@2 399 vert_arr[num_verts].x = x;
nuclear@2 400 vert_arr[num_verts].y = y;
nuclear@2 401 vert_arr[num_verts].z = z;
nuclear@2 402 vert_arr[num_verts].w = w;
nuclear@2 403
nuclear@2 404 if(cloc != -1) {
nuclear@2 405 col_arr[num_verts] = cur_color;
nuclear@2 406 }
nuclear@2 407 if(nloc != -1) {
nuclear@2 408 norm_arr[num_verts] = cur_normal;
nuclear@2 409 }
nuclear@2 410 if(tloc != -1) {
nuclear@2 411 texc_arr[num_verts] = cur_texcoord;
nuclear@2 412 }
nuclear@2 413 if(aloc != -1) {
nuclear@2 414 attr_arr[num_verts] = cur_attrib;
nuclear@2 415 }
nuclear@2 416
nuclear@2 417 vert_calls++;
nuclear@2 418 num_verts++;
nuclear@2 419
nuclear@2 420 if(prim == GL_QUADS) {
nuclear@2 421 /* leave space for 6 more worst-case and don't allow flushes mid-quad */
nuclear@2 422 buffer_full = num_verts >= MAX_VERTS - 6 && vert_calls % 4 == 0;
nuclear@2 423 } else {
nuclear@2 424 buffer_full = num_verts >= MAX_VERTS - prim;
nuclear@2 425 }
nuclear@2 426
nuclear@2 427 if(buffer_full) {
nuclear@2 428 gl_draw_immediate();
nuclear@2 429 gl_begin(prim); /* reset everything */
nuclear@2 430 }
nuclear@2 431 }
nuclear@2 432
nuclear@2 433
nuclear@2 434 void gl_normal3f(float x, float y, float z)
nuclear@2 435 {
nuclear@2 436 cur_normal.x = x;
nuclear@2 437 cur_normal.y = y;
nuclear@2 438 cur_normal.z = z;
nuclear@2 439 }
nuclear@2 440
nuclear@2 441
nuclear@2 442 void gl_color3f(float r, float g, float b)
nuclear@2 443 {
nuclear@2 444 cur_color.x = r;
nuclear@2 445 cur_color.y = g;
nuclear@2 446 cur_color.z = b;
nuclear@2 447 cur_color.w = 1.0f;
nuclear@2 448 }
nuclear@2 449
nuclear@2 450 void gl_color4f(float r, float g, float b, float a)
nuclear@2 451 {
nuclear@2 452 cur_color.x = r;
nuclear@2 453 cur_color.y = g;
nuclear@2 454 cur_color.z = b;
nuclear@2 455 cur_color.w = a;
nuclear@2 456 }
nuclear@2 457
nuclear@2 458
nuclear@2 459 void gl_texcoord1f(float s)
nuclear@2 460 {
nuclear@2 461 cur_texcoord.x = s;
nuclear@2 462 cur_texcoord.y = 0.0f;
nuclear@2 463 }
nuclear@2 464
nuclear@2 465 void gl_texcoord2f(float s, float t)
nuclear@2 466 {
nuclear@2 467 cur_texcoord.x = s;
nuclear@2 468 cur_texcoord.y = t;
nuclear@2 469 }
nuclear@2 470
nuclear@2 471 void gl_vertex_attrib2f(int loc, float x, float y)
nuclear@2 472 {
nuclear@2 473 aloc = loc;
nuclear@2 474 cur_attrib.x = x;
nuclear@2 475 cur_attrib.y = y;
nuclear@2 476 cur_attrib.z = 0.0f;
nuclear@2 477 cur_attrib.w = 1.0f;
nuclear@2 478 }
nuclear@2 479
nuclear@2 480 void gl_vertex_attrib3f(int loc, float x, float y, float z)
nuclear@2 481 {
nuclear@2 482 aloc = loc;
nuclear@2 483 cur_attrib.x = x;
nuclear@2 484 cur_attrib.y = y;
nuclear@2 485 cur_attrib.z = z;
nuclear@2 486 cur_attrib.w = 1.0f;
nuclear@2 487 }
nuclear@2 488
nuclear@2 489 void gl_vertex_attrib4f(int loc, float x, float y, float z, float w)
nuclear@2 490 {
nuclear@2 491 aloc = loc;
nuclear@2 492 cur_attrib.x = x;
nuclear@2 493 cur_attrib.y = y;
nuclear@2 494 cur_attrib.z = z;
nuclear@2 495 cur_attrib.w = w;
nuclear@2 496 }