bool  CTexture::MakeScreenTextureBind() {
    if (glIsTexture(m_nTxt) == GL_TRUE) {
    } else {
        GLint Viewport[4];
        glGetIntegerv(GL_VIEWPORT, Viewport);
        int32 newWidth = 128;
        uint8* pData = new uint8[newWidth * newWidth * 3 + 6];
        int32 sx, sy;
        unsigned char temp[6];
        for (int32 y = 0; y < newWidth; y++)
            for (int32 x = 0; x < newWidth; x++) {
                sx = static_cast<int32>(static_cast<float>(x * Viewport[2]) / newWidth);
                sy = static_cast<int32>(static_cast<float>(y * Viewport[3]) / newWidth);
                glReadPixels(sx, sy, 1, 1,
                             GL_RGB, GL_UNSIGNED_BYTE, temp);
                pData[y * newWidth * 3 + x * 3 + 0] = static_cast<uint8>(temp[0] * 0.8f);
                pData[y * newWidth * 3 + x * 3 + 1] = static_cast<uint8>(temp[1] * 0.8f);
                pData[y * newWidth * 3 + x * 3 + 2] = static_cast<uint8>(temp[2] * 0.8f);
            }
        glGenTextures(1, &m_nTxt);
        glBindTexture(GL_TEXTURE_2D, m_nTxt);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, newWidth, newWidth, 0, GL_RGB, GL_UNSIGNED_BYTE, pData);
        delete[] pData;
    }
    return true;
}
void Texture::deleteTexture()
{
    if(glIsTexture(texID)){
        glDeleteTextures(1, &texID);
        texID = 0;
    }
}
Example #3
0
GLuint loadSkyBoxTexture(char *fileName, GLuint *textureID) {
    // free previously bound texture
    if ((*textureID != 0) && glIsTexture(*textureID)) {
        glDeleteTextures(1, textureID);
    }

    *textureID = loadTexture(va("%s/skybox/%s", MISCDIR, fileName), GL_TRUE);

    // catch error
    if ((*textureID == 0) || !glIsTexture(*textureID)) {
        view.drawSky ++;
        if(view.drawSky > SKYBOX_LAST) view.drawSky = 0;
    }

    return *textureID;
}
Example #4
0
//********************************************
// glDraw
//********************************************
void CSceneGraph3d::glDraw(void)
{
	if(!m_ListDone)
		glBuildList();

	unsigned int size = m_ArrayObject3d.GetSize();
	for(unsigned int i=0; i<size; i++)
	{
		CObject3d *pObject3d = m_ArrayObject3d[i];
		// Texture
		if(pObject3d->GetType() == TYPE_MESH3D)
		{
			CMesh3d *pMesh = (CMesh3d *)pObject3d;
			int IndexTexture = pMesh->GetTextureIndex();
			if(IndexTexture >= 0)
			{
				ASSERT(glIsTexture(m_pIndexTextureBinding[IndexTexture]));
				glBindTexture(GL_TEXTURE_2D,m_pIndexTextureBinding[IndexTexture]);
				TRACE("Texture : %d\n",m_pIndexTextureBinding[IndexTexture]);
			}
			// Drawing
			pObject3d->glDraw();
		}
		else
			pObject3d->glDraw();
	}
}
Example #5
0
TextureResource::~TextureResource(){
	
	if(glIsTexture(ids[0])) glDeleteTextures(numTextures, ids);
	if (glIsFramebuffer(frameBuffer)) glDeleteFramebuffers(1, &frameBuffer);
	if (glIsRenderbuffer(renderBuffer)) glDeleteRenderbuffers(1, &renderBuffer);
	if (ids) delete[] ids;
}
Example #6
0
const bool GPUQuery::isRenderBuffer(const GLuint renderbuffer)
{
    const bool is(glIsTexture(renderbuffer) == GL_TRUE);
	if(!is)
		glGetError();
	return is;
}
Example #7
0
void rect(const unsigned texture,
		  const vec2& v0,
		  const vec2& v1,
		  const vec2& vt0,
		  const vec2& vt1)
{
	if(!glIsTexture(texture))
		return;

	const BindTexture2D bind(texture);
	GLint old_state(0);
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &old_state);

	if(old_state != GL_MODULATE)
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	vec2 vp[4] = {v0, vec2(v1.x, v0.y), vec2(v0.x, v1.y), v1};
	vec2 vtp[4] = {vt0, vec2(vt1.x, vt0.y), vec2(vt0.x, vt1.y), vt1};

	glTexCoordPointer(2, GL_FLOAT, 0, vtp);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glVertexPointer(2, GL_FLOAT, 0, vp);
	glEnableClientState(GL_VERTEX_ARRAY);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	if(old_state != GL_MODULATE)
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, old_state);
}
Example #8
0
bool TextureManager::LoadTexture(const KFbxFileTexture * pTexture, unsigned int * pTextureObject)
{
	TextureMapType::RecordType * lTextureRecord = mTextureMap.Find(pTexture);
	if (lTextureRecord)
	{
		if (pTextureObject)
			*pTextureObject = lTextureRecord->GetValue();
		return true;
	}

	const KString lFileName = pTexture->GetFileName();
	unsigned int lTextureObject = 0;
	bool lStatus = LoadTextureFromFile(lFileName, lTextureObject);

	if (!lStatus)
	{
		const KString lRelativeFileName = mWorkingDir + "/" + pTexture->GetFileName();
		lStatus = LoadTextureFromFile(lRelativeFileName, lTextureObject);
	}

	if (lStatus)
	{
		K_ASSERT(glIsTexture(lTextureObject));
		mTextureMap.Insert(pTexture, lTextureObject);
		if (pTextureObject)
			*pTextureObject = lTextureObject;
		return true;
	}

	return false;
}
Example #9
0
bool nTextureManager::saveTexture(nTexture *tex, string name) {
    if(!glIsTexture(tex->tex)) {
        return false;
    }
    mutex->lock();
    unsigned char *dat = new unsigned char[3 * (unsigned int)(tex->size.x * tex->size.y)];
    glBindTexture(GL_TEXTURE_2D, tex->tex);
    glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, dat);
    ILuint img;
    ilGenImages(1, &img);
    ilBindImage(img);
    iluScale(tex->size.x, tex->size.y, 1);
    ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
    bool t = ilTexImage(tex->size.x, tex->size.y, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, dat);
    ILuint error = ilGetError();
    GLuint glError = glGetError();
    if(error || !t || glError) {
        nGine::instance()->getLogger()->addDebugLog("Error while saving file : " + nLogger::numToString((int)error) + "/" + nLogger::numToString((int)glError));
        mutex->unlock();
        return false;
    }
    bool a = ilSaveImage((nGine::instance()->appPath() + name).c_str());
    mutex->unlock();
    return a;
}
Example #10
0
bool CObjectView::loadTexture(const char *file,  GLuint *tex){
  //  kill old one
  if (!glIsTexture(*tex)){
    //  load new texture
    glGenTextures(1, tex);
    glBindTexture(GL_TEXTURE_2D, *tex);
    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_LINEAR*/GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, /*GL_LINEAR*/GL_NEAREST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    }
  else{
    glBindTexture(GL_TEXTURE_2D, *tex);
    }

  CProgressMeter pm(this);
  pm.init();

  ImageRGB im;
  char *err;
  float r = im.loadTexture(file, &err, &pm);
  if (r > 0){
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, im.getN(), im.getM(), 0, GL_RGB, GL_UNSIGNED_BYTE, &im.index(0, 0));
    return true;
    }
  else{
    AfxMessageBox(err, MB_OK | MB_ICONSTOP);
    return false;
    }
}
Example #11
0
Response TextureView::Draw (AbstractWindow* context)
{
  float x = (size().width() - image_size_.width()) / 2.f;
  float y = (size().height() - image_size_.height()) / 2.f;

  // draw checkerboard
  chessboard_->Draw(x, y);

  if (texture_ && glIsTexture(texture_->id())) {

    // draw texture
    glActiveTexture(GL_TEXTURE0);

    texture_->bind();

    AbstractWindow::shaders()->widget_image_program()->use();
    glUniform2f(
        AbstractWindow::shaders()->location(Shaders::WIDGET_IMAGE_POSITION), x,
        y);
    glUniform1i(
        AbstractWindow::shaders()->location(Shaders::WIDGET_IMAGE_TEXTURE), 0);
    glUniform1i(
        AbstractWindow::shaders()->location(Shaders::WIDGET_IMAGE_GAMMA), 0);

    glBindVertexArray(vao_[1]);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    texture_->reset();

  }

  return Finish;
}
Example #12
0
KBImage::~KBImage()
{
    delete m_viewTrans;

    if (glIsTexture(m_texture))
        glDeleteTextures(1, &m_texture);
}
Example #13
0
/**
 * @brief GLContextReinit
 */
void FBO::GLContextReinit()
{
	if (!IsSupported()) return;

	for (std::map<GLuint,FBO::TexData*>::iterator ti=texBuf.begin(); ti!=texBuf.end(); ++ti) {
		FBO::TexData* tex = ti->second;

		if (glIsTexture(tex->id)) {
			glBindTexture(tex->target,tex->id);
			//todo: regen mipmaps?
			switch (tex->target) {
				case GL_TEXTURE_3D:
					//glTexSubImage3D(tex->target, 0, 0,0,0, tex->xsize, tex->ysize, tex->zsize, /*FIXME?*/GL_RGBA, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
					glTexImage3D(tex->target, 0, tex->format, tex->xsize, tex->ysize, tex->zsize, 0, /*FIXME?*/GL_RGBA, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
					break;
				case GL_TEXTURE_1D:
					//glTexSubImage1D(tex->target, 0, 0, tex->xsize, /*FIXME?*/GL_RGBA, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
					glTexImage1D(tex->target, 0, tex->format, tex->xsize, /*FIXME?*/GL_RGBA, 0, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
					break;
				default: //GL_TEXTURE_2D & GL_TEXTURE_RECTANGLE
					//glTexSubImage2D(tex->target, 0, 0,0, tex->xsize, tex->ysize, /*FIXME?*/GL_RGBA, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
					glTexImage2D(tex->target, 0, tex->format, tex->xsize, tex->ysize, 0, /*FIXME?*/GL_RGBA, /*FIXME?*/GL_UNSIGNED_BYTE, tex->pixels);
			}
		}else if (glIsRenderbufferEXT(tex->id)) {
			//FIXME
		}

		delete[] tex->pixels;
		delete tex;
	}
	texBuf.clear();
}
Example #14
0
//----------------------------------------------------------------//
bool USTexture::Bind () {

	this->AffirmTexture ();
	if ( !this->mGLTexID ) {
		return false;
	}

	// attempt to recover from lost context
	if ( !glIsTexture ( this->mGLTexID )) {
	
		this->mGLTexID = 0;
	
		// ugh... fix this monstrosity later!
		if ( this->mFilename.size ()) {
			this->Init ( this->mFilename );
			this->AffirmTexture ();
		}
		if ( !this->mGLTexID ) return false;
	}

	glBindTexture ( GL_TEXTURE_2D, this->mGLTexID );

	glEnable ( GL_TEXTURE_2D );
	glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
	
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, this->mWrap );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, this->mWrap );
	
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, this->mMinFilter );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, this->mMagFilter );
	
	return true;
}
Example #15
0
void Sprite::draw()
{
    if (!loadedp) { return; }
    if (!glIsTexture(tex_id)) {
        loadData();
    }
    glBindTexture(GL_TEXTURE_2D, tex_id);
    glEnable(GL_TEXTURE_2D);
    glColor3f(1.f,1.f,1.f);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    float texcoords[] = { 0, 0,
                          m_pw, 0,
                          m_pw, m_ph,
                          0, m_ph };
    float vertices[] = { -m_w/2.f, 0.f, 0.f,
                          m_w/2.f, 0.f, 0.f,
                          m_w/2.f, m_h, 0.f,
                         -m_w/2.f, m_h, 0.f };
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, vertices);
    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
    glDrawArrays(GL_QUADS, 0, 4);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisable(GL_TEXTURE_2D);
}
Example #16
0
/*===========================================================================*/
void ColorMapPalette::paintEvent( void )
{
    this->screenUpdated();

    if ( !BaseClass::isShown() ) return;

    if ( !glIsTexture( m_texture.id() ) ) this->initialize_texture( m_color_map );

    BaseClass::begin_draw();
    BaseClass::draw_background();

    // Draw the caption.
    {
        const int x = BaseClass::x0() + BaseClass::margin();
        const int y = BaseClass::y0() + BaseClass::margin();
        BaseClass::draw_text( x, y + BaseClass::characterHeight(), m_caption );
    }

    // Draw palette.
    {
        const int x = BaseClass::x0() + BaseClass::margin();
        const int y = BaseClass::y0() + BaseClass::margin() + BaseClass::characterHeight() + 5;
        const int width = BaseClass::width() - BaseClass::margin() * 2;
        const int height = BaseClass::height() - BaseClass::margin() * 2 - BaseClass::characterHeight();
        m_palette.setGeometry( x, y, width, height );
    }

    this->draw_palette();

    BaseClass::end_draw();
}
void Sphere::Render()
{
	WorldObject::Render();
	bool can_render = false;
	if (!shader.empty() && shader.o()->enabled)
	{
		shader.o()->Use();
		if (!texture.empty())
		{
			if (!glIsTexture(texture.o()->Get()))
			{
				std::cout << "Invalid texture" << std::endl;
			}
			shader.o()->BindTexture("texture", 0, texture.o()->Get());
			can_render = true;
		}
	}
	else
	{
		glUseProgramObjectARB(0);
		if (!texture.empty())
		{
			glBindTexture(GL_TEXTURE_2D, texture.o()->Get());
			can_render = true;
		}
	}
	quadratic = gluNewQuadric();			// Create A Pointer To The Quadric Object ( NEW )
	gluQuadricNormals(quadratic, GLU_SMOOTH);	// Create Smooth Normals ( NEW )
	gluQuadricTexture(quadratic, GL_TRUE);		// Create Texture Coords ( NEW )
	PutSphere(radius, 50);
	gluDeleteQuadric(quadratic);
}
Example #18
0
void CGUITextureManager::FreeUnusedTextures(unsigned int timeDelay)
{
  unsigned int currFrameTime = XbmcThreads::SystemClockMillis();
  CSingleLock lock(g_graphicsContext);
  for (ilistUnused i = m_unusedTextures.begin(); i != m_unusedTextures.end();)
  {
    if (currFrameTime - i->second >= timeDelay)
    {
      delete i->first;
      i = m_unusedTextures.erase(i);
    }
    else
      ++i;
  }

#if defined(HAS_GL) || defined(HAS_GLES)
  for (unsigned int i = 0; i < m_unusedHwTextures.size(); ++i)
  {
  // on ios the hw textures might be deleted from the os
  // when XBMC is backgrounded (e.x. for backgrounded music playback)
  // sanity check before delete in that case.
#if defined(TARGET_DARWIN_IOS)
    if (!g_Windowing.IsBackgrounded() || glIsTexture(m_unusedHwTextures[i]))
#endif
      glDeleteTextures(1, (GLuint*) &m_unusedHwTextures[i]);
  }
#endif
  m_unusedHwTextures.clear();
}
Example #19
0
TGEnv::~TGEnv()
{
    if(glIsBuffer(myBuffers[0]))
        glDeleteBuffers(3, myBuffers);
    if(glIsTexture(myTexture))
        glDeleteTextures(1, &myTexture);
}
Example #20
0
const bool GPUQuery::isTexture(const GLuint texture)
{
    const bool is(glIsTexture(texture) == GL_TRUE);
	if(!is)
		glGetError();
	return is;
}
Example #21
0
Texture* Texture::create(TextureHandle handle, int width, int height, Format format)
{
    GP_ASSERT( handle );

    Texture* texture = new Texture();
    if (glIsTexture(handle))
    {
        // There is no real way to query for texture type, but an error will be returned if a cube texture is bound to a 2D texture... so check for that
        glBindTexture(GL_TEXTURE_CUBE_MAP, handle);
        if (glGetError() == GL_NO_ERROR)
        {
            texture->_type = TEXTURE_CUBE;
        }
        else
        {
            // For now, it's either or. But if 3D textures and others are added, it might be useful to simply test a bunch of bindings and seeing which one doesn't error out
            texture->_type = TEXTURE_2D;
        }

        // Restore the texture id
        GL_ASSERT( glBindTexture((GLenum)__currentTextureType, __currentTextureId) );
    }
    texture->_handle = handle;
    texture->_format = format;
    texture->_width = width;
    texture->_height = height;
    texture->_internalFormat = getFormatInternal(format);
    texture->_texelType = getFormatTexel(format);
    texture->_bpp = getFormatBPP(format);

    return texture;
}
Example #22
0
SN_CheckerGLPBO::~SN_CheckerGLPBO() {
//	disconnect();

	if (_workerThread) {
		_workerThread->setThreadEnd();
		_workerThread->setBufferReadyForWriting(true);
		if ( pthread_cond_signal(_pbobufferready) != 0 ) {
			perror("pthread_cond_signal");
			qDebug() << "failed to signal condition var.";
		}
	}

	if (glIsTexture(_textureid))
		glDeleteTextures(1, &_textureid);


	pthread_mutex_unlock(_pbomutex);
	if ( pthread_mutex_destroy(_pbomutex) != 0) {
		qDebug() << "failed to destory pbomutex mutex";
	}

	if ( pthread_cond_destroy(_pbobufferready) != 0 ) {
		qDebug() << "failed to destroy pbobufferready condition variable";
	}
	free(_pbomutex);
	free(_pbobufferready);

    for (int i=0; i<2; i++) {
        _pbobuf[i]->destroy();
        delete _pbobuf[i];
    }
    QGLBuffer::release(QGLBuffer::PixelUnpackBuffer);

	qDebug() << "~SN_CheckerGLPBO";
}
Example #23
0
void gdOpenGlInitTexture (GDImage *image) {
    GLuint format;
    GLuint texId;

    gdReturnIfTrue(glIsTexture(image->id));

    glGenTextures(1, &texId);
    glBindTexture(GL_TEXTURE_2D, texId);
    gdImageSetId(image, texId);

    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_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); 

    format = gdOpenGlImageFormat(image->format);
    if (gdImageFormatIsCompressed(image->format)) {
        /* TODO: Handle Compression */
    } else {
        glTexImage2D(GL_TEXTURE_2D, 0, format,
                     image->width, image->height, 
                     0, format, GL_UNSIGNED_BYTE, image->data);
    }
}
Example #24
0
void CubeMapCore::setCubeMap(GLsizei width, GLsizei height, const std::vector<unsigned char*>& rgbaData) {
  assert(rgbaData.size() == 6);
  glDeleteTextures(1, &tex_);
  glGenTextures(1, &tex_);
  glBindTexture(GL_TEXTURE_CUBE_MAP, tex_);
  assert(glIsTexture(tex_));
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  // use anisotropic filtering
  GLfloat maxAnisotropy;
  glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
  glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);

  // transfer textures to GPU memory
  const GLenum cubeMapTexNames[] = {
      GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
      GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
      GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
  };
  for (int i = 0; i < 6; ++i) {
    assert(rgbaData[i]);
    glTexImage2D(cubeMapTexNames[i], 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaData[i]);
  }
  glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

  assert(!checkGLError());
}
Example #25
0
	void FractalTexture::create() {
		if(glIsTexture(texture.id)) glDeleteTextures(1, &texture.id); //cleaning gl memory up
		m_iMaxIterations = (long)((double)m_iStdMaxIterations * 1.0); //todo?
		m_dInvMaxIterations = 1.0 / (m_iMaxIterations+0.0001);
		const double winv = 1.0/(texture.width -1);
		const double hinv = 1.0/(texture.height-1);
		util::timeDiff();
		for (int x = 0; x < texture.width; ++x) {
			for (int y = 0; y < texture.height; ++y) {
#ifdef ROE_FRACTAL_GMP_USE_C
				mpf_set_d(m_xPos, x*winv);
				mpf_set_d(m_yPos, y*hinv);
				mpf_mul(m_xPos, m_xPos, m_width);
				mpf_mul(m_yPos, m_yPos, m_height);
				mpf_add(m_xPos, m_xUpLt, m_xPos);
				mpf_sub(m_yPos, m_yUpLt, m_yPos);
#else
				m_xPos = m_xUpLt + (x*winv)*m_width;
				m_yPos = m_yUpLt - (y*hinv)*m_height;
#endif
				computeColor(&(texture.data[((texture.height-1-y)*texture.width+x)*texture.bpp]));
			}
		}
		cout << "dt: " << util::timeDiff() << endl;
		cout << getCenterX() << endl;
		cout << getCenterY() << endl;
		cout << getZoomW() << endl;
		updateMipmaps();
		Texture::loadTextureIntoGL(&texture);
	}
Example #26
0
File: glx.c Project: zwizwa/pdp
void *zl_glx_image_data(zl_glx* x, zl_xwindow_p xwin,
			unsigned int w, unsigned int h){

    if (!x->initialized) return 0;

    x->image_width = w;
    x->image_height = h;
    
    int tex_width = x->tex_width;
    int tex_height = x->tex_height;

    /* set window context current
       just to make sure we don't conflict with other contexts */
    zl_glx_makecurrent(x, xwin);

    /* setup texture if necesary */
    if ((x->image_width > tex_width) || (x->image_height > tex_height)) {
	while (x->image_width > tex_width) tex_width *= 2;
	while (x->image_height > tex_height) tex_height *= 2;
	if (!glIsTexture(x->texture)){glGenTextures(1, &(x->texture));}
	glBindTexture(GL_TEXTURE_2D, x->texture);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	x->tex_width = tex_width;
	x->tex_height = tex_height;
	fprintf(stderr, "zl_glx_image_data: creating texture %dx%d", tex_width, tex_height);
	if (x->data) free (x->data);
	x->data = malloc(4 * x->image_width * x->image_height);
    }
    else {
	glBindTexture(GL_TEXTURE_2D, x->texture);
    }
    return x->data;
}
Example #27
0
void _XResourceTex::release()
{
	if(glIsTexture(m_texID)) 
	{
		printf("delete texture:%d\n",m_texID);
		glDeleteTextures(1,&m_texID);
	}
}
void SpriteTexture::destroy()
{
	if(glIsTexture(mTextureId))
	{
		glDeleteTextures(1, &mTextureId);
		mTextureId = 0;
	}
}
Example #29
0
GC3Dboolean GraphicsContext3D::isTexture(Platform3DObject texture)
{
    if (!texture)
        return GL_FALSE;
    
    makeContextCurrent();
    return glIsTexture(texture);
}
Example #30
0
 //----------------------------------------------------------------------
 void Texture::wipe() {
     Log::trace(TAG, "Trying to delete texture handle %d", mHandle);
     if (mHandle != 0 && glIsTexture(mHandle) == GL_TRUE) {
         Log::trace(TAG, "Deleting texture handle %d", mHandle);
         glDeleteTextures(1, &mHandle);
         mHandle = 0;
     }
 }