Changeset 3089 in orxonox.OLD for orxonox/branches/images
- Timestamp:
- Dec 4, 2004, 11:09:25 PM (20 years ago)
- Location:
- orxonox/branches/images/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/images/importer/material.cc
r3088 r3089 394 394 if (map = SDL_LoadBMP(bmpName)) 395 395 { 396 397 glGenTextures( 1, texture ); 398 /* Typical Texture Generation Using Data From The Bitmap */ 399 glBindTexture( GL_TEXTURE_2D, *texture ); 400 401 /* Generate The Texture */ 402 glTexImage2D( GL_TEXTURE_2D, 0, 3, map->w, 403 map->h, 0, GL_BGR, 404 GL_UNSIGNED_BYTE, map->pixels ); 405 406 /* Linear Filtering */ 407 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 408 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 396 loadTexToGL (map->w, map->h, map->pixels, texture); 409 397 if ( map ) 410 398 SDL_FreeSurface( map ); … … 455 443 456 444 457 if(pImage == NULL) // If we can't load the file, quit!445 if(pImage == NULL) 458 446 exit(0); 459 460 // Generate a texture with the associative texture ID stored in the array 461 glGenTextures(1, texture); 462 463 // Bind the texture to the texture arrays index and init the texture 464 glBindTexture(GL_TEXTURE_2D, *texture); 465 466 // Build Mipmaps (builds different versions of the picture for distances - looks better) 467 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->sizeX, pImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pImage->data); 468 469 // Lastly, we need to tell OpenGL the quality of our texture map. GL_LINEAR_MIPMAP_LINEAR 470 // is the smoothest. GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, 471 // but looks blochy and pixilated. Good for slower computers though. 472 473 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); 474 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); 475 476 477 // Now we need to free the image data that we loaded since OpenGL stored it as a texture 478 479 if (pImage) // If we loaded the image 480 { 481 if (pImage->data) // If there is texture data 447 448 loadTexToGL (pImage->sizeX, pImage->sizeY, pImage->data, texture); 449 if (pImage) 450 { 451 if (pImage->data) 482 452 { 483 free(pImage->data); // Free the texture data, we don't need it anymore453 free(pImage->data); 484 454 } 485 455 486 free(pImage); // Free the image structure456 free(pImage); 487 457 } 488 458 return true; … … 528 498 } 529 499 500 bool Material::loadTexToGL (int hight, int width, void* rawImage, GLuint* texture) 501 { 502 glGenTextures(1, texture); 503 glBindTexture(GL_TEXTURE_2D, *texture); 504 /* not Working, and not needed. 505 glTexImage2D( GL_TEXTURE_2D, 0, 3, width, 506 height, 0, GL_BGR, 507 GL_UNSIGNED_BYTE, map->pixels ); 508 */ 509 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, hight, GL_RGB, GL_UNSIGNED_BYTE, rawImage); 510 511 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); 512 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); 513 514 515 } -
orxonox/branches/images/importer/material.h
r3087 r3089 71 71 int sizeX; 72 72 int sizeY; 73 unsigned char*data;73 GLubyte *data; 74 74 }; 75 75 … … 91 91 bool loadJPG (char* jpgName, GLuint* texture); 92 92 void decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData); 93 94 bool loadTexToGL (int hight, int width, void* rawImage, GLuint* texture); 93 95 }; 94 96 #endif
Note: See TracChangeset
for help on using the changeset viewer.