//virtual void BaResource::FixPointers( BtU8 *pFileData, BaArchive *pArchive ) { BtPrint( "Fix pointer for unsupported resource type %s.\r\n", GetTitle() ); (void)pFileData; m_pArchive = pArchive; }
GLenum RsTextureWinGL::checkError( const BtChar* action ) { GLenum error = glGetError(); switch( error ) { case GL_NO_ERROR: break; case GL_INVALID_ENUM: { BtPrint( "%s GL_INVALID_ENUM when creating texture %s\r\n", action, GetTitle() ); break; } case GL_INVALID_VALUE: { BtPrint( "%s GL_INVALID_VALUE when creating texture %s\r\n", action, GetTitle() ); break; } case GL_INVALID_OPERATION: { BtPrint( "%s GL_INVALID_OPERATION when creating texture %s\r\n", action, GetTitle() ); break; } case GL_STACK_OVERFLOW: { BtPrint( "%s GL_STACK_OVERFLOW when creating texture %s\r\n", action, GetTitle() ); break; } case GL_STACK_UNDERFLOW: { BtPrint( "%s GL_STACK_UNDERFLOW when creating texture %s\r\n", action, GetTitle() ); break; } case GL_OUT_OF_MEMORY: { BtPrint( "%s GL_OUT_OF_MEMORY when creating texture %s\r\n", action, GetTitle() ); break; } default: { BtPrint( "Unknown error when creating texture %s\r\n", action, GetTitle() ); break; } } return error; }
void RsTextureWinGL::CreateOnDevice() { // Find the mipmap data BtU8* pMemory = (BtU8*)( m_pFileData ); // Skip pass the header pMemory += sizeof( LBaTextureFileData ); // Set the mipmap pointer m_pMipmaps = ( LBaMipMapFileData* ) pMemory; // Go past the mipmap data pMemory+= sizeof( LBaMipMapFileData ) * m_pFileData->m_nMipMaps; for( BtU32 i=0; i<m_pFileData->m_nMipMaps; i++ ) { // Cache each mipmap LBaMipMapFileData& mipMap = m_pMipmaps[i]; // Mark up each texture mipMap.m_pTextureMemory = pMemory; // Increment the memory pointer pMemory+= mipMap.m_nTextureSize; } if( m_pFileData->m_flags & RsTF_SystemMemory ) { BtPrint( "Texture %s is loaded into system memory.\r\n", GetTitle() ); } else { BtU32 iMipmapLevel=0; // iMipmapLevel<m_pFileData->m_nMipMaps; iMipmapLevel++ ) // Cache each mipmap LBaMipMapFileData& mipMap = m_pMipmaps[iMipmapLevel]; // Cache the texture memory BtU8* pTextureMemory = mipMap.m_pTextureMemory; // Cache the texture size BtU32 textureSize = mipMap.m_nTextureSize; (void)textureSize; // Load the texture GLenum format = (GLenum)0; GLenum internalformat = (GLenum)0; if( strstr( this->GetTitle(), "vera20") ) { int a=0; a++; } if( m_pFileData->m_flags & RsTF_Alpha ) { format = GL_RGBA; internalformat = GL_RGBA8; } else { format = GL_RGB; internalformat = GL_RGB8; } // http://www.flashbang.se/archives/48 // Cache the mipmap mipMap = m_pMipmaps[0]; glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); } if (m_pFileData->m_flags & RsTF_ClampU) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } if (m_pFileData->m_flags & RsTF_NearestNeighbour) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } if( m_pFileData->m_flags & RsTF_RenderTarget ) { glGenFramebuffers(1, &m_frameBufferObject); glGenRenderbuffers(1, &m_renderBufferObject); glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferObject); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mipMap.m_nWidth, mipMap.m_nHeight, 0, GL_RGBA, GL_INT, NULL); glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, m_texture, 0); glBindRenderbuffer(GL_RENDERBUFFER, m_renderBufferObject); glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH_COMPONENT24, mipMap.m_nWidth, mipMap.m_nHeight ); glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER, m_renderBufferObject); // check FBO status // GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); // BtAssert( status == GL_FRAMEBUFFER_COMPLETE ); glBindFramebuffer(GL_FRAMEBUFFER, 0); } else { // float maximumAnistropy; // glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &maximumAnistropy); // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, maximumAnistropy); glTexImage2D( GL_TEXTURE_2D, //target : usually GL_TEXTURE_2D 0, //level : usually left to zero format, //internal format mipMap.m_nWidth, //image size mipMap.m_nHeight, 0, //0 : no border format, //format : usually RGBA GL_UNSIGNED_BYTE, //data type : pixels are made of byte pTextureMemory ); //picture datas //glGenerateMipmap(GL_TEXTURE_2D); checkError( "glTexImage2D" ); } } glBindTexture( GL_TEXTURE_2D, 0 ); }
void ApConfig::SetResourcePath( const BtChar* pResourcePath ) { BtStrCopy( m_resourcePath, 256, pResourcePath ); BtPrint( "%s\n", m_resourcePath ); }