Пример #1
0
void forgetSpriteBank (spriteBank & forgetme) {

	deleteTextures (forgetme.myPalette.numTextures, forgetme.myPalette.tex_names);
	if (forgetme.isFont) {
		deleteTextures (forgetme.myPalette.numTextures, forgetme.myPalette.burnTex_names);
		delete [] forgetme.myPalette.burnTex_names;
		forgetme.myPalette.burnTex_names = NULL;
	}
	
	delete [] forgetme.myPalette.tex_names;
	forgetme.myPalette.tex_names = NULL;
	delete [] forgetme.myPalette.tex_w;
	forgetme.myPalette.tex_w = NULL;
	delete [] forgetme.myPalette.tex_h;
	forgetme.myPalette.tex_h = NULL;
	
	if (forgetme.myPalette.pal) {
		delete  [] forgetme.myPalette.pal;
		forgetme.myPalette.pal = NULL;
		delete  [] forgetme.myPalette.r;
		forgetme.myPalette.r = NULL;
		delete  [] forgetme.myPalette.g;
		forgetme.myPalette.g = NULL;
		delete  [] forgetme.myPalette.b;
		forgetme.myPalette.b = NULL;
	}

	delete forgetme.sprites;
	forgetme.sprites = NULL;
    
    
    // TODO: also remove sprite bank from allLoadedBanks
    // And add a function call for this function to the scripting language
}
Пример #2
0
Splot_EnemyFleet::~Splot_EnemyFleet ()
{
  deleteTextures ();
  clear ();
//  inherited::dealloc(1);
  ACE_ASSERT (inherited::size_ == 0);
}
Пример #3
0
void shutdownDisplay(gDisplay *d) {
  deleteTextures(d);
  deleteFonts();
  // deleteBitmaps(d);
  SystemDestroyWindow(d->win_id);
  printf("window destroyed\n");
}
Пример #4
0
void killLightMap () {
	deleteTextures (1, &lightMap.name);
	lightMap.name = 0;
	if (lightMap.data) {
		delete lightMap.data;
		lightMap.data = NULL;
	}
	lightMapNumber = 0;
}
Пример #5
0
void killZBuffer () {
	if (zBuffer.tex) {
		deleteTextures (1, &zBuffer.texName);
		zBuffer.texName = 0;
		delete zBuffer.tex;
		zBuffer.tex = NULL;
	}
	zBuffer.numPanels = 0;
	zBuffer.originalNum =0;
}
Пример #6
0
void killParallax () {
	while (parallaxStuff) {

		parallaxLayer * k = parallaxStuff;
		parallaxStuff = k -> next;

		// Now kill the image
		deleteTextures (1, &k -> textureName);
		delete k -> texture;
		delete k;
		k = NULL;
	}
}
Пример #7
0
EnemyAmmo::~EnemyAmmo()
{
	ActiveAmmo *cur;
	ActiveAmmo *del;

	clear();
	cur = ammoPool->next;
	while(cur)
	{
		del = cur;
		cur = cur->next;
		delete del;
	}

	deleteTextures();

	for(int i = 0; i < NUM_ENEMY_AMMO_TYPES; i++)
	{
		delete ammoRoot[i];
	}
	delete ammoPool;
}
Пример #8
0
void Map::loadTextures(){
    deleteTextures();

    // Tileset
    QImage imageTileset(1, 1, QImage::Format_ARGB32);
    QString path = m_mapProperties->tileset()->picture()->getPath(
        PictureKind::Tilesets);
    if (!path.isEmpty() && QFile::exists(path)) {
        imageTileset = QImage(path);
    }
    else {
        imageTileset.fill(QColor(0, 0, 0, 0));
    }
    m_textureTileset = createTexture(imageTileset);

    // Characters && walls
    loadCharactersTextures();
    loadSpecialPictures(PictureKind::Walls, m_texturesSpriteWalls);
    loadAutotiles();

    // Object square
    QImage imageObjectSquare(":/textures/Ressources/object_square.png");
    m_textureObjectSquare = createTexture(imageObjectSquare);
}
Пример #9
0
bool loadHSI (FILE * fp, int x, int y, bool reserve) {

	int t1, t2, n;
	unsigned short c;
	GLubyte * target;
	int32_t transCol = reserve ? -1 : 63519;
	int picWidth;
	int picHeight;
	int realPicWidth, realPicHeight;
	long file_pointer = ftell (fp);

	png_structp png_ptr;
	png_infop info_ptr, end_info;


	int fileIsPNG = true;

	// Is this a PNG file?

	char tmp[10];
	size_t bytes_read = fread(tmp, 1, 8, fp);
	if (bytes_read != 8 && ferror (fp)) {
		debugOut("Reading error in loadHSI.\n");
	}
    if (png_sig_cmp((png_byte *) tmp, 0, 8)) {
		// No, it's old-school HSI
		fileIsPNG = false;
		fseek(fp, file_pointer, SEEK_SET);

		picWidth = realPicWidth = get2bytes (fp);
		picHeight = realPicHeight = get2bytes (fp);
	} else {
		// Read the PNG header

		png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
		if (!png_ptr) {
			return false;
		}

		info_ptr = png_create_info_struct(png_ptr);
		if (!info_ptr) {
			png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
			return false;
		}

		end_info = png_create_info_struct(png_ptr);
		if (!end_info) {
			png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
			return false;
		}
		png_init_io(png_ptr, fp);		// Tell libpng which file to read
		png_set_sig_bytes(png_ptr, 8);	// 8 bytes already read

		png_read_info(png_ptr, info_ptr);

		png_uint_32 width, height;
		int bit_depth, color_type, interlace_type, compression_type, filter_method;
		png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);

		picWidth = realPicWidth = width;
		picHeight = realPicHeight = height;

		if (bit_depth < 8) png_set_packing(png_ptr);
		png_set_expand(png_ptr);
		if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr);
		if (bit_depth == 16) png_set_strip_16(png_ptr);

		png_set_add_alpha(png_ptr, 0xff, PNG_FILLER_AFTER);

		png_read_update_info(png_ptr, info_ptr);
		png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_method);

		//int rowbytes = png_get_rowbytes(png_ptr, info_ptr);

	}


	GLfloat texCoordW = 1.0;
	GLfloat texCoordH = 1.0;
	if (! NPOT_textures) {
		picWidth = getNextPOT(picWidth);
		picHeight = getNextPOT(picHeight);
		texCoordW = ((double)realPicWidth) / picWidth;
		texCoordH = ((double)realPicHeight) / picHeight;
	}

	if (reserve) {
		if (! resizeBackdrop (realPicWidth, realPicHeight)) return false;
	}

	if (x == IN_THE_CENTRE) x = (sceneWidth - realPicWidth) >> 1;
	if (y == IN_THE_CENTRE) y = (sceneHeight - realPicHeight) >> 1;
	if (x < 0 || x + realPicWidth > sceneWidth || y < 0 || y + realPicHeight > sceneHeight) return false;

	if (fileIsPNG) {
		unsigned char * row_pointers[realPicHeight];
		for (int i = 0; i<realPicHeight; i++)
			row_pointers[i] = backdropTexture + 4*i*picWidth;

		png_read_image(png_ptr, (png_byte **) row_pointers);
		png_read_end(png_ptr, NULL);
		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
	} else {
		for (t2 = 0; t2 < realPicHeight; t2 ++) {
			t1 = 0;
			while (t1 < realPicWidth) {
				c = (unsigned short) get2bytes (fp);
				if (c & 32) {
					n = fgetc (fp) + 1;
					c -= 32;
				} else {
					n = 1;
				}
				while (n --) {
					target = backdropTexture + 4*picWidth*t2 + t1*4;
					if (c == transCol || c == 2015) {
						target[0] = (GLubyte) 0;
						target[1] = (GLubyte) 0;
						target[2] = (GLubyte) 0;
						target[3] = (GLubyte) 0;
					} else {
						target[0] = (GLubyte) redValue(c);
						target[1] = (GLubyte) greenValue(c);
						target[2] = (GLubyte) blueValue(c);
						target[3] = (GLubyte) 255;
					}
					t1++;
				}
			}
		}
	}

	GLuint tmpTex;

	glGenTextures (1, &tmpTex);
	glBindTexture(GL_TEXTURE_2D, tmpTex);
	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 (gameSettings.antiAlias < 0) {
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	} else {
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	}
	texImage2D (GL_TEXTURE_2D, 0, GL_RGBA, picWidth, picHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, backdropTexture, tmpTex);


	//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);


	float btx1;
	float btx2;
	float bty1;
	float bty2;
	if (! NPOT_textures) {
		btx1 = backdropTexW * x / sceneWidth;
		btx2 = backdropTexW * (x+realPicWidth) / sceneWidth;
		bty1 = backdropTexH * y / sceneHeight;
		bty2 = backdropTexH * (y+realPicHeight) / sceneHeight;
	} else {
		btx1 = (float) x / sceneWidth;
		btx2 = (float) (x+realPicWidth) / sceneWidth;
		bty1 = (float) y / sceneHeight;
		bty2 = (float) (y+realPicHeight) / sceneHeight;
	}

	const GLfloat btexCoords[] = { 
		btx1, bty1,
		btx2, bty1,
		btx1, bty2,
		btx2, bty2 
	}; 

	setPixelCoords (true);

	int xoffset = 0;
	while (xoffset < realPicWidth) {
		int w = (realPicWidth-xoffset < viewportWidth) ? realPicWidth-xoffset : viewportWidth;

		int yoffset = 0;
		while (yoffset < realPicHeight) {
			int h = (realPicHeight-yoffset < viewportHeight) ? realPicHeight-yoffset : viewportHeight;

			glClear(GL_COLOR_BUFFER_BIT);	// Clear The Screen

			const GLfloat vertices[] = { 
				(GLfloat)-xoffset, (GLfloat)-yoffset, 0., 
				(GLfloat)realPicWidth-xoffset, (GLfloat)-yoffset, 0., 
				(GLfloat)-xoffset, (GLfloat)-yoffset+realPicHeight, 0.,
				(GLfloat)realPicWidth-xoffset, (GLfloat)-yoffset+realPicHeight, 0.
			};

			const GLfloat texCoords[] = { 
				0.0f, 0.0f,
				texCoordW, 0.0f,
				0.0f, texCoordH,
				texCoordW, texCoordH
			}; 

			if (backdropExists) {
				// Render the sprite to the backdrop
				// (using mulitexturing, so the old backdrop is seen where alpha < 1.0)
				glActiveTexture(GL_TEXTURE2);
				glBindTexture (GL_TEXTURE_2D, backdropTextureName);
				glActiveTexture(GL_TEXTURE0);

				glUseProgram(shader.paste);
				GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
				if (uniform >= 0) glUniform1i(uniform, 0); // No lighting

				setPMVMatrix(shader.paste);

				setPrimaryColor(1.0, 1.0, 1.0, 1.0);
				glBindTexture(GL_TEXTURE_2D, tmpTex);
				//glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

				drawQuad(shader.paste, vertices, 3, texCoords, NULL, btexCoords);

				glUseProgram(0);

			} else {
				// It's all new - nothing special to be done.

				glUseProgram(shader.texture);
				setPMVMatrix(shader.texture);

				glBindTexture(GL_TEXTURE_2D, tmpTex);

				setPrimaryColor(1.0, 0.0, 0.0, 0.0);

				drawQuad(shader.texture, vertices, 1, texCoords);

				glUseProgram(0);
			}

			// Copy Our ViewPort To The Texture
			copyTexSubImage2D(GL_TEXTURE_2D, 0, x+xoffset, y+yoffset, viewportOffsetX, viewportOffsetY, w, h, backdropTextureName);

			yoffset += viewportHeight;
		}

		xoffset += viewportWidth;
	}
	deleteTextures(1, &tmpTex);

	setPixelCoords (false);

	backdropExists = true;
	return true;
}
Пример #10
0
void nosnapshot () {
	deleteTextures (1, &snapshotTextureName);
	snapshotTextureName = 0;
}
Пример #11
0
void killBackDrop () {
	deleteTextures (1, &backdropTextureName);
	backdropTextureName = 0;
	backdropExists = false;
}
Пример #12
0
Splot_BackgroundSea::~Splot_BackgroundSea ()
{
  deleteTextures ();
}
Пример #13
0
void reloadArt() {
    printf("reloading art\n");
    deleteTextures(game->screen);
    loadArt();
}
Пример #14
0
void shutdownDisplay(Visual *d) {
    deleteTextures(d);
    deleteFonts();
    nebu_Video_Destroy(d->win_id);
    // printf("[video] window destroyed\n");
}
Пример #15
0
Splot_StatusDisplay::~Splot_StatusDisplay ()
{
  deleteTextures ();
}
Пример #16
0
inline void deleteAny(const NamedTexture & v){
    deleteTextures(1,&v);
}