void DrawStuff(){ glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(0, 0, -50); glRotatef(-45, 0, 1, 0); glRotatef(45, 1, 0, 0); glTranslatef(0, 0, 50); if (textured){ if (image1){ texData = tgaLoad("tardis.tga"); } else { texData = tgaLoad("gmDoor.tga"); } glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName); glTexImage2D(GL_TEXTURE_2D, 0, 3, texData->width, texData->height, 0, GL_RGB, GL_UNSIGNED_BYTE, texData->imageData); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); } glBegin(GL_QUADS); //Front glTexCoord2f(xMin, yMin); glVertex3f(-10.0, -10.0, -50.0); glTexCoord2f(xMax, yMin); glVertex3f(10.0, -10.0, -50.0); glTexCoord2f(xMax, yMax); glVertex3f(10.0, 10.0, -50.0); glTexCoord2f(xMin, yMax); glVertex3f(-10.0, 10.0, -50.0); //Right glTexCoord2f(xMin, yMin); glVertex3f(10.0, -10.0, -50.0); glTexCoord2f(xMax, yMin); glVertex3f(10.0, -10.0, -70.0); glTexCoord2f(xMax, yMax); glVertex3f(10.0, 10.0, -70.0); glTexCoord2f(xMin, yMax); glVertex3f(10.0, 10.0, -50.0); //Back glTexCoord2f(xMin, yMin); glVertex3f(10.0, -10.0, -70.0); glTexCoord2f(xMax, yMin); glVertex3f(-10.0, -10.0, -70.0); glTexCoord2f(xMax, yMax); glVertex3f(-10.0, 10.0, -70.0); glTexCoord2f(xMin, yMax); glVertex3f(10.0, 10.0, -70.0); //Left glTexCoord2f(xMin, yMin); glVertex3f(-10.0, -10.0, -70.0); glTexCoord2f(xMax, yMin); glVertex3f(-10.0, -10.0, -50.0); glTexCoord2f(xMax, yMax); glVertex3f(-10.0, 10.0, -50.0); glTexCoord2f(xMin, yMax); glVertex3f(-10.0, 10.0, -70.0); //Top glTexCoord2f(xMin, yMin); glVertex3f(-10.0, 10.0, -50.0); glTexCoord2f(xMax, yMin); glVertex3f(10.0, 10.0, -50.0); glTexCoord2f(xMax, yMax); glVertex3f(10.0, 10.0, -70.0); glTexCoord2f(xMin, yMax); glVertex3f(-10.0, 10.0, -70.0); //Bottom glTexCoord2f(xMin, yMin); glVertex3f(-10.0, -10.0, -50.0); glTexCoord2f(xMax, yMin); glVertex3f(-10.0, -10.0, -70.0); glTexCoord2f(xMax, yMax); glVertex3f(10.0, -10.0, -70.0); glTexCoord2f(xMin, yMax); glVertex3f(10.0, -10.0, -50.0); glEnd(); glPopMatrix(); }
void loadSkyboxTextures(void) { char *impathfile[6] = { "textures/front.tga", "textures/back.tga", "textures/right.tga", "textures/left.tga", "textures/top.tga", "textures/bottom.tga" }; int i; // Carrega as imagens de textura da skybox for (i = 0; i<6; i++) { im2[i] = tgaLoad(impathfile[i]); //printf("IMAGE INFO: %s\nstatus: %d\ntype: %d\npixelDepth: %d\nsize%d x %d\n", impathfile[i], im2[i]->status, im2[i]->type, im2[i]->pixelDepth, im2[i]->width, im2[i]->height); fflush(stdout); } for (i = 0; i<6; i++) { // Selecciona uma textura glBindTexture(GL_TEXTURE_2D, skyboxtextures[i]); // Impede a existência de "bordas" entre as texturas glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // MIPMAP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // build our texture mipmaps gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im2[i]->width, im2[i]->height, GL_RGB, GL_UNSIGNED_BYTE, im2[i]->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, im2[i]->width, im2[i]->height, 0, GL_RGB, GL_UNSIGNED_BYTE, im2[i]->imageData); } // Destroi as imagens for (i = 0; i<6; i++) tgaDestroy(im2[i]); }
void init(void) { glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glEnable ( GL_COLOR_MATERIAL ); glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE ); glEnable ( GL_TEXTURE_2D ); glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ); glGenTextures (3, texture_id); image_t temp_image; glBindTexture ( GL_TEXTURE_2D, texture_id [0] ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); tgaLoad ( "CRATE.tga", &temp_image, TGA_FREE | TGA_LOW_QUALITY ); glBindTexture ( GL_TEXTURE_2D, texture_id [1] ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); tgaLoad ( "CRATE.tga", &temp_image, TGA_FREE | TGA_LOW_QUALITY ); glBindTexture ( GL_TEXTURE_2D, texture_id [2] ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST ); tgaLoad ( "CRATE.tga", &temp_image, TGA_FREE | TGA_LOW_QUALITY ); glEnable ( GL_CULL_FACE ); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light glEnable(GL_LIGHT1); // Enable Light One }
static bool checkForTexture(const string &pathName, const string &fileName, image_t *texture) { if (fileName.size()) { string fullPath = string(pathName + fileName); tgaLoad(fullPath.c_str(), texture, TGA_DEFAULT); if (texture != NULL) return true; } return false; }
void CCTileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); // //Find the path of the file // NSBundle *mainBndl = [CCDirector sharedDirector].loadingBundle; // CCString *resourcePath = [mainBndl resourcePath]; // CCString * path = [resourcePath stringByAppendingPathComponent:file]; m_pTGAInfo = tgaLoad( CCFileUtils::fullPathFromRelativePath(file) ); #if 1 if( m_pTGAInfo->status != TGA_OK ) { CCAssert(0, "TileMapAtlasLoadTGA : TileMapAtas cannot load TGA file"); } #endif }
void TileMapAtlas::loadTGAfile(const std::string& file) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(file); // //Find the path of the file // NSBundle *mainBndl = [Director sharedDirector].loadingBundle; // String *resourcePath = [mainBndl resourcePath]; // String * path = [resourcePath stringByAppendingPathComponent:file]; _TGAInfo = tgaLoad( fullPath.c_str() ); #if 1 if( _TGAInfo->status != TGA_OK ) { CCASSERT(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file"); } #endif }
void loadTex(char * pstrName) { image_t temp_image; tgaLoad ( pstrName, &temp_image, TGA_DEFAULT); glGenTextures(1, &tex[demoId]); glBindTexture(GL_TEXTURE_2D, tex[demoId]); glTexImage2D(GL_TEXTURE_2D, 0, 4, temp_image.info.width, temp_image.info.height, 0, GL_RGB, GL_UNSIGNED_BYTE, temp_image.data); GLfloat color[4]; color[0] = 1.0f, color[1] = 0.0f, color[2] = 1.0f, color[3] = 0.5f; glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); }
void load_tga_image(std::string nome, GLuint texture, bool transparency) { std::string impathfile = "textures/" + nome + ".tga"; std::vector<char> writable(impathfile.begin(), impathfile.end()); writable.push_back('\0'); // Carrega a imagem de textura im = tgaLoad(&writable[0]); //printf("IMAGE INFO: %s\nstatus: %d\ntype: %d\npixelDepth: %d\nsize%d x %d\n", impathfile, im->status, im->type, im->pixelDepth, im->width, im->height); // Seleciona a textura atual glBindTexture(GL_TEXTURE_2D, texture); // set up quadric object and turn on FILL draw style for it mysolid = gluNewQuadric(); gluQuadricDrawStyle(mysolid, GLU_FILL); // turn on texture coordinate generator for the quadric gluQuadricTexture(mysolid, GL_TRUE); // select modulate to mix texture with color for shading glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // MIPMAP glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // build our texture mipmaps if (!transparency){ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im->width, im->height, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, im->width, im->height, 0, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); } else{ //Textura com transparência (anéis de saturno) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, im->width, im->height, GL_RGB, GL_UNSIGNED_BYTE, im->imageData); // MIPMAP glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, im->width, im->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, im->imageData); } // Destroi a imagem tgaDestroy(im); }
void TileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(file); // //Find the path of the file // NSBundle *mainBndl = [Director sharedDirector].loadingBundle; // String *resourcePath = [mainBndl resourcePath]; // String * path = [resourcePath stringByAppendingPathComponent:file]; _TGAInfo = tgaLoad( fullPath.c_str() ); #if 1 if( _TGAInfo->status != TGA_OK ) { CCAssert(0, "TileMapAtlasLoadTGA : TileMapAtlas cannot load TGA file"); } #endif }
Image::Image(string filename, int length, int width, int xPos, int yPos){ glEnable(GL_DEPTH_TEST); glGenTextures(1, texName); pic = tgaLoad((char *)filename.c_str()); glBindTexture(GL_TEXTURE_2D,texName[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER ,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER ,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pic->width, pic->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pic->imageData); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, 0); this->x=xPos; this->y=yPos; this->width=width; this->length=length; }
/******************************************************************************* Function: textureLoadFromImage Usage: extureLoadFromImage(char *filename, int normals) --------------------------------------------------------------------------- Extracts the image data pixels *******************************************************************************/ int pixelLoadFromImage(char *filename, int normals) { int mode; float pointHeight; // load the image, using the tgalib info = tgaLoad(filename); // check to see if the image was properly loaded // remember: only greyscale, RGB or RGBA noncompressed images mode = 1; if (info->status != TGA_OK) { printf("Error loading texture map \n"); mode = 0; } return(mode); }
bool tgaReadImage(const std::string &file, U8 *&bitmap, glm::ivec2 &dims, BitmapTexture::Format &format) { tgaInfo *info = tgaLoad(file.c_str()); if (info == NULL) { return false; } if (info->status != TGA_OK) { tgaDestroy(info); IO::printf("Error reading TGA: %d", info->status); return false; } dims.x = info->width; dims.y = info->height; format = (info->pixelDepth == 24 ? BitmapTexture::FormatRGB8 : BitmapTexture::FormatRGBA8); bitmap = new U8[info->width * info->height * (info->pixelDepth / 8)]; memcpy(bitmap, info->imageData, info->width * info->height * (info->pixelDepth / 8)); tgaDestroy(info); return true; }
void LoadTextures() { image_t temp; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D,texture); tgaLoad("texture.tga", &temp, TGA_DEFAULT); }
bool objects_init(Map_Settings mSettings) { // Load_Menu_Textures(); SDL_ShowCursor(false); char szfm1path[256]; char szobjpath[256]; char sztexpath[256]; /* chemins vers les objets 3D */ strcpy(szobjpath, g_exepath); strcat(szobjpath, "objects"PATHDELIM_S); /* chemins vers les textures */ strcpy(sztexpath, g_exepath); strcat(sztexpath, "textures"PATHDELIM_S); /* chargement d'un objet Graine */ g_ObjsSeed = new C3DObjElements ; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"seed.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsSeed->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsSeed->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, &g_matDefault); g_ObjsSeed->m_lowRes = 0 ; /* chargement d'un objet Fourmi Récolteuse générique */ g_ObjsHarvester = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"minor.fm1"); if (!C3DObjLoader::Load3d(szfm1patPATHDELIMh,&g_ObjsHarvester->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsHarvester->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, &g_matSeed); /* chargement d'un objet Fourmi Récolteuse générique */ strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"minor-lowres.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsHarvester->m_lowRes, AnimNameUID, ObjNameUID)) return false; g_ObjsHarvester->m_lowRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); /* chargement d'un objet Herbe Type 1 */ g_ObjsWeed1 = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"weed1.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsWeed1->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsWeed1->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsWeed1->m_lowRes = NULL; /* chargement d'un objet Herbe Type 2 */ g_ObjsWeed2 = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"weed2.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsWeed2->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsWeed2->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsWeed2->m_lowRes = NULL; /* chargement d'un objet Champignon*/ g_ObjsMushroom = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"mushroom.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsMushroom->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsMushroom->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsMushroom->m_lowRes = NULL; /* chargement d'un objet Fleur Rouge*/ g_ObjsRedFlower = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"redflower.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsRedFlower->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsRedFlower->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsRedFlower->m_lowRes = NULL; /* chargement d'un objet Araignée*/ g_ObjsSpider = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"spider.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsSpider->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsSpider->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsSpider->m_lowRes = NULL; /* chargement d'un objet Major*/ g_ObjsMajor = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"major.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsMajor->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsMajor->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsMajor->m_lowRes = NULL; //g_ObjsMajor->m_hiRes->SelectDefaultAnimation(ANIMATION_WALK_UID); //g_ObjsMajor->m_hiRes->ChangeFrameRateRatio(4); /* CVector3f grav (0,-0.8f,0); CVector3f randplan (0.0f, 0.0f, 0.0f); CVector3f randspeed (0.3f, 0.8f, 0.4f);*/ /*g_ObjsMajor->m_hiRes->InitParticleSystem(OBJECT_SHOOTPARTICLE_UID, 20.0f, 20, 5.0f, 1.0f, 0.3f, 1.0f, 0.3f, 0.8f, false,0, 0.5f,0.5f, grav, randplan, randspeed, NULL,NULL); g_ObjsMajor->m_hiRes->Reset();*/ //g_ObjsMajor->m_hiRes->StartParticleSystem(); init_world(world,"AI_test.wld", mSettings); // minor.load3d(); /* initialisation des objets par copie */ /* g_ObjGraine = new C3DObjElement; *(g_ObjGraine) = *(ObjGraine); g_ObjGraine->ChangeFrameRateRatio(10.0); g_ObjFourmi1 = new C3DObjElement; *(g_ObjFourmi1) = *(ObjOuvriere); g_ObjFourmi1->ChangeFrameRateRatio(40.0); g_ObjFourmi1->SelectDefaultAnimation(ANIMATION_STAY_UID); g_ObjFourmi1->RandomAnimationStart(ANIMATION_STAY_UID); g_ObjFourmi2 = new C3DObjElement; *(g_ObjFourmi2) = *(ObjOuvriere); g_ObjFourmi2->ChangeFrameRateRatio(10.0); g_ObjFourmi2->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi2->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi3 = new C3DObjElement; *(g_ObjFourmi3) = *(ObjOuvriere); g_ObjFourmi3->ChangeFrameRateRatio(10.0); g_ObjFourmi3->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi3->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi4 = new C3DObjElement; *(g_ObjFourmi4) = *(ObjOuvriere); g_ObjFourmi4->ChangeFrameRateRatio(10.0); g_ObjFourmi4->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi4->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi5 = new C3DObjElement; *(g_ObjFourmi5) = *(ObjOuvriere); g_ObjFourmi5->ChangeFrameRateRatio(10.0); g_ObjFourmi5->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi5->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi6 = new C3DObjElement; *(g_ObjFourmi6) = *(ObjOuvriere); g_ObjFourmi6->ChangeFrameRateRatio(10.0); g_ObjFourmi6->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi6->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi7 = new C3DObjElement; *(g_ObjFourmi7) = *(ObjOuvriere); g_ObjFourmi7->ChangeFrameRateRatio(10.0); g_ObjFourmi7->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi7->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi8 = new C3DObjElement; *(g_ObjFourmi8) = *(ObjOuvriere); g_ObjFourmi8->ChangeFrameRateRatio(10.0); g_ObjFourmi8->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi8->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi9 = new C3DObjElement; *(g_ObjFourmi9) = *(ObjOuvriere); g_ObjFourmi9->ChangeFrameRateRatio(10.0); g_ObjFourmi9->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi9->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi10 = new C3DObjElement; *(g_ObjFourmi10) = *(ObjOuvriere); g_ObjFourmi10->ChangeFrameRateRatio(10.0); g_ObjFourmi10->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi10->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi11 = new C3DObjElement; *(g_ObjFourmi11) = *(ObjOuvriere); g_ObjFourmi11->ChangeFrameRateRatio(10.0); g_ObjFourmi11->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi11->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi12 = new C3DObjElement; *(g_ObjFourmi12) = *(ObjOuvriere); g_ObjFourmi12->ChangeFrameRateRatio(10.0); g_ObjFourmi12->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi12->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi13 = new C3DObjElement; *(g_ObjFourmi13) = *(ObjOuvriere); g_ObjFourmi13->ChangeFrameRateRatio(10.0); g_ObjFourmi13->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi13->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi14 = new C3DObjElement; *(g_ObjFourmi14) = *(ObjOuvriere); g_ObjFourmi14->ChangeFrameRateRatio(10.0); g_ObjFourmi14->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi14->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi15 = new C3DObjElement; *(g_ObjFourmi15) = *(ObjOuvriere); g_ObjFourmi15->ChangeFrameRateRatio(10.0); g_ObjFourmi15->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi15->RandomAnimationStart(ANIMATION_WALK_UID); */ CVector3f PositionInitiale( 600,400,600 ); CVector3f VitesseInitiale( 5.,-180.,0 ); CVector3f Force( 0.f,-9.81f*80.f,-500.f ); CVector3f RandomPlan( 1200,0.0,1200 ); CVector3f RandomSpeed( 0, -40, 0 ); strcpy(g_sztextureparticule, g_exepath); strcat(g_sztextureparticule, "textures"PATHDELIM_S"particle.tga"); GLuint texuid; glGenTextures(1, &texuid); // Create The Texture tgaLoad(g_sztextureparticule,texuid); g_ParticleSystem.Init(1000, 5, 10, 0.8f, 1.0f, 1.0f, 0.25f, true, texuid, 10.,13., PositionInitiale, VitesseInitiale, Force, RandomPlan, RandomSpeed,&create_particle_callback, NULL); g_ParticleChrono.Reset(); return true; }
void init() { glClearColor(0.0, 0.0, 0.0, 1.0); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); glMaterialfv(GL_LIGHT0, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialf(GL_LIGHT0, GL_SHININESS, mat_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); glShadeModel(GL_SMOOTH); /* enable smooth shading */ glEnable(GL_LIGHTING); /* enable lighting */ glEnable(GL_LIGHT0); /* enable light 0 */ glEnable(GL_DEPTH_TEST); // following are texture mapping part // glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glEnable ( GL_COLOR_MATERIAL ); glColorMaterial ( GL_LIGHT0, GL_AMBIENT_AND_DIFFUSE ); glEnable ( GL_TEXTURE_2D ); glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 ); // glGenTextures (1, texture_id); image_t temp_image; glBindTexture ( GL_TEXTURE_2D, texture_id[MOUNTAIN_TEXTURE] ); tgaLoad ( "mountains-hero.tga", &temp_image, TGA_FREE | TGA_LOW_QUALITY ); //try to load a second picture glPixelStorei ( GL_UNPACK_ALIGNMENT, 2); // glGenTextures (2, texture_id); image_t temp_image2; glBindTexture ( GL_TEXTURE_2D, texture_id[CLOUD_TEXTURE] ); tgaLoad ( "atmosphere_clouds.tga", &temp_image2, TGA_FREE | TGA_LOW_QUALITY ); //try to load a third texture glPixelStorei ( GL_UNPACK_ALIGNMENT, 3 ); glGenTextures (3, texture_id); image_t temp_image3; glBindTexture ( GL_TEXTURE_2D, texture_id[CHECKBOARD_TEXTURE] ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); tgaLoad ( "color_checkboard.tga", &temp_image3, TGA_FREE | TGA_LOW_QUALITY ); // a flat image glShadeModel(GL_FLAT); makeCheckImage(); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glGenTextures(4, &texture_id[3]); glBindTexture(GL_TEXTURE_2D, texture_id[3]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D, texture_id[3]); glEnable ( GL_CULL_FACE ); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); }
int terrainLoadFromImage(char *filename, int normals) { tgaInfo *info; int mode; float pointHeight; /* if a terrain already exists, destroy it. */ if (terrainHeights != NULL) terrainDestroy(); /* load the image, using the tgalib */ info = tgaLoad(filename); /* check to see if the image was properly loaded remember: only greyscale, RGB or RGBA noncompressed images */ if (info->status != TGA_OK) return(TERRAIN_ERROR_LOADING_IMAGE); /* if the image is RGB, convert it to greyscale mode will store the image's number of components */ mode = info->pixelDepth / 8; if (mode == 3) { tgaRGBtoGreyscale(info); mode = 1; } /* set the width and height of the terrain */ terrainGridWidth = info->width; terrainGridLength = info->height; /* alocate memory for the terrain, and check for errors */ terrainHeights = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float)); if (terrainHeights == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); /* allocate memory for the normals, and check for errors */ if (normals) { terrainNormals = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float) * 3); if (terrainNormals == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); } else terrainNormals = NULL; /* if mode = RGBA then allocate memory for colors, and check for errors */ if (mode == 4) { terrainColors = (float *)malloc(terrainGridWidth * terrainGridLength * sizeof(float)*3); if (terrainColors == NULL) return(TERRAIN_ERROR_MEMORY_PROBLEM); } else terrainColors = NULL; /* fill arrays */ for (int i = 0 ; i < terrainGridLength; i++) for (int j = 0;j < terrainGridWidth; j++) { /* compute the height as a value between 0.0 and 1.0 */ pointHeight = info->imageData[mode*(i*terrainGridWidth + j)+(mode-1)] / 255.0; terrainHeights[i*terrainGridWidth + j] = pointHeight; /* if mode = RGBA then fill the colors array as well */ if (mode==4) { terrainColors[3*(i*terrainGridWidth + j)] = (info->imageData[mode*(i*terrainGridWidth + j)])/255.0; terrainColors[3*(i*terrainGridWidth + j)+1] = (info->imageData[mode*(i*terrainGridWidth + j)+1])/255.0; terrainColors[3*(i*terrainGridWidth + j)+2] = (info->imageData[mode*(i*terrainGridWidth + j)+2])/255.0; } } /* if we want normals then compute them */ if (normals) terrainComputeNormals(); /* free the image's memory */ tgaDestroy(info); return(TERRAIN_OK); }
bool objects_recreate_displaylists() { menu_main= new menu(TempSettings,"Menu.ini"); menu_map = new menu(TempSettings,"Mapmenu.ini"); g_textures_list.m_textures_number=0; // TODO : mettre tous les types d'objets ici pour recharger leur displaylist // ResetTextures reset les textures des particules. GLuint texuid; glGenTextures(1, &texuid); // Create The Texture tgaLoad(g_sztextureparticule,texuid); g_ParticleSystem.ResetTextures(texuid); // et maintenant c'est le tour de la police. uint tex,mask; glGenTextures(1, &tex); tgaLoad("textures"PATHDELIM_S"font.tga",tex); glGenTextures(1, &mask); tgaLoad("textures"PATHDELIM_S"fontmask.tga",mask); fontBuild(tex, mask); fontResize(TAILLEX, TAILLEY); // TODO: reset des textures des phéromones if (world) { glGenTextures(1,&(world->g_world_->token_texture_id_)); tgaLoad("textures"PATHDELIM_S"token.tga",world->g_world_->token_texture_id_); world->map_->Switch_to_fullscreen(); if (g_ObjsHarvester) { g_ObjsHarvester->m_hiRes->RebuilDisplayLists(); // c'est magique, il suffit pour les fourmis texturées de ne le faire qu'une // fois (la texture va être en fait simplement recréé avec le même ID // qu'avant, donc les autres n'y voient que du feu g_ObjsHarvester->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, &g_matDefault); // l'objet étant déjà en mémoire (3DS), il ne sera pas recharger sur le // disque dur, donc pas la peine de donner le dossier où sont stocker les // fichiers } if (g_ObjsHarvester->m_lowRes) { g_ObjsHarvester->m_lowRes->RebuilDisplayLists(); g_ObjsHarvester->m_lowRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, &g_matDefault); } if (g_ObjsSeed) { g_ObjsSeed->m_hiRes->RebuilDisplayLists(); g_ObjsSeed->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } if (g_ObjsWeed1) { g_ObjsWeed1->m_hiRes->RebuilDisplayLists(); g_ObjsWeed1->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } if (g_ObjsWeed2) { g_ObjsWeed2->m_hiRes->RebuilDisplayLists(); g_ObjsWeed2->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } if (g_ObjsMushroom) { g_ObjsMushroom->m_hiRes->RebuilDisplayLists(); g_ObjsMushroom->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } if (g_ObjsRedFlower) { g_ObjsRedFlower->m_hiRes->RebuilDisplayLists(); g_ObjsRedFlower->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } if (g_ObjsSpider) { g_ObjsSpider->m_hiRes->RebuilDisplayLists(); g_ObjsSpider->m_hiRes->Load(NULL, NULL, true,&g_textures_list, &g_objects_list, NULL); } } return true; }