void App_Test::load_Texture() { loadPCX((u8*)heavy_pcx, &this->pcx); image8to16trans(&this->pcx,0); glGenTextures(1, &this->textureID[0]); glBindTexture(0, this->textureID[0]); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, this->pcx.image.data8); imageDestroy(&this->pcx); // loadPCX((u8*)start_button_1_pcx, &this->pcx); // image8to16trans(&this->pcx,0); // glGenTextures(1, &this->textureID[0]); // glBindTexture(0, this->textureID[0]); // glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_32, 0, TEXGEN_TEXCOORD | GL_TEXTURE_COLOR0_TRANSPARENT, this->pcx.image.data8); // imageDestroy(&this->pcx); // // loadPCX((u8*)hex_pcx, &this->pcx); // image8to16trans(&this->pcx,0); // glGenTextures(1, &this->textureID[1]); // glBindTexture(0, this->textureID[1]); // glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_16 , TEXTURE_SIZE_16, 0, TEXGEN_TEXCOORD | GL_TEXTURE_COLOR0_TRANSPARENT, this->pcx.image.data8); // imageDestroy(&this->pcx); // // loadPCX((u8*)GO_base_pcx, &this->pcx); // image8to16trans(&this->pcx,0); // glGenTextures(1, &this->textureID[3]); // glBindTexture(0, this->textureID[3]); // glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_8 , TEXTURE_SIZE_8, 0, TEXGEN_TEXCOORD | GL_TEXTURE_COLOR0_TRANSPARENT , this->pcx.image.data8); // imageDestroy(&this->pcx); // }
// Load PCX files And Convert To Textures int LoadGLTextures() { sImage pcx; // (NEW) and different from nehe. //load our texture loadPCX((u8*)Star_pcx, &pcx); image8to16trans(&pcx, 0); //DS supports no filtering of anykind so no need for more than one texture glGenTextures(1, &texture[0]); glBindTexture(0, texture[0]); glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.image.data8); imageDestroy(&pcx); return TRUE; }
void fillDisplay(unsigned short color, unsigned int page, AppState & state) { int offset = 0; // for (int y=0; y<MY_BG_H; y++) { // offset = y * MY_BG_W; // for (int x=0; x<MY_BG_W; x++) { // offset+=1; // BG_GFX[offset] = color; // } // } if (page != state.lastPage) { if (state.lastPage != -1 && state.lastImageFromPcx) { free(state.lastImage.palette); // free(state.lastImage.imasge.data8); free(state.lastImage.image.data16); } state.lastPage = page; int res = 0; char fileName[1024]; sprintf(fileName, "%s/%s/image%02d.pcx", MAINPATH, state.notebookName.c_str(), page); FILE * pFile = fopen ( fileName , "rb" ); if (pFile==NULL) { printf("File %s Not Found\n", fileName); fillEmptyPage(state); return; } // obtain file size: long lSize; fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); char * pcx_image = (char *)malloc (sizeof(char)*lSize); if (pcx_image == NULL) { printf ("Memory error\n"); fillEmptyPage(state); return; } // copy the file into the buffer: res = fread (pcx_image,1,lSize,pFile); if (res != lSize) { printf("Reading image error\n"); fillEmptyPage(state); return; } fclose (pFile); res = loadPCX((u8*)pcx_image, &state.lastImage); free (pcx_image); printf("Loaded Background of size %d x %d\n", state.lastImage.width, state.lastImage.height); printf(" Bits per pixel %d\n", state.lastImage.bpp); printf(" res %d\n", res); // image8to16(&image); printf(" palette size %d\n", sizeof(state.lastImage.palette)); for (int i=0; i<256; i++) { BG_PALETTE[i] = state.lastImage.palette[i]; } BG_PALETTE[1] = RGB15(31,0,0) | BIT(15); state.lastImageFromPcx = true; } // dmaCopy(image.palette, BG_PALETTE, sizeof(image.palette)); for (int y=0 ; y < MY_BG_H; y++) { offset = y * MY_BG_W / 2; for (int x=0; x<MY_BG_W; x+=2) { int offset2 = offset + x/2; Point imgPoint = state.convertBufferToImage(Point(x,y)); if (imgPoint.y < 0 || imgPoint.y >= state.lastImage.height) { bgGetGfxPtr(3)[offset2] = 0; continue; } if (imgPoint.x < 0 || imgPoint.x >= state.lastImage.width) { bgGetGfxPtr(3)[offset2] = 0; continue; } //BG_GFX[offset] = RGB15(31,0,0) | BIT(15); // BG_GFX[offset] = image.image.data16[imgO]; int imgO = imgPoint.y * state.lastImage.width/2 + imgPoint.x/2; bgGetGfxPtr(3)[offset2] = state.lastImage.image.data16[imgO]; // bgGetGfxPtr(3)[offset2] = 0x0101; } } // dmaCopy(image.image.data8, bgGetGfxPtr(3), image.width*image.height); }