Changeset 9071 in orxonox.OLD for branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
- Timestamp:
- Jul 3, 2006, 10:23:35 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/terrain/src/lib/graphics/importer/terrain/terrain.cc
r8965 r9071 28 28 SDL_Surface *tmpData = IMG_Load( full.c_str() ); 29 29 if ( !tmpData ) { 30 PRINT F(0)( "I' sorry, I can't load %s\n", full.c_str() );30 PRINT(0)( "I' sorry, I can't load %s\n", full.c_str() ); 31 31 return; 32 32 } 33 33 if ( !validateSize( tmpData->h ) || !validateSize( tmpData->w ) ) { 34 PRINT F(0)( "The size of the elevation map must be 2^n+1x2^m+1. and at least 17x17" );34 PRINT(0)( "The size of the elevation map must be 2^n+1x2^m+1. and at least 17x17" ); 35 35 return; 36 36 } 37 37 if ( tmpData->format->BytesPerPixel != 1 ) { 38 PRINTF(0)( "The elevetation map must be an 8bit image!" ); 38 PRINT(0)( "The elevetation map must be an 8bit image not %d", 39 tmpData->format->BytesPerPixel*8 ); 39 40 return; 40 41 } … … 148 149 switch( _node->cull() ) { 149 150 case Frustum::INTERSECT: 150 //printf( "partially inside frustum\n" );151 151 if ( !_node->isChildless() ) { 152 152 pTerrainQuad *children = _node->getChildren(); … … 160 160 break; 161 161 case Frustum::INSIDE: 162 //printf( "fully inside frustum\n" );163 162 showPages( _node->getXOffset(), 164 163 _node->getZOffset(), … … 167 166 break; 168 167 case Frustum::OUTSIDE: 169 cullCount+= (_node->getWidth()-1)*(_node->getHeight()-1);170 168 break; 171 169 } … … 249 247 //Due to some reason, the OpenGL implementors chose the plane equation 250 248 //to an array of doubles. So we will make them happy. 251 double farPlane[] = { far.n.x, far.n.y, far.n.z, far.d };252 glEnable( GL_CLIP_PLANE0 );253 glClipPlane( GL_CLIP_PLANE0, farPlane );249 //double farPlane[] = { far.n.x, far.n.y, far.n.z, far.d }; 250 //glEnable( GL_CLIP_PLANE0 ); 251 //glClipPlane( GL_CLIP_PLANE0, farPlane ); 254 252 glPushAttrib( GL_ALL_ATTRIB_BITS ); 255 253 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); … … 273 271 //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); 274 272 cullCount = 0; 275 276 /*// Lets see which pages are visible.277 determineVisiblePages( root );278 int wantedLeft, wantedRight, wantedBottom, wantedTop, minLOD;279 pTerrainPage neighbor = NULL;280 page = activePages;281 bool dirty;282 current = 0;283 BufferInfo bi;284 broker->acquire( bi.vbIdentifier, bi.ibIdentifier );285 buffers.push_back( bi );286 int dirtyRounds = 0;287 do {288 dirtyRounds++;289 dirty = false;290 page = activePages;291 while ( page ) {292 if ( !page->isActive() ) {293 pTerrainPage tmp = page;294 page = tmp->getNext();295 tmp->setVisibility( false );296 continue;297 }298 wantedLeft = wantedRight = wantedBottom = wantedTop = page->getWantedLOD();299 if ( ( neighbor = page->getLeft() ) && ( neighbor->isActive() ) )300 wantedLeft = neighbor->getWantedLOD();301 if ( ( neighbor = page->getRight() ) && ( neighbor->isActive() ) )302 wantedRight = neighbor->getWantedLOD();303 if ( ( neighbor = page->getTop() ) && ( neighbor->isActive() ) )304 wantedTop = neighbor->getWantedLOD();305 if ( ( neighbor = page->getBottom() ) && ( neighbor->isActive() ) )306 wantedBottom = neighbor->getWantedLOD();307 308 minLOD = std::min( std::min( wantedBottom, wantedTop ),309 std::min( wantedLeft, wantedRight ) );310 if ( minLOD < page->getWantedLOD()-1 ) {311 page->setWantedLOD( minLOD+1 );312 dirty = true;313 }314 page = page->getNext();315 }316 } while ( dirty );317 318 page = activePages;319 while ( page ) {320 assert( page->isActive() );321 page->updateTesselation();322 page = page->getNext();323 }324 //If there is some data in the buffer, we need to upload the data325 //into the vram...326 if ( buffers[current].numIndices != 0 ) {327 BufferInfo bi = buffers[current];328 glBindBufferARB( GL_ARRAY_BUFFER_ARB, bi.vbIdentifier );329 glBufferDataARB( GL_ARRAY_BUFFER_ARB, MAX_VERTICES*sizeof( Vertex ),330 vertices, GL_DYNAMIC_DRAW_ARB );331 glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bi.ibIdentifier );332 glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, MAX_INDICES*sizeof( short ),333 indices, GL_DYNAMIC_DRAW_ARB );334 }*/335 273 glEnable( GL_BLEND ); 336 274 glDepthFunc( GL_LEQUAL ); … … 389 327 } 390 328 } 391 392 329 glClientActiveTextureARB( GL_TEXTURE1_ARB ); 393 330 glActiveTextureARB( GL_TEXTURE1_ARB ); … … 412 349 break; 413 350 case 2: 414 pixel = *(Uint16 *)p; 351 if ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) 352 pixel = p[0] << 8 | p[1]; 353 else 354 pixel = *(Uint16 *)p; 415 355 break; 416 356 case 3: … … 424 364 break; 425 365 default: 426 return 255; 366 return 255; /* shouldn't happen, but avoids warnings */ 427 367 } 428 368 Uint8 r,g,b,a;
Note: See TracChangeset
for help on using the changeset viewer.