Changeset 438 for branches/thune

Show
Ignore:
Timestamp:
07/25/07 22:34:48 (16 months ago)
Author:
krobillard
Message:

GL - texture! make can now make GL_TEXTURE_1D from binary!.

Location:
branches/thune/thread_safe/gl
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/gl/draw_list.c

    r420 r438  
    11111111                    if( ur_dlGL(val) ) 
    11121112                    { 
     1113                        //printf( "call glGetError %d\n", glGetError() ); 
    11131114                        //if( ur_dlGL(val) != 1 ) 
    11141115                        //    printf( "KR list %d\n", ur_dlGL(val) ); 
  • branches/thune/thread_safe/gl/glfbo.c

    r310 r438  
    11/*============================================================================ 
    22    Thune Interpreter 
    3     Copyright (C) 2005-2006  Karl Robillard 
     3    Copyright (C) 2005-2007  Karl Robillard 
    44 
    55    This library is free software; you can redistribute it and/or 
  • branches/thune/thread_safe/gl/gllist.c

    r310 r438  
    11/*============================================================================ 
    22    Thune Interpreter 
    3     Copyright (C) 2005-2006  Karl Robillard 
     3    Copyright (C) 2005-2007  Karl Robillard 
    44 
    55    This library is free software; you can redistribute it and/or 
  • branches/thune/thread_safe/gl/gltex.c

    r310 r438  
    11/*============================================================================ 
    22    Thune Interpreter 
    3     Copyright (C) 2005-2006  Karl Robillard 
     3    Copyright (C) 2005-2007  Karl Robillard 
    44 
    55    This library is free software; you can redistribute it and/or 
     
    2121#include <assert.h> 
    2222#include <stdint.h> 
     23//#include <stdio.h> 
    2324 
    2425 
     
    125126            GLuint name = listBase + i; 
    126127            glDeleteTextures( 1, &name ); 
     128            //printf( "KR glDeleteTextures(1,%d)\n", name ); 
    127129        } 
    128130    } 
  • branches/thune/thread_safe/gl/gx.c

    r423 r438  
    15041504    FIXED_ATOM( "mag",      3, UR_ATOM_MAG ); 
    15051505    FIXED_ATOM( "mipmap",   6, UR_ATOM_MIPMAP ); 
     1506    FIXED_ATOM( "gray",     4, UR_ATOM_GRAY ); 
     1507    FIXED_ATOM( "rgb",      3, UR_ATOM_RGB ); 
     1508    FIXED_ATOM( "rgba",     4, UR_ATOM_RGBA ); 
    15061509 
    15071510    // Particles 
  • branches/thune/thread_safe/gl/gx_atoms.h

    r436 r438  
    3737#define UR_ATOM_MAG             352 
    3838#define UR_ATOM_MIPMAP          353 
     39#define UR_ATOM_GRAY            354 
     40#define UR_ATOM_RGB             344 
     41#define UR_ATOM_RGBA            345 
    3942#define UR_ATOM_ON              258 
    4043#define UR_ATOM_OFF             260 
    4144#define UR_ATOM_ADD             198 
    42 #define UR_ATOM_BURN            354 
    43 #define UR_ATOM_COLOR           355 
    44 #define UR_ATOM_TRANS           356 
    45 #define UR_ATOM_SPRITE          357 
     45#define UR_ATOM_BURN            355 
     46#define UR_ATOM_COLOR           356 
     47#define UR_ATOM_TRANS           357 
     48#define UR_ATOM_SPRITE          358 
  • branches/thune/thread_safe/gl/gx_dt.c

    r403 r438  
    11/*============================================================================ 
    22    Thune OpenGL Module 
    3     Copyright (C) 2005-2006  Karl Robillard 
     3    Copyright (C) 2005-2007  Karl Robillard 
    44 
    55    This library is free software; you can redistribute it and/or 
     
    305305static void _texCoord( TextureDef* tex, const UCell* cell ) 
    306306{ 
    307     tex->width  = cell->coord.elem[0]; 
    308     tex->height = cell->coord.elem[1]; 
     307    if( ur_is(cell, UT_COORD) ) 
     308    { 
     309        tex->width  = cell->coord.elem[0]; 
     310        tex->height = cell->coord.elem[1]; 
     311    } 
     312    else 
     313    { 
     314        tex->width  = ur_int(cell); 
     315        tex->height = 1; 
     316    } 
     317 
    309318    tex->pixels = 0; 
    310319    tex->comp   = 4; 
     
    327336 
    328337 
    329 // (texture! raster -- tex) 
    330 // (texture! coord  -- tex) 
    331 // (texture! [raster!/coord! 'mipmap 'nearest 'linear 'repeat 'clamp] -- tex) 
     338/* 
     339  (texture! raster -- tex) 
     340  (texture! coord  -- tex)    ; 2D Texture 
     341  (texture! int    -- tex)    ; 1D Texture 
     342  (texture! [raster!/coord!/int! 
     343             binary! 
     344             'mipmap 'nearest 'linear 'repeat 'clamp 
     345             'gray 'rgb' 'rgba ] -- tex) 
     346*/ 
    332347UR_CALL( make_texture ) 
    333348{ 
     
    337352    int mipmap = 0; 
    338353    UIndex rastN = 0; 
     354    GLenum target = GL_TEXTURE_2D; 
    339355    UCell* res = ur_s_prev(tos); 
    340356 
     
    353369        else if( ur_is(tos, UT_COORD) ) 
    354370        { 
     371            _texCoord( &def, tos ); 
     372            goto build; 
     373        } 
     374        else if( ur_is(tos, UT_INT) ) 
     375        { 
     376            target = GL_TEXTURE_1D; 
    355377            _texCoord( &def, tos ); 
    356378            goto build; 
     
    380402                            _texRast( &def, ur_rastHead(val) ); 
    381403                        }  
     404                        else if( ur_is(val, UT_BINARY) ) 
     405                        { 
     406                            def.pixels = ur_bin(val)->ptr.b; 
     407                        } 
    382408                        else if( ur_is(val, UT_COORD) ) 
    383409                        { 
     410                            _texCoord( &def, val ); 
     411                        } 
     412                        else if( ur_is(val, UT_INT) ) 
     413                        { 
     414                            target = GL_TEXTURE_1D; 
    384415                            _texCoord( &def, val ); 
    385416                        } 
     
    410441                                mipmap = 1; 
    411442                                break; 
     443 
     444                            case UR_ATOM_GRAY: 
     445                                def.comp   = 1; 
     446                                def.format = GL_LUMINANCE; 
     447                                break; 
     448 
     449                            case UR_ATOM_RGB: 
     450                                def.comp   = 3; 
     451                                def.format = GL_RGB; 
     452                                break; 
     453 
     454                            case UR_ATOM_RGBA: 
     455                                def.comp   = 4; 
     456                                def.format = GL_RGBA; 
     457                                break; 
    412458                        } 
     459                        break; 
     460 
     461                    case UT_INT: 
     462                        target = GL_TEXTURE_1D; 
     463                        _texCoord( &def, it ); 
    413464                        break; 
    414465 
     
    416467                        _texCoord( &def, it ); 
    417468                        break; 
     469 
     470                    case UT_BINARY: 
     471                        def.pixels = ur_bin(it)->ptr.b; 
    418472                } 
    419473                ++it; 
     
    431485 
    432486    name = gltex_alloc( &pool ); 
    433     glBindTexture( GL_TEXTURE_2D, name ); 
     487    glBindTexture( target, name ); 
    434488 
    435489    // TODO: Support texture type of GL_FLOAT. 
    436     if( mipmap ) 
    437     { 
    438         gluBuild2DMipmaps( GL_TEXTURE_2D, def.comp, def.width, def.height, 
    439                            def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     490 
     491    if( target == GL_TEXTURE_2D ) 
     492    { 
     493        if( mipmap ) 
     494        { 
     495            gluBuild2DMipmaps( GL_TEXTURE_2D, def.comp, def.width, def.height, 
     496                               def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     497        } 
     498        else 
     499        { 
     500            // Ensure that a non-mipmap minifying filter is used. 
     501            // Using a mipmap filter can cause FBO format errors and textures 
     502            // to not appear. 
     503            if( def.min_filter != GL_NEAREST ) 
     504                def.min_filter = GL_LINEAR; 
     505 
     506            glTexImage2D( GL_TEXTURE_2D, 0, def.comp, def.width, def.height, 
     507                          0, def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     508        } 
    440509    } 
    441510    else 
    442511    { 
    443         // Ensure that a non-mipmap minifying filter is used. 
    444         // Using a mipmap filter can cause FBO format errors and textures to 
    445         // not appear. 
    446         if( def.min_filter != GL_NEAREST ) 
    447             def.min_filter = GL_LINEAR; 
    448  
    449         glTexImage2D( GL_TEXTURE_2D, 0, def.comp, def.width, def.height, 0, 
    450                       def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     512        if( mipmap ) 
     513        { 
     514            gluBuild1DMipmaps( GL_TEXTURE_1D, def.comp, def.width, 
     515                               def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     516        } 
     517        else 
     518        { 
     519            if( def.min_filter != GL_NEAREST ) 
     520                def.min_filter = GL_LINEAR; 
     521 
     522            glTexImage1D( GL_TEXTURE_1D, 0, def.comp, def.width, 
     523                          0, def.format, GL_UNSIGNED_BYTE, def.pixels ); 
     524        } 
    451525    } 
    452526 
     
    464538 
    465539    // GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT. 
    466     glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, def.wrap ); 
    467     glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, def.wrap ); 
     540    glTexParameteri( target, GL_TEXTURE_WRAP_S, def.wrap ); 
     541    glTexParameteri( target, GL_TEXTURE_WRAP_T, def.wrap ); 
    468542 
    469543    // TODO: Support all GL_TEXTURE_MIN_FILTER types. 
    470544    // GL_NEAREST, GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, etc. 
    471     glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, def.min_filter ); 
     545    glTexParameteri( target, GL_TEXTURE_MIN_FILTER, def.min_filter ); 
    472546 
    473547    // GL_NEAREST, GL_LINEAR 
    474     glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, def.mag_filter ); 
     548    glTexParameteri( target, GL_TEXTURE_MAG_FILTER, def.mag_filter ); 
    475549 
    476550    ur_initType( res, UT_TEXTURE ); 
     
    522596    if( phase == UR_GC_PHASE_MARK ) 
    523597    { 
     598        // Clear any unchecked GL error. 
     599#ifdef DEBUG 
     600        GLenum err = glGetError(); 
     601        if( err ) 
     602            printf( "recycle_texture - glGetError() returned %d\n", err ); 
     603#else 
     604        glGetError(); 
     605#endif 
     606 
    524607        gllist_gcBegin(); 
    525608        gltex_gcBegin(); 
     
    9411024static int cmp_nop( UThread* ut, const UCell* a, const UCell* b, int mode ) 
    9421025{ 
     1026    (void) ut; 
     1027    (void) a; 
     1028    (void) b; 
     1029    (void) mode; 
    9431030    return 0; 
    9441031} 
  • branches/thune/thread_safe/gl/shader.c

    r399 r438  
    334334 
    335335                    case GL_SAMPLER_1D: 
     336                        glActiveTexture( GL_TEXTURE0 + texUnit ); 
     337                        glEnable( GL_TEXTURE_1D ); 
     338                        glBindTexture( GL_TEXTURE_1D, ur_texId(cval) ); 
     339                        glUniform1i( pi->location, texUnit ); 
     340                        ++texUnit; 
     341                        break; 
     342 
    336343                    case GL_SAMPLER_2D: 
    337                     case GL_SAMPLER_3D: 
    338344                        glActiveTexture( GL_TEXTURE0 + texUnit ); 
    339345                        glEnable( GL_TEXTURE_2D ); 
     
    342348                        ++texUnit; 
    343349                        break; 
     350 
     351                    //case GL_SAMPLER_3D: 
    344352                } 
    345353                ++pi; 
  • branches/thune/thread_safe/gl/testfw.t

    r436 r438  
    6666        script-file load context drop 
    6767    ] 
    68     [dup 'reload if/eq (drop recurse)] try 
     68    [dup 'reload if/eq (drop recurse) throw] try 
    6969] 
    7070proc :run-script     ; ( -- )