root/trunk/orca/gl/dlist.c

Revision 86, 22.4 kB (checked in by krobillard, 3 years ago)

Added OR_NATIVE macros. The Qt and GL code now uses this macro.

Line 
1/*============================================================================
2    ORCA OpenGL Module
3    Copyright (C) 2005-2006  Karl Robillard
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18===========================================================================*/
19
20
21#include "gx.h"
22#include "os.h"
23#include "dlist.h"
24#include "cbparse.h"
25
26
27DrawListResource* createDrawList()
28{
29    DrawListResource* dr = memAlloc( sizeof(DrawListResource) );
30    if( dr )
31    {
32        dr->res.resType = RES_TYPE_DRAWLIST;
33        //dr->name        = 0;
34        dr->prog        = 0;
35        dr->argCtxHold  = OR_INVALID_HOLD;
36        dr->glist       = 0;
37        dr->glistCount  = 0;
38    }
39    return dr;
40}
41
42
43void clearDrawList( DrawListResource* dr )
44{
45    //if( dr->name )
46    //    memFree( dr->name );
47
48    if( dr->prog )
49    {
50        memFree( dr->prog );
51        dr->prog = 0;
52    }
53
54    if( orHoldIsValid(dr->argCtxHold) )
55    {
56        orRelease( dr->argCtxHold );
57        dr->argCtxHold = OR_INVALID_HOLD;
58    }
59
60    if( dr->glistCount )
61    {
62        glDeleteLists( dr->glist, dr->glistCount );
63        dr->glistCount = 0;
64    }
65}
66
67
68void destroyDrawList( Resource* res )
69{
70    if( res )
71    {
72        clearDrawList( (DrawListResource*) res );
73        memFree( res );
74    }
75}
76
77
78//----------------------------------------------------------------------------
79
80
81#define DLP_CALL_INT         0
82#define DLP_CALL_BLOCK       1
83#define DLP_PUSH_MATRIX      2
84#define DLP_PUSH             3
85#define DLP_POP              4
86#define DLP_TRANSLATE        5
87#define DLP_ROTATE           6
88#define DLP_SCALE            7
89#define DLP_COLOR_TUPLE      8
90#define DLP_PEN_PAIR         9
91#define DLP_PEN_CURRENT     10
92#define DLP_FONT            11
93#define DLP_TEXT_STR        12
94#define DLP_TEXT_VAL        13
95#define DLP_VERTS           14
96#define DLP_NORMALS         15
97#define DLP_COLORS          16
98#define DLP_UVS             17
99#define DLP_QUADS           18
100#define DLP_TRIS            19
101#define DLP_STRIP           20
102#define DLP_FAN             21
103#define DLP_POINTS          22
104#define DLP_LINES           23
105#define DLP_POINT_SIZE      24
106#define DLP_TEXTURE         25
107#define DLP_LIGHT_ON        26
108#define DLP_LIGHT_OFF       27
109#define DLP_LIGHT_VEC3      28
110
111
112static GLfloat _dlFloat( OValue* val )
113{
114    if( val->type == OT_DECIMAL )
115        return (GLfloat) orDecimal(val);
116    else if( val->type == OT_INTEGER )
117        return (GLfloat) orInt(val);
118    return 0.0f;
119}
120
121
122static RenderWord* _dlAddVec3( OArray* rarr, OValue* val )
123{
124    RenderWord* pc = ((RenderWord*) rarr->buf) + rarr->used;
125
126    if( val->type == OT_VEC3 )
127    {
128        pc[0].f = val->vec3.x;
129        pc[1].f = val->vec3.y;
130        pc[2].f = val->vec3.z;
131    }
132    else if( val->type == OT_DECIMAL )
133    {
134        GLfloat f = (GLfloat) orDecimal(val);
135        pc[0].f = pc[1].f = pc[2].f = f;
136    }
137    else if( val->type == OT_INTEGER )
138    {
139        GLfloat f = (GLfloat) orInt(val);
140        pc[0].f = pc[1].f = pc[2].f = f;
141    }
142
143    // RP_INC * 3
144    rarr->used += 3;
145    return pc + 3;
146}
147
148
149#define PRIM_KEY_END        0
150#define PRIM_KEY_VERTEX     1
151#define PRIM_KEY_NORMAL     2
152#define PRIM_KEY_COLOR      3
153#define PRIM_KEY_UV0        4
154#define PRIM_KEY_UV1        5
155#define PRIM_KEY_IGNORE     6
156
157
158/*
159   Returns zero if atom is bad.
160*/
161uint32_t mapPrimKey( const OAtom atom )
162{
163    uint32_t key = 0;
164    const char* cp = orAtomCString( atom );
165    const char* end;
166
167    end = cp;
168    while( *end )
169        ++end;
170
171    if( (end - cp) > 5 )
172        return 0;
173
174    // NOTE: Using '1' may be a problem since words cannot start with a digit.
175
176    while( cp != end )
177    {
178        --end;
179        switch( *end )
180        {
181            case 'v': key |= PRIM_KEY_VERTEX; key <<= 4; break;
182            case 'n': key |= PRIM_KEY_NORMAL; key <<= 4; break;
183            case 'c': key |= PRIM_KEY_COLOR;  key <<= 4; break;
184            case 't': key |= PRIM_KEY_UV0;    key <<= 4; break;
185            case '1': key |= PRIM_KEY_UV1;    key <<= 4; break;
186            case '-': key |= PRIM_KEY_IGNORE; key <<= 4; break;
187            default: return 0;
188        }
189    }
190
191    return key >> 4;
192}
193
194
195/*
196   Returns zero if successful or OValue where error occured.
197*/
198OValue* compileProg( OValue* it, OValue* end, OArray* prog )
199{
200    CBParser cbp;
201    OValue* val;
202    OValue* match;
203    RenderWord* pc;
204
205
206#define RP_INC \
207    ++pc; \
208    ++prog->used
209
210#if defined(__BIG_ENDIAN__)
211#define RP_ADD(op) \
212    pc->list = op << 24; \
213    RP_INC
214#else
215#define RP_ADD(op) \
216    pc->list = op; \
217    RP_INC
218#endif
219
220#define RP_ADD_ARG(oa,ra,aa) \
221    pc->ins.op  = oa; \
222    pc->ins.ref = ra; \
223    pc->ins.arg = aa; \
224    RP_INC
225
226#define RP_ADD_FLOAT(val) \
227    pc->f = _dlFloat(val); \
228    RP_INC
229
230#define RP_ADD_VEC3(val)    pc = _dlAddVec3(prog,val)
231
232
233    cbp_beginParse( &cbp, it, end, orBLOCKS + gEnv.drawListDialectBlkN );
234    while( (match = cbp_matchRule( &cbp )) )
235    {
236        // Reserve enough space for largest instruction + ROP_END.
237        orArrayReserve( prog, sizeof(RenderWord), prog->used + 6 );
238        pc = ((RenderWord*) prog->buf) + prog->used;
239
240        switch( orInt(match) )
241        {
242            case DLP_CALL_INT:
243                RP_ADD( ROP_GL_CALL );
244                pc->list = cbp.values[1].integer;
245                RP_INC;
246                break;
247
248            case DLP_CALL_BLOCK:
249                RP_ADD( ROP_GL_CALL );
250                //val = cbp.values + 1;
251                pc->list = 0; //compileList( orBLOCK(val), 0 );
252                RP_INC;
253                break;
254
255            case DLP_PUSH_MATRIX:
256                // TODO: Hold matrix string.
257                RP_ADD( ROP_GL_MULT_MATRIX );
258                pc->list = cbp.values[1].index;
259                RP_INC;
260                break;
261
262            case DLP_PUSH:
263                RP_ADD( ROP_GL_PUSH );
264                break;
265
266            case DLP_POP:
267                RP_ADD( ROP_GL_POP );
268                break;
269
270            case DLP_TRANSLATE:
271                RP_ADD( ROP_GL_TRANSLATE );
272                RP_ADD_VEC3( cbp.values + 1 );
273                break;
274
275            case DLP_ROTATE:
276                RP_ADD( ROP_GL_ROTATE );
277                RP_ADD_FLOAT( cbp.values + 1 );
278                RP_ADD_VEC3( cbp.values + 2 );
279                break;
280
281            case DLP_SCALE:
282                RP_ADD( ROP_GL_SCALE );
283                RP_ADD_VEC3( cbp.values + 1 );
284                break;
285
286            case DLP_COLOR_TUPLE:
287                val = cbp.values;
288                if( val->argc > 3 )
289                {
290                    RP_ADD( ROP_GL_COLOR4 );
291                    pc->color.a = val->tuple[3];
292                }
293                else
294                {
295                    RP_ADD( ROP_GL_COLOR3 );
296                    pc->color.a = 0;
297                }
298                pc->color.r = val->tuple[0];
299                pc->color.g = val->tuple[1];
300                pc->color.b = val->tuple[2];
301                RP_INC;
302                /*
303                printf( "KR color %d.%d.%d\n",
304                        (int) val->tuple[0],
305                        (int) val->tuple[1],
306                        (int) val->tuple[2] );
307                */
308                break;
309
310            case DLP_PEN_PAIR:
311                RP_ADD( ROP_PEN );
312                val = cbp.values + 1;
313                pc->f = (GLfloat) val->pair[0];
314                RP_INC;
315                pc->f = (GLfloat) val->pair[1];
316                RP_INC;
317                break;
318
319            case DLP_PEN_CURRENT:
320                RP_ADD( ROP_PEN );
321                pc->f = gEnv.state.penX;
322                RP_INC;
323                pc->f = gEnv.state.penY;
324                RP_INC;
325                break;
326
327            case DLP_FONT:
328                RP_ADD( ROP_FONT );
329                val = cbp.values + 1;
330                pc->list = gxHashString( val );
331                RP_INC;
332                break;
333
334            case DLP_TEXT_STR:
335                // TODO: Hold string.
336                RP_ADD_ARG( ROP_TEXT, 0, cbp.values[1].series.it );
337                pc->list = cbp.values[1].index;
338                RP_INC;
339                break;
340
341            case DLP_TEXT_VAL:
342                // TODO: Hold context.
343                RP_ADD_ARG( ROP_TEXT_VAL, 0, cbp.values[1].word.index );
344                pc->list = cbp.values[1].word.context;
345                RP_INC;
346                break;
347
348            case DLP_VERTS:
349                // TODO: Hold block.
350                RP_ADD_ARG( ROP_VERTS, 0, cbp.values[1].series.it );
351                pc->list = cbp.values[1].index;
352                RP_INC;
353                break;
354
355            case DLP_NORMALS:
356                // TODO: Hold block.
357                RP_ADD_ARG( ROP_NORMALS, 0, cbp.values[1].series.it );
358                pc->list = cbp.values[1].index;
359                RP_INC;
360                break;
361
362            case DLP_COLORS:
363                // TODO: Hold block.
364                RP_ADD_ARG( ROP_COLORS, 0, cbp.values[1].series.it );
365                pc->list = cbp.values[1].index;
366                RP_INC;
367                break;
368
369            case DLP_UVS:
370                // TODO: Hold block.
371                RP_ADD_ARG( ROP_UVS, 0, cbp.values[1].series.it );
372                pc->list = cbp.values[1].index;
373                RP_INC;
374                break;
375
376            case DLP_QUADS:
377                // TODO: Hold block.
378                RP_ADD_ARG( ROP_QUADS, 0, cbp.values[2].series.it );
379                pc->list = cbp.values[2].index;
380                RP_INC;
381                pc->list = mapPrimKey( cbp.values[1].word.atom );
382                RP_INC;
383                break;
384
385            case DLP_TRIS:
386                // TODO: Hold block.
387                RP_ADD_ARG( ROP_TRIS, 0, cbp.values[2].series.it );
388                pc->list = cbp.values[2].index;
389                RP_INC;
390                pc->list = mapPrimKey( cbp.values[1].word.atom );
391                RP_INC;
392                break;
393
394            case DLP_STRIP:
395                // TODO: Hold block.
396                RP_ADD_ARG( ROP_TRISTRIP, 0, cbp.values[2].series.it );
397                pc->list = cbp.values[2].index;
398                RP_INC;
399                pc->list = mapPrimKey( cbp.values[1].word.atom );
400                RP_INC;
401                break;
402
403            case DLP_FAN:
404                // TODO: Hold block.
405                RP_ADD_ARG( ROP_TRIFAN, 0, cbp.values[2].series.it );
406                pc->list = cbp.values[2].index;
407                RP_INC;
408                pc->list = mapPrimKey( cbp.values[1].word.atom );
409                RP_INC;
410                break;
411
412            case DLP_POINTS:
413                // TODO: Hold block.
414                RP_ADD_ARG( ROP_POINTS, 0, cbp.values[2].series.it );
415                pc->list = cbp.values[2].index;
416                RP_INC;
417                pc->list = mapPrimKey( cbp.values[1].word.atom );
418                RP_INC;
419                break;
420
421            case DLP_LINES:
422                // TODO: Hold block.
423                RP_ADD_ARG( ROP_LINES, 0, cbp.values[2].series.it );
424                pc->list = cbp.values[2].index;
425                RP_INC;
426                pc->list = mapPrimKey( cbp.values[1].word.atom );
427                RP_INC;
428                break;
429
430            case DLP_POINT_SIZE:
431                RP_ADD( ROP_POINT_SIZE );
432                RP_ADD_FLOAT( cbp.values + 1 );
433                break;
434
435            case DLP_TEXTURE:
436                RP_ADD_ARG( ROP_TEXTURE, cbp.values[1].integer, 0 );
437                pc->list = gxLoadTexture( cbp.values + 2 );
438                RP_INC;
439                break;
440
441            case DLP_LIGHT_ON:     
442                RP_ADD_ARG( ROP_LIGHT_ENABLE, cbp.values[1].integer, 1 );
443                break;
444
445            case DLP_LIGHT_OFF:
446                RP_ADD_ARG( ROP_LIGHT_ENABLE, cbp.values[1].integer, 0 );
447                break;
448
449            case DLP_LIGHT_VEC3:   
450                RP_ADD_ARG( ROP_LIGHT_POS, cbp.values[1].integer, 0 );
451                RP_ADD_VEC3( cbp.values + 2 );
452                pc->f = 0.0f;
453                RP_INC;
454                break;
455        }
456    }
457
458    if( ! cbp.error )
459    {
460        RP_ADD( ROP_END );
461    }
462
463    return cbp.error;
464}
465
466
467#if 0
468static OValue* compileList( OBlock* blk, GLuint list )
469{
470    OValue* err;
471    OArray prog;
472    orArrayInit( &prog, sizeof(RenderWord), blk->used );
473
474    err = compileProg( blk, &prog );
475    if( ! err )
476    {
477        //list = glGenLists( 1 );
478        glNewList( list, GL_COMPILE );
479        gxRunRenderProgram( (RenderWord*) prog.buf );
480        glEndList();
481    }
482
483    orArrayFree( &prog );
484    return err;
485}
486#endif
487
488
489/*
490   Compile render program.
491*/
492OR_NATIVE_PUB( renderProgramNative )
493{
494    OValue* error;
495    DrawListResource* res;
496    OArray prog;
497    OBlock* blk;
498    OValue* a2 = a1 + 1;
499
500
501    {
502    uint32_t key;
503    if( a1->type == OT_RESOURCE )
504    {
505        if( gxResType(a1) != RES_TYPE_DRAWLIST )
506        {
507            orError("render-prog passed bad resource type (%d)", gxResType(a1));
508            return;
509        }
510        key = orInt(a1);
511    }
512    else
513    {
514        key = gxHashString(a1);
515    }
516
517    res = gxDList( key );
518    if( res )
519    {
520        clearDrawList( res );
521    }
522    else
523    {
524        res = createDrawList();
525        resd_add( &gEnv.resd, &res->res, key );
526    }
527    }
528
529
530    blk = orBLOCK(a2);
531    orArrayInit( &prog, sizeof(RenderWord), orSeriesLen(blk,a2) );
532
533    error = compileProg( blk->values + a2->series.it,
534                         blk->values + blk->used, &prog );
535    if( error )
536    {
537        orArrayFree( &prog );
538
539        orError( "render-prog invalid" );
540        orSetErrorLoc( a2->index, error - blk->values );
541        return;
542    }
543
544    res->prog = (RenderWord*) prog.buf;
545    gxResultRES( res )
546}
547
548
549//----------------------------------------------------------------------------
550
551
552extern void getVector( int count, OValue* val, GLdouble* vec );
553
554static void makePrims( OValue* idx, OValue* end, uint32_t primKey )
555{
556    GLdouble vec[3];
557    uint32_t itype;
558    int vindex;
559
560    if( ! primKey )
561        return;
562
563    itype = primKey;
564
565    while( idx != end )
566    {
567        // Silently skip non-integers.
568        // This allows us to mix other data with the indices.
569
570        if( idx->type == OT_INTEGER )
571        {
572            switch( itype & 0x0f )
573            {
574                case PRIM_KEY_VERTEX:
575                    vindex = orInt(idx) * 3;
576                    getVector( 3, gEnv.state.vertVals + vindex, vec );
577                    glVertex3dv( vec );
578                    //printf( "KR vert %g %g %g\n", vec[0], vec[1], vec[2] );
579                    break;
580
581                case PRIM_KEY_NORMAL:
582                    vindex = orInt(idx) * 3;
583                    getVector( 3, gEnv.state.normVals + vindex, vec );
584                    glNormal3dv( vec );
585                    //printf( "KR norm %g %g %g\n", vec[0], vec[1], vec[2] );
586                    break;
587
588                case PRIM_KEY_COLOR:
589                {
590                    OValue* cval = gEnv.state.colorVals + orInt(idx);
591                    if( orIs(cval, OT_TUPLE) )
592                    {
593                        if( cval->argc > 3 )
594                            glColor4ubv( cval->tuple );
595                        else
596                            glColor3ubv( cval->tuple );
597                    }
598                }
599                    break;
600
601                case PRIM_KEY_UV0:
602                    vindex = orInt(idx) * 2;
603                    getVector( 2, gEnv.state.uvVals + vindex, vec );
604                    //printf( "KR UV0 %g %g\n", vec[0], vec[1] );
605                    glTexCoord2dv( vec );
606                    //gleMultiTexCoord2dARB( GL_TEXTURE0_ARB, vec[0], vec[1] );
607                    break;
608
609                case PRIM_KEY_UV1:
610                    break;
611
612                case PRIM_KEY_IGNORE:
613                    break;
614            }
615
616            itype >>= 4;
617            if( itype == PRIM_KEY_END )
618                itype = primKey;
619        }
620
621        ++idx;
622    }
623}
624
625
626static GLenum _beginMode[4] =
627{
628    GL_QUADS, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN
629};
630
631
632static void makePoints( OValue* idx, OValue* end, uint32_t primKey )
633{
634    glDisable( GL_LIGHTING );
635    glEnable( GL_POINT_SMOOTH );
636    glEnable( GL_BLEND );
637    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
638
639    glBegin( GL_POINTS );
640    makePrims( idx, end, primKey );
641    glEnd();
642}
643
644
645#if 0
646static GLfloat* color3f( GLubyte* rgb )
647{
648    static GLfloat color[3];
649
650    color[0] = ((GLfloat) *rgb++) / 255.0f;
651    color[1] = ((GLfloat) *rgb++) / 255.0f;
652    color[2] = ((GLfloat) *rgb  ) / 255.0f;
653
654    printf( "KR col3 %g %g %g\n", color[0], color[1], color[2] );
655    return color;
656}
657#endif
658
659
660void gxRunRenderProgram( RenderWord* pc )
661{
662    while( 1 )
663    {
664        switch( pc->ins.op )
665        {
666            case ROP_NOP:
667                break;
668
669            case ROP_GL_PUSH:
670                glPushMatrix();
671                break;
672
673            case ROP_GL_POP:
674                glPopMatrix();
675                break;
676
677            case ROP_GL_MULT_MATRIX:
678            {
679                OString* bin;
680                ++pc;
681                bin = orSTRINGS + pc->list;
682                glPushMatrix();
683                glMultMatrixf( bin->floats );
684            }
685                break;
686
687            case ROP_GL_LOAD_MATRIX:
688                glPushMatrix();
689                //glLoadMatrix();
690                break;
691
692            case ROP_GL_CALL:
693                ++pc;
694                glCallList( pc->list );
695                break;
696
697            case ROP_GL_TRANSLATE:
698                glTranslatef( pc[1].f, pc[2].f, pc[3].f );
699                pc += 3;
700                break;
701
702            case ROP_GL_ROTATE:
703                glRotatef( pc[1].f, pc[2].f, pc[3].f, pc[4].f );
704                pc += 4;
705                break;
706
707            case ROP_GL_SCALE:
708                glScalef( pc[1].f, pc[2].f, pc[3].f );
709                pc += 3;
710                break;
711
712            case ROP_GL_COLOR3:
713                ++pc;
714                /*
715                if( gEnv.state.stateId == GRS_MODEL )
716                    glMaterialfv(GL_FRONT, GL_DIFFUSE, color3f((GLubyte*)pc));
717                else
718                */
719                glColor3ubv( (GLubyte*) pc );
720                break;
721
722            case ROP_GL_COLOR4:
723                ++pc;
724                glColor4ubv( (GLubyte*) pc );
725                break;
726
727            case ROP_LOD:
728                break;
729
730            case ROP_PEN:
731                gxSetPen( pc[1].f, pc[2].f );
732                pc += 2;
733                break;
734
735            case ROP_FONT:
736                ++pc;
737                gEnv.state.fontKey = pc->list;
738                break;
739
740            case ROP_TEXT:
741            {
742                OString* str = orSTRINGS + pc[1].list;
743                FontResource* fnt = gxFont( gEnv.state.fontKey );
744                if( fnt )
745                {
746                    gxDrawText( fnt, str->charArray + pc->ins.arg,
747                                     str->charArray + str->used );
748                }
749                ++pc;
750            }
751                break;
752
753            case ROP_TEXT_VAL:
754            {
755                OBlock* ctx = orBlockPtr( pc[1].list );
756                FontResource* fnt = gxFont( gEnv.state.fontKey );
757                if( fnt )
758                {
759                    gxDrawTextValue( fnt, ctx->values + pc->ins.arg );
760                }
761                ++pc;
762            }
763                break;
764
765            case ROP_SHADER:
766                break;
767
768            case ROP_VERTS:
769            {
770                OBlock* blk = orBLOCKS + pc[1].list;
771                gEnv.state.vertVals = blk->values + pc->ins.arg;
772                ++pc;
773            }
774                break;
775
776            case ROP_NORMALS:
777            {
778                OBlock* blk = orBLOCKS + pc[1].list;
779                gEnv.state.normVals = blk->values + pc->ins.arg;
780                ++pc;
781            }
782                break;
783
784            case ROP_COLORS:
785            {
786                OBlock* blk = orBLOCKS + pc[1].list;
787                gEnv.state.colorVals = blk->values + pc->ins.arg;
788                ++pc;
789            }
790                break;
791
792            case ROP_UVS:
793            {
794                OBlock* blk = orBLOCKS + pc[1].list;
795                gEnv.state.uvVals = blk->values + pc->ins.arg;
796                ++pc;
797            }
798                break;
799
800            case ROP_QUADS:
801            case ROP_TRIS:
802            case ROP_TRISTRIP:
803            case ROP_TRIFAN:
804            {
805                OBlock* blk = orBLOCKS + pc[1].list;
806                glBegin( _beginMode[ pc->ins.op - ROP_QUADS ] );
807                makePrims( blk->values + pc->ins.arg,
808                           blk->values + blk->used,
809                           pc[2].list );
810                glEnd();
811                pc += 2;
812            }
813                break;
814
815            case ROP_POINTS:
816            {
817                OBlock* blk = orBLOCKS + pc[1].list;
818                makePoints( blk->values + pc->ins.arg,
819                            blk->values + blk->used,
820                            pc[2].list );
821                pc += 2;
822            }
823                break;
824
825            case ROP_LINES:
826                break;
827
828            case ROP_POINT_SIZE:
829                ++pc;
830                glPointSize( pc->f );
831                break;
832
833            case ROP_TEXTURE:
834                //gleActiveTextureARB( GL_TEXTURE0_ARB + pc->ins.ref );
835                ++pc;
836                glEnable( GL_TEXTURE_2D );
837                glBindTexture( GL_TEXTURE_2D, pc->list );
838                break;
839
840            case ROP_LIGHT_ENABLE:
841                if( pc->ins.arg )
842                    glEnable( GL_LIGHT0 + pc->ins.ref );
843                else
844                    glDisable( GL_LIGHT0 + pc->ins.ref );
845                break;
846
847            case ROP_LIGHT_POS:
848                //printf( "KR light pos %g %g %g\n", pc[1].f,pc[2].f,pc[3].f );
849                glLightfv( GL_LIGHT0 + pc->ins.ref, GL_POSITION, &pc[1].f );
850                pc += 4;
851                break;
852
853            case ROP_END:
854                return;
855
856            default:
857                dprint( "Unknown Opcode %d\n", pc->ins.op );
858                return;
859        }
860        ++pc;
861    }
862}
863
864
865//EOF
Note: See TracBrowser for help on using the browser.