HRESULT ManagementTex::handleTexDesc( TexDesc* texDesc, ID3D11Device* device) { HRESULT hr = S_OK; std::string path = texDesc->getPath() + texDesc->getHeader().texPath_; std::vector<TexDescTex> texDescs = texDesc->getTexDescs(); unsigned int texID; std::string texFileName; for(unsigned int i = 0; i < texDescs.size(); i++) { texID = texDescs.at(i).id_; texFileName = texDescs.at(i).fileName_; hr = createTex( texID, path, texFileName, device); if(FAILED(hr)) { ERROR_MESSAGEBOX("ManagementTex::handleTexDesc Could not load texture: " + texFileName); } } return hr; }
void createFBTex(GLuint *tex, GLuint *fb, int w, int h, GLenum format, GLenum filter, GLenum wrap) { createTex(tex, w, h, format, filter, wrap, 0); glGenFramebuffers(1, fb); glBindFramebuffer(GL_FRAMEBUFFER, *fb); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *tex, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
void TransFunc::setPixelData(GLubyte* data) { if (!tex_ || (tex_->getDimensions() != dimensions_)) createTex(); tgtAssert(tex_, "No texture"); if (tex_->getPixelData() != reinterpret_cast<GLubyte*>(data)) tex_->destroy(); tex_->setPixelData(data); textureInvalid_ = true; }
void TransFunc::updateTexture() { if (!tex_ || (tex_->getDimensions() != dimensions_)) createTex(); if (!tex_) { LERROR("Failed to create texture"); return; } tex_->uploadTexture(); textureInvalid_ = false; }
Sprite::Sprite(ID3D10Device* p_d3dDevice, float p_x, float p_y, float p_width, float p_height, char* p_fileName, D3D10_VIEWPORT* p_viewPort) { m_d3dDevice = p_d3dDevice; m_viewPort = p_viewPort; // Set the sprite's shader resource view m_imageSprite.pTexture = createTex(p_fileName); m_x = p_x; m_y = p_y; m_posX = m_x; m_posY = m_y; m_height = p_height; m_width = p_width; // top-left location in U,V coords m_imageSprite.TexCoord.x = 0; m_imageSprite.TexCoord.y = 0; // Determine the texture size in U,V coords m_imageSprite.TexSize.x = 1.0f; m_imageSprite.TexSize.y = 1.0f; // Set the texture index. Single textures will use 0 m_imageSprite.TextureIndex = 0; m_imageSprite.ColorModulate = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); D3DXMatrixIdentity(&m_matTranslate); D3DXMatrixIdentity(&m_matScale); D3DXMatrixScaling(&m_matScale, m_width, m_height, 1.0f); m_anchorPoint = NORMAL; m_centerX = false; }
// loading immage // input - filename of image GLuint TexPool::loadImage(const char* filename) { GLuint num; std::string buf; buf = texPath; buf = buf + filename; std::cout << buf << std::endl; SDL_Surface* img = IMG_Load(buf.c_str()); if (img == NULL) { std::cout << "Image " << buf << " not found" << std::endl; return -1; } SDL_PixelFormat form = {NULL, 32, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff}; SDL_Surface * img2 = SDL_ConvertSurface (img, &form, SDL_SWSURFACE); if (img2 == NULL) { std::cout << "Cannot convert " << filename << std::endl; return -1; } num = createTex(img2, filename); SDL_FreeSurface(img); SDL_FreeSurface(img2); return num; }