Show
Ignore:
Timestamp:
01/16/08 16:07:40 (1 year ago)
Author:
cneumann
Message:

changed: - factory functions return a TransitPtr? that can not be implicitly

converted to C Ptr. Should help with porting.

added: - GlobalRefPtr?, needed for cases where upon return from main

a RefPtr? goes out of scope (it would attempt to access the
FCFactory which is already shutdown at that point).

status: - vrml loader does not compile (needs porting to ref ptr)

  • tutorials compile, run and exit cleanly
  • multithreading and cluster are untested, yet
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Tutorials/22Shader.cpp

    r835 r1039  
    3131 
    3232// The SimpleSceneManager to manage simple applications 
    33 SimpleSceneManager *_mgr = NULL; 
    34 NodePtr _scene = NullFC
    35 SHLChunkPtr _shl = NullFC
     33SimpleSceneManager *_mgr  = NULL; 
     34NodeGlobalRefPtr     _scene
     35SHLChunkGlobalRefPtr _shl
    3636 
    3737// vertex shader program. 
     
    113113    static Real32 t = glutGet(GLUT_ELAPSED_TIME); 
    114114 
    115     Real32 td = (glutGet(GLUT_ELAPSED_TIME) - t) / 100.0f; 
     115     Real32 td = (glutGet(GLUT_ELAPSED_TIME) - t) / 100.0f; 
     116      
    116117    _shl->setUniformParameter("time", td); 
    117118 
     
    133134 
    134135    // create light 
    135     TransformPtr point1_trans; 
    136     PointLightPtr point1_core; 
    137     NodePtr point1 = makeCoredNode<PointLight>(&point1_core); 
    138     NodePtr point1_beacon = makeCoredNode<Transform>(&point1_trans); 
     136    TransformGlobalRefPtr point1_trans; 
     137    PointLightGlobalRefPtr point1_core; 
     138    NodeGlobalRefPtr point1 = makeCoredNode<PointLight>(&point1_core); 
     139    NodeGlobalRefPtr point1_beacon = makeCoredNode<Transform>(&point1_trans); 
    139140    point1_trans->editMatrix().setTranslate(0.0, 100.0, 0.0); 
    140141 
     
    146147 
    147148    // create bottom 
    148     NodePtr bottom = makePlane(50.0, 50.0, 128, 128); 
     149    NodeGlobalRefPtr bottom = makePlane(50.0, 50.0, 128, 128); 
    149150     
    150151    UChar8 imgdata[] = 
    151152        {  255,0,0,  0,255,0,  0,0,255, 255,255,0 }; 
    152     ImagePtr bottom_img = Image::create(); 
     153    ImageGlobalRefPtr bottom_img = Image::create(); 
    153154    bottom_img->set(Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata); 
    154155 
    155     TextureObjChunkPtr bottom_tex     = TextureObjChunk::create(); 
    156     TextureEnvChunkPtr bottom_tex_env = TextureEnvChunk::create(); 
     156    TextureObjChunkGlobalRefPtr bottom_tex     = TextureObjChunk::create(); 
     157    TextureEnvChunkGlobalRefPtr bottom_tex_env = TextureEnvChunk::create(); 
    157158 
    158159    bottom_tex->setImage(bottom_img); 
     
    163164    bottom_tex_env->setEnvMode(GL_MODULATE); 
    164165 
    165     SimpleMaterialPtr bottom_mat = SimpleMaterial::create(); 
     166    SimpleMaterialGlobalRefPtr bottom_mat = SimpleMaterial::create(); 
    166167    bottom_mat->setAmbient(Color3f(0.3,0.3,0.3)); 
    167168    bottom_mat->setDiffuse(Color3f(1.0,1.0,1.0)); 
     
    169170    bottom_mat->addChunk(bottom_tex_env); 
    170171     
    171     GeometryPtr bottom_geo = dynamic_cast<GeometryPtr>(bottom->getCore()); 
     172    GeometryGlobalRefPtr bottom_geo(dynamic_cast<GeometryPtr>(bottom->getCore())); 
    172173    bottom_geo->setMaterial(bottom_mat); 
    173174     
    174175    // rotate the bottom about 90 degree. 
    175     TransformPtr bottom_trans_core; 
    176     NodePtr bottom_trans = makeCoredNode<Transform>(&bottom_trans_core); 
     176    TransformGlobalRefPtr bottom_trans_core; 
     177    NodeGlobalRefPtr bottom_trans = makeCoredNode<Transform>(&bottom_trans_core); 
    177178    Quaternion q; 
    178179    q.setValueAsAxisDeg(1, 0, 0, -90); 
     
    181182 
    182183    // create a sphere. 
    183     NodePtr sphere = makeLatLongSphere(50, 50, 1.0); 
     184    NodeGlobalRefPtr sphere = makeLatLongSphere(50, 50, 1.0); 
    184185     
    185186    // create the shader material 
    186     ChunkMaterialPtr cmat = ChunkMaterial::create(); 
     187    ChunkMaterialGlobalRefPtr cmat = ChunkMaterial::create(); 
    187188    _shl = SHLChunk::create(); 
    188189    _shl->setVertexProgram(_vp_program); 
     
    198199    cmat->addChunk(_shl); 
    199200 
    200     GeometryPtr spheregeo = dynamic_cast<GeometryPtr>(sphere->getCore()); 
     201    GeometryGlobalRefPtr spheregeo(dynamic_cast<GeometryPtr>(sphere->getCore())); 
    201202    spheregeo->setMaterial(cmat); 
    202203 
     
    209210    // create ShadowViewport with a gradient background. 
    210211    //ShadowMapViewportPtr svp = ShadowMapViewport::create(); 
    211     GradientBackgroundPtr gbg = GradientBackground::create(); 
     212    GradientBackgroundGlobalRefPtr gbg = GradientBackground::create(); 
    212213 
    213214    gbg->addLine(Color3f(0.7, 0.7, 0.8), 0); 
     
    227228 
    228229    // the connection between GLUT and OpenSG 
    229     GLUTWindowPtr gwin= GLUTWindow::create(); 
     230    GLUTWindowGlobalRefPtr gwin = GLUTWindow::create(); 
    230231    gwin->setGlutId(winid); 
    231232    //gwin->addPort(svp); 
     
    290291    { 
    291292        case 27: 
     293            delete _mgr; 
     294         
    292295            OSG::osgExit(); 
    293296            exit(0);