예제 #1
0
//===========================================================================
//
//	Frees all associated resources
//
//===========================================================================
void FHardwareTexture::Clean(bool all)
{
    int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size();

    if (all)
    {
        for (int i=0; i<cm_arraysize; i++)
        {
            DeleteTexture(glTexID[i]);
        }
        //glDeleteTextures(cm_arraysize,glTexID);
        memset(glTexID,0,sizeof(unsigned int)*cm_arraysize);
    }
    else
    {
        for (int i=1; i<cm_arraysize; i++)
        {
            DeleteTexture(glTexID[i]);
        }
        //glDeleteTextures(cm_arraysize-1,glTexID+1);
        memset(glTexID+1,0,sizeof(unsigned int)*(cm_arraysize-1));
    }
    for(unsigned int i=0; i<glTexID_Translated.Size(); i++)
    {
        DeleteTexture(glTexID_Translated[i].glTexID);
    }
    glTexID_Translated.Clear();
    if (glDepthID != 0) glDeleteRenderbuffers(1, &glDepthID);
}
void FGLRenderBuffers::ClearExposureLevels()
{
	for (auto &level : ExposureLevels)
	{
		DeleteTexture(level.Texture);
		DeleteFrameBuffer(level.Framebuffer);
	}
	ExposureLevels.Clear();
	DeleteTexture(ExposureTexture);
	DeleteFrameBuffer(ExposureFB);
}
void FGLRenderBuffers::ClearAmbientOcclusion()
{
	DeleteFrameBuffer(LinearDepthFB);
	DeleteFrameBuffer(AmbientFB0);
	DeleteFrameBuffer(AmbientFB1);
	DeleteTexture(LinearDepthTexture);
	DeleteTexture(AmbientTexture0);
	DeleteTexture(AmbientTexture1);
	for (int i = 0; i < NumAmbientRandomTextures; i++)
		DeleteTexture(AmbientRandomTexture[i]);
}
void FGLRenderBuffers::ClearBloom()
{
	for (int i = 0; i < NumBloomLevels; i++)
	{
		auto &level = BloomLevels[i];
		DeleteFrameBuffer(level.HFramebuffer);
		DeleteFrameBuffer(level.VFramebuffer);
		DeleteTexture(level.HTexture);
		DeleteTexture(level.VTexture);
		level = FGLBloomTextureLevel();
	}
}
예제 #5
0
void ModelType::DeleteModel()
{
   for (int i = 0; i < numObjects; i++)
   {
      glDeleteLists(cDispObj[i].DispList, 1);
      glDeleteLists(cDispObj[i].EdgeList, 1);

      DeleteTexture(cDispObj[i].TextMap);
      DeleteTexture(cDispObj[i].GlowMap);
      DeleteTexture(cDispObj[i].SpecMap);
   }
}
예제 #6
0
CRendererVAAPI::~CRendererVAAPI()
{
  for (int i = 0; i < NUM_BUFFERS; ++i)
  {
    DeleteTexture(i);
  }
}
예제 #7
0
bool CRendererVAAPI::CreateTexture(int index)
{
  if (m_format == RENDER_FMT_VAAPINV12)
  {
    return CreateNV12Texture(index);
  }

  YV12Image &im     = m_buffers[index].image;
  YUVFIELDS &fields = m_buffers[index].fields;
  YUVPLANE  &plane  = fields[0][0];

  DeleteTexture(index);

  memset(&im    , 0, sizeof(im));
  memset(&fields, 0, sizeof(fields));
  im.height = m_sourceHeight;
  im.width  = m_sourceWidth;
  im.cshift_x = 1;
  im.cshift_y = 1;

  plane.pixpertex_x = 1;
  plane.pixpertex_y = 1;

  plane.id = 1;

  return true;
}
예제 #8
0
bool CRendererVTB::CreateTexture(int index)
{
  YUVBUFFER &buf = m_buffers[index];
  YuvImage &im = buf.image;
  YUVPLANE (&planes)[YuvImage::MAX_PLANES] = buf.fields[0];
  
  DeleteTexture(index);
  
  memset(&im    , 0, sizeof(im));
  memset(&planes, 0, sizeof(YUVPLANE[YuvImage::MAX_PLANES]));
  
  im.height = m_sourceHeight;
  im.width = m_sourceWidth;
  
  planes[0].texwidth  = im.width;
  planes[0].texheight = im.height;
  planes[1].texwidth  = planes[0].texwidth >> im.cshift_x;
  planes[1].texheight = planes[0].texheight >> im.cshift_y;
  planes[2].texwidth  = planes[1].texwidth;
  planes[2].texheight = planes[1].texheight;

  for (int p = 0; p < 3; p++)
  {
    planes[p].pixpertex_x = 1;
    planes[p].pixpertex_y = 1;
  }

  planes[0].id = 1;
  return true;
}
예제 #9
0
bool CRendererVTB::CreateTexture(int index)
{
  YV12Image &im = m_buffers[index].image;
  YUVFIELDS &fields = m_buffers[index].fields;
  YUVPLANES &planes = fields[0];
  
  DeleteTexture(index);
  
  memset(&im    , 0, sizeof(im));
  memset(&fields, 0, sizeof(fields));
  
  im.height = m_sourceHeight;
  im.width = m_sourceWidth;
  
  planes[0].texwidth  = im.width;
  planes[0].texheight = im.height;
  planes[1].texwidth  = planes[0].texwidth >> im.cshift_x;
  planes[1].texheight = planes[0].texheight >> im.cshift_y;
  planes[2].texwidth  = planes[1].texwidth;
  planes[2].texheight = planes[1].texheight;

  for (int p = 0; p < 3; p++)
  {
    planes[p].pixpertex_x = 1;
    planes[p].pixpertex_y = 1;
  }

  planes[0].id = 1;
  return true;
}
예제 #10
0
CRendererVDPAU::~CRendererVDPAU()
{
  for (int i = 0; i < NUM_BUFFERS; ++i)
  {
    DeleteTexture(i);
  }
}
예제 #11
0
void CTerritoryTexture::RecomputeTexture(int unit)
{
	// If the map was resized, delete and regenerate the texture
	if (m_Texture)
	{
		CmpPtr<ICmpTerrain> cmpTerrain(m_Simulation, SYSTEM_ENTITY);
		if (cmpTerrain && m_MapSize != (ssize_t)cmpTerrain->GetVerticesPerSide())
			DeleteTexture();
	}

	if (!m_Texture)
		ConstructTexture(unit);

	PROFILE("recompute territory texture");

	std::vector<u8> bitmap;
	bitmap.resize(m_MapSize * m_MapSize * 4);

	CmpPtr<ICmpTerritoryManager> cmpTerritoryManager(m_Simulation, SYSTEM_ENTITY);
	if (!cmpTerritoryManager)
		return;

	const Grid<u8> territories = cmpTerritoryManager->GetTerritoryGrid();

	GenerateBitmap(territories, &bitmap[0], m_MapSize, m_MapSize);

	g_Renderer.BindTexture(unit, m_Texture);
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize, m_MapSize, GL_RGBA, GL_UNSIGNED_BYTE, &bitmap[0]);
}
예제 #12
0
void CleanupCuda(){
    if(m_pbo){
        DeletePBO(&m_pbo);
    } 
    if(m_image){
        DeleteTexture(&m_image);
    } 
}
예제 #13
0
FGLRenderBuffers::~FGLRenderBuffers()
{
	ClearScene();
	ClearPipeline();
	ClearEyeBuffers();
	ClearShadowMap();
	DeleteTexture(mDitherTexture);
}
예제 #14
0
 virtual ~VboScene()
 {
     DeleteTexture();
     glBindBuffer(GL_ARRAY_BUFFER, buffer);
     glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STATIC_DRAW);
     glBindBuffer(GL_ARRAY_BUFFER, 0);
     glDeleteBuffers(1, &buffer);
 }
예제 #15
0
CRendererVTB::~CRendererVTB()
{
  for (int i = 0; i < NUM_BUFFERS; ++i)
  {
    ReleaseBuffer(i);
    DeleteTexture(i);
  }
}
void FGLRenderBuffers::ClearPipeline()
{
	for (int i = 0; i < NumPipelineTextures; i++)
	{
		DeleteFrameBuffer(mPipelineFB[i]);
		DeleteTexture(mPipelineTexture[i]);
	}
}
예제 #17
0
bool PsiTexture::OpenPsi(const char *input, int min_filter, int mag_filter)
{
	const char check_string[] = "Piano's Single Alpha Image Format 1.0";
	FILE *psifile = NULL;
	int i;

	if(texture_number != -1)
	DeleteTexture();

	// open psi file
	psifile = fopen(input, "rb");
	if(psifile == NULL) return false;

	// check whether file header is valid or not
	int inchar = fgetc(psifile);
	if(inchar != sizeof(check_string)-1) return false;
	char *compare_string = new char[inchar];
	fread(compare_string, 1, inchar, psifile);
	for(i = 0; i < inchar; i++)
		if(check_string[i] != compare_string[i]) return false;
	delete compare_string;

	// get image sizes
	original_size_x = 0;
	original_size_y = 0;
	extended_size_x = 0;
	extended_size_y = 0;
	inchar = fgetc(psifile);
	inchar /= 4;
	for(i = 0; i < inchar; i++)
		extended_size_x |= fgetc(psifile) << (8*i);
	for(i = 0; i < inchar; i++)
		extended_size_y |= fgetc(psifile) << (8*i);
	for(i = 0; i < inchar; i++)
		original_size_x |= fgetc(psifile) << (8*i);
	for(i = 0; i < inchar; i++)
		original_size_y |= fgetc(psifile) << (8*i);

	// copying colors to memory
	unsigned char *data = 
		new unsigned char[extended_size_x * extended_size_y * 4];
	int buffersize = original_size_x * 4;
	int skipsize = extended_size_x * 4;
	for(i = 0; i < original_size_y; i++)
		fread(data + (i*skipsize), 1, buffersize, psifile);
	fclose(psifile);

	// generating texture
	glGenTextures(1, &texture_number);
	glBindTexture(GL_TEXTURE_2D, texture_number);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, extended_size_x, extended_size_y, 0,
		GL_RGBA, GL_UNSIGNED_BYTE, data);
	delete data;

	return true;
}
예제 #18
0
//===========================================================================
// CloseData
//===========================================================================
void CloseData(void)
{
	// Free the def groups.
	for(int i = 0; i < NUM_GROUPS; i++)
		while(root[i].next != &root[i]) DeleteTexture(root[i].next);
	
	// Free the patch names.
	while(plist.next != &plist) DeletePatch(plist.next);			
}
예제 #19
0
파일: engine3d.cpp 프로젝트: jratajew/ogl
GfxContext::~GfxContext()
{
    if(m_TriangleProgram)
        delete m_TriangleProgram;

    // Release textures:
    for(auto tex : m_Textures)
        DeleteTexture(tex.second);
    m_Textures.clear();
}
예제 #20
0
CRendererVTB::~CRendererVTB()
{
  if (m_textureCache)
    CFRelease(m_textureCache);

  for (int i = 0; i < NUM_BUFFERS; ++i)
  {
    DeleteTexture(i);
  }
}
void FGLRenderBuffers::ClearScene()
{
	DeleteFrameBuffer(mSceneFB);
	DeleteFrameBuffer(mSceneDataFB);
	if (mSceneUsesTextures)
	{
		DeleteTexture(mSceneMultisample);
		DeleteTexture(mSceneFog);
		DeleteTexture(mSceneNormal);
		DeleteTexture(mSceneDepthStencil);
	}
	else
	{
		DeleteRenderBuffer(mSceneMultisample);
		DeleteRenderBuffer(mSceneFog);
		DeleteRenderBuffer(mSceneNormal);
		DeleteRenderBuffer(mSceneDepthStencil);
	}
}
예제 #22
0
void Backbuffer::Resize(uint32_t width, uint32_t height)
{
  DeleteTexture();
  CreateTexture(width, height);

  m_Projection = Orthographic(-1.0f, 2 * width / (float)m_TextureSize - 1,
    -1.0f, 2 * height / (float)m_TextureSize - 1,
    1.0f, -1.0f);

  m_Image.resize(height, width);
}
void FGLRenderBuffers::ClearEyeBuffers()
{
	for (auto handle : mEyeFBs)
		DeleteFrameBuffer(handle);

	for (auto handle : mEyeTextures)
		DeleteTexture(handle);

	mEyeTextures.Clear();
	mEyeFBs.Clear();
}
/**
 *  Setzt den Texturfilter auf einen bestimmten Wert.
 *
 *  @author FloSoft
 */
void glArchivItem_BitmapBase::setFilter(unsigned int filter)
{
    if(this->filter == filter)
        return;

    this->filter = filter;

    // neugenerierung der Textur anstoßen
    if(texture != 0)
        DeleteTexture();
}
예제 #25
0
void UIDirect3D9Window::ReleaseTexture(UIImage *Image)
{
    if (!m_textureHash.contains(Image))
        return;

    Image->SetState(UIImage::ImageReleasedFromGPU);

    m_textureExpireList.removeAll(Image);
    D3D9Texture *texture = m_textureHash.take(Image);
    m_hardwareCacheSize -= texture->m_internalDataSize;
    DeleteTexture(texture);
}
예제 #26
0
/**	Updates the texture
 *
 *	@returns	The texture buffer ID of this object
 *
 *	Operation:
 *		-#	Attempts to use the vfs to open the file
 *		-#	Sets the filename to the file requested
 *		-#	If the file handle is valid, continue to load the image
 *		-#	Read the file contents
 *		-#	Close the file handle
 *		-#	Create a 32bit image buffer to store the image in
 *		-#	Create two pixel objects, src/dest, the dest pixel object is 32bit, the src is whatever bpp the source image was
 *		-#	Setup the pixel objects to read pixels from the src image and convert them to 32bit pixels
 *		-#	Loop through the pixels, converting each to 32bit
 *		-#	delete any temporary memory allocated
 *		-#	Return the texture buffer id
 */
int OGLImageTexture::UpdateTexture(void)
{
	DeleteTexture();

	VFSHandle *handle = fusion->vfs->Open(m_filename);

	if(handle != NULL){
		SetFilename(handle->Filename());

		m_fileinfo = reinterpret_cast<ImageFileInfo *>(handle->Read());

		if(m_fileinfo != NULL){
			m_width		=	m_fileinfo->width;
			m_height	=	m_fileinfo->height;
			m_numcomp	=	m_fileinfo->bpp>>3;

			unsigned char *buffer = m_fileinfo->data;

			if(m_fileinfo->bpp < 24){
				m_numcomp = 3;

				buffer = new unsigned char[m_width * m_height * m_numcomp];

				Pixel	*s = NULL;
				Pixel	*d = new Pixel24Bit(buffer);

				switch(m_fileinfo->bpp){
					case 8:	{ s = new Pixel8Bit	(m_fileinfo->data,m_fileinfo->palette);	}break;
					case 16:{ s = new Pixel16Bit(m_fileinfo->data,5,6,5);				}break;
				};

				d->SetInput(s->GetOutput());

				int numpixels = m_width * m_height;

				for(int offset=0;offset<numpixels;offset++){
					s->ReadPixel(offset);
					d->WritePixel(offset);
				}

				delete		s;
				delete		d;
				delete[]	m_fileinfo->data;
			}

			CreateTexture(buffer);

			delete[]	buffer;
			delete[]	m_fileinfo->palette;
			delete		m_fileinfo;
		}	
예제 #27
0
    STARTDECL(gl_deletetexture) (Value &i)
    {
        auto it = texturecache.begin();
        while (it != texturecache.end())    // this is potentially expensive, we're counting on gl_deletetexture not being needed often
        {
            if (it->second == uint(i.ival)) texturecache.erase(it++);
            else ++it;
        }

        // the surfaces in meshes are still potentially referring to this texture, but OpenGL doesn't care about illegal texture ids, so neither do we

        DeleteTexture(i.ival);

        return Value();
    }
/**	Updates the texture
 *
 *	@returns	The texture buffer ID of this object
 *
 *	Operation:
 *		-#	Allocate a buffer the size requested in the constructor
 *		-#	Initialise the buffer with zeros
 *		-#	Call the procedure, passing the buffer, width and height to it
 *		-#	Generate an OpenGL texture object
 *		-#	Enable GL_TEXTURE_2D
 *		-#	Load the buffer containing the 32bit image data into an opengl texture object (This is not the same as a Fusion Texture Object)
 *		-#	Delete any temporary memory allocated
 *		-#	Return the texture buffer id
 */
int OGLProceduralTexture::UpdateTexture()
{
	DeleteTexture();

	unsigned char *buffer = new unsigned char[m_width*m_height*m_numcomp];

	memset(buffer,0,m_width*m_height*m_numcomp);

	buffer = m_proc(buffer,m_width,m_height,m_numcomp);

	CreateTexture(buffer);

	delete[] buffer;

	return m_tbid;
}
예제 #29
0
uint MythRenderOpenGL1::CreateHelperTexture(void)
{
    if (!m_glTexImage1D)
    {
        LOG(VB_GENERAL, LOG_WARNING, LOC + "glTexImage1D not available.");
        return 0;
    }

    makeCurrent();

    uint width = m_max_tex_size;
    uint tmp_tex = CreateTexture(QSize(width, 1), false,
                                 GL_TEXTURE_1D, GL_FLOAT, GL_RGBA,
                                 GL_RGBA16, GL_NEAREST, GL_REPEAT);

    if (!tmp_tex)
    {
        DeleteTexture(tmp_tex);
        return 0;
    }

    float *buf = NULL;
    buf = new float[m_textures[tmp_tex].m_data_size];
    float *ref = buf;

    for (uint i = 0; i < width; i++)
    {
        float x = (((float)i) + 0.5f) / (float)width;
        StoreBicubicWeights(x, ref);
        ref += 4;
    }
    StoreBicubicWeights(0, buf);
    StoreBicubicWeights(1, &buf[(width - 1) << 2]);

    EnableTextures(tmp_tex);
    glBindTexture(m_textures[tmp_tex].m_type, tmp_tex);
    m_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA16, width, 0, GL_RGBA, GL_FLOAT, buf);

    LOG(VB_PLAYBACK, LOG_INFO, LOC +
        QString("Created bicubic helper texture (%1 samples)") .arg(width));
    delete [] buf;
    doneCurrent();
    return tmp_tex;
}
예제 #30
0
파일: LOSTexture.cpp 프로젝트: stev47/0ad
void CLOSTexture::RecomputeTexture(int unit)
{
	// If the map was resized, delete and regenerate the texture
	if (m_Texture)
	{
		CmpPtr<ICmpTerrain> cmpTerrain(m_Simulation, SYSTEM_ENTITY);
		if (cmpTerrain && m_MapSize != (ssize_t)cmpTerrain->GetVerticesPerSide())
			DeleteTexture();
	}

	bool recreated = false;
	if (!m_Texture)
	{
		ConstructTexture(unit);
		recreated = true;
	}

	PROFILE("recompute LOS texture");

	std::vector<u8> losData;
	losData.resize(GetBitmapSize(m_MapSize, m_MapSize));

	CmpPtr<ICmpRangeManager> cmpRangeManager(m_Simulation, SYSTEM_ENTITY);
	if (!cmpRangeManager)
		return;

	ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(g_Game->GetPlayerID()));

	GenerateBitmap(los, &losData[0], m_MapSize, m_MapSize);

	if (CRenderer::IsInitialised() && g_Renderer.m_Options.m_SmoothLOS && recreated)
	{
		g_Renderer.BindTexture(unit, m_TextureSmooth1);		
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
		g_Renderer.BindTexture(unit, m_TextureSmooth2);		
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
	}

	g_Renderer.BindTexture(unit, m_Texture);
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]);
}