Tag Info

Hot answers tagged

118

"Memory" and "efficiency" are commonly misused terms, so I'll give you an answer for four different elements that may affect the performance of your game. I will be oversimplifying way too many things to keep it short and concise, but there are tons of inaccuracies in this text below, so take it with a pinch of salt. However, the main concepts should be ...


22

Here are the “restored” images, thanks to tillberg's further research: As expected, there is a 5-byte block marker every about 0x4020 bytes. The format appears to be the following: struct marker { uint8_t tag; /* 1 if this is the last marker in the file, 0 otherwise */ uint16_t len; /* size of the following block (little-endian) */ uint16_t ...


18

Based on Sam's suggestion, I forked James' code at https://github.com/tillberg/skyrim and was able to successfully extract n_letter.png from the Skyrim Textures BSA file. The "file_size" given by the BSA headers is not the actual final file size. It includes some header info as well as some random chunks of useless-seeming data scattered around. The ...


18

Once an image is loaded off the disk and is formatted for rendering, it will use the same amount of memory regardless of whether that image was saved to disk using PNG, JPEG, or GIF. General rule of thumb: JPEG is a lossy format, and will degrade image quality in order to make the image smaller on disk. PNG, on the other hand, is a lossless image format, ...


18

Hue-shifting is one possibility that would let you get a range of colors without losing the color details. The basic idea is to convert each pixel from RGB to HSV space, then offset the hue by a user-defined amount, then convert back to RGB. Actually, this can be done more efficiently by applying a rotation matrix to the RGB values: create a matrix that ...


14

You think XNA has a lot of surface formats? Boy, you ain't seen nothing yet. Joking aside, I suspect the reason has to do with a combination of legacy/backwards compatibility and flexibility. Obviously, once a surface format is introduced it needs to be supported forward for some time, or the entire API takes a backwards compatibility hit. So there are ...


12

Just a couple of things to add to @Marco's answer: .gif is sorely outdated. I would completely avoid using .gif files as much as possible. I think people only use them these days because of in-browser animations, and animated png's aren't well supported at this time. So all you have is jpg and png. PNG: Is lossless. The only thing you are considering ...


12

Yes, it is possible for a user to get the images in GPU memory. It's not likely they'd get them by dumping the entire GPU memory space (though with specialized hardware, drivers or debugging software such a thing is possible -- Visual Studio has a powerful GPU debugger these days). Rather, they can get them from CPU memory, which is much easier. Your game's ...


9

I doubt such a power tool exists, game companies create in house tools, max-scripts and Photoshop scripts to make up for the lack thereof. They generally adapt because Photoshop is the tool that all artists need to know how to use. Even if you created a tool with all the functionality of Photoshop, artists would still prefer the original and even if you ...


9

Precisely, to repeat a texture. So, if you have a quad, and the texture coordinates go from 0 to 1, the texture will be drawn once. If the coordinates go from 0 to 2 and wrap is set to GL_REPEAT, then the texture will be drawn twice. Try it and see it by yourself


8

Some color data will be lost or changed regardless of your texture format. However, a bigger problem will be gamma correction. Gamma correction can be a tricky subject since your game will not appear visually the same across all display technologies and finding a single solution is not going to be easy. These might help you out: ...


8

At the request of commenters... Warning to Pyglet professionals: There may be a nice Pyglet way to do this, and this isn't it. It's a nice OpenGL way. You have been warned! You can do this in OpenGL by first binding the texture, then calling glTexParameteri or similar varients. You can do this in Pyglet by importing OpenGL: from pyglet.gl import * You ...


8

The commonly used formats are PNG and PVR. The PNG (Portable Network Graphics) format is compressed but lossless. It's a commonly used format (basically any image-editing software can write to PNG). The PVR (PowerVR) format is a format that is much closer to the native memory structure of images on the GPU of the iPhone. Therefore it also allows for some ...


8

The problem you are facing is that you can't simply "tint" the whole image, the appearance you see is more than just a base color. For one you have fine gradients from one one material to the other, but more importantly you also have reflections,highlights and shadows, which are not influenced by the base color. (Those are basically added on top of it.) So ...


7

The image format is only a way to save raw data of pixels, so as long as you use bitmaps, the format usually does not make a difference in execution after the loading step. What matters is the pixel data supplied to the graphics API. There are three formats commonly used in the web: .gif The (now normally deprecated) GIF format is used for images with 256 ...


7

For best quality results, you should probably first render the SVG at high resolution and then scale it down, using a good scaling algorithm. For example, here's the result I got by taking your 256 × 357 px image and scaling it down to 71 × 99 pixels in GIMP using Lanczos3 resampling: It looks noticably sharper than the version you got using ...


5

sRGB is the default color space for most of todays operating systems. From Wikipedias entry about sRGB: ... one can generally assume, in the absence of embedded profiles or any other information, that any 8-bit-per-channel image file or any 8-bit-per-channel image API or device interface can be treated as being in the sRGB color space. What that ...


5

How are you saving these PNG files from Fireworks? Fireworks uses PNG as its native file format, but adds meta-data to it (such as information about layers, effects etc.). This could be the reason why the Fireworks PNG files are larger than a PNG saved using Photoshop. Since your iPhone app won't need any of the meta-information Fireworks stores, you should ...


5

Use a texture atlas, or a tilesheet of some kind. One texture in video memory is much less work than 100 textures in video memory.


5

Since "2D Programming" is really now just 3D Programming, but with an orthographic viewpoint, what you need to look for is how to draw 2D things in 3D, using OpenGL. When I did this I found the websites out there were often incomplete, too old or were written for the "wrong" OpenGL. And that's what you need to choose first - do you want to write things on ...


5

Set graphics.PreferredBackBufferFormat = SurfaceFormat.Color; in your Game constructor. XNA sets the backbuffer to SurfaceFormat.Bgr565 (16 bit) by default.


5

Edit: Just saw that my answer was based on your code but didn't actually answer your question. I kept the old answer in case you can use that information. Edit 2: I have fixed 2 issues with the original code: - The +1 addition in the calculation of end x and y was by mistake inside the brackets, but it needs to be added after the division. - I forgot to ...


5

Not really, no. There's one scenario: you're calling the draw method so often you don't leave yourself the resources to do anything else. That's not your FPS negatively affecting how the game runs, though. The cause would be a badly written game, engine or framework; the FPS would just be a side-effect. You have a glitch that surfaces on your desktop. Your ...


5

The parallelogram coordinates you're using are easier to work with, but they do have the drawback of being weird for rectangular maps. One approach is to store it with the offset coordinates but actually use parallelogram coordinates in your game logic. Observation: in each row of the map, the grid data is contiguous. All the wasted space is on the left ...


5

Not all textures use texture coordinates that come from the mesh data. For example, with projective texturing, you transform the world into the space of the texture. Well, a lot of that world falls outside the [0, 1] range of the texture. Without some sort of clamping mode in place, you're going to get problems.


5

I suspect you are using an inefficient implementation of the flood fill algorithm especially that the application freezes when applied on large images. By looking quickly at your code I can identify few problems It seems your code has a Big O( N^2 * K ) and might even be O(N^3), which translates to your code like this: toProcessList.Count // Looping ...


5

In C++, a char is an integral data type. It holds numbers, and on most implementations you are likely to encounter, it will be capable of holding 8 bits of data. The 24-bit RGB color representation (the most common one that does not encode transparency information) uses 8 bits for each red, blue and green channel. Thus, a single char can hold a single color ...


5

JPG is lossy. Don't use that for sprites -- you will end up with nasty artifacts that will look bad. There's a couple reasons you might want to use colur-keying, but they're a bit lost in todays hardware. Taking a quick look at color key advantages: Pros They use up less disk space -- there is no alpha channel to store By consequence, their memory foot ...


4

You need a bigger image, or a (slightly) smaller ball. It is a known issue that raster image algorithms tend to create ugly aliases on round(ish) objects, if they touch the 'edges'. The easiest fix is adding a small 'background space' to all your balls. So for each of your generated tiles, instead of this: +-----+ |.000.| |00000| |00000| |00000| |.000.| ...



Only top voted, non community-wiki answers of a minimum length are eligible