Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - eishiya

Pages: [1]
1
Graphics / Re: Text outline incorrect on bitmap TTF
« on: July 23, 2020, 03:21:51 pm »
SFML just uses Freetype to read the font information. If the font doesn't support outlines properly, then there's nothing SFML can do.
Are the text outlines not generated by SFML, though? Can SFML not choose which data to use as the base for them, just as it chooses whether to display the vector outline or the bitmap for the glyph?

2
General / Re: BG & FG Level design ?
« on: July 17, 2020, 08:28:02 pm »
It's quite common for games to use a mix of large images and tiles. For example, a sidescroller game might use a large image for the sky and tiles for everything else, or there may be large drawn image layers for the terrain and tiles for the interactive elements.

Another option is to use a whole lot of freely positioned sprites rather than tiles. Examples of games using that approach are Blasphemous and Lunafon. Even among tile-based games, it's not uncommon to have freely positioned sprites for props.

Different approaches yield different looks, so if you look long enough, you'll find many different ways of doing it.

3
Graphics / Text outline incorrect on bitmap TTF
« on: July 17, 2020, 08:01:17 pm »
I'm using a font which is a TTF with an embedded bitmap, and empty outlines for all the glyphs. SFML renders the glyphs correctly (shows the bitmaps, and not the empty outlines), but if I try to use an outline with this font, it appears to outline the empty font outlines rather than the bitmaps, producing squares behind the text instead of an outline.

Here's an example with 2px black outlines:


If I use an all-outline font, the outlines are correct. I have not tested with pure bitmap fonts because I don't have any that are compatible with SFML.

4
Graphics / Re: help me about sprites!
« on: July 17, 2020, 07:45:52 pm »
You can use sf::Texture::loadFromMemory to achieve this. This function takes a byte array and the array's length as parameters. If you hard-code the array with the binary data for your image, you'll have essentially embedded the image into your code.

An example from my code:

Code: [Select]
cursor.defaultTexture.loadFromMemory("\x89\x50\x4e\x47\xd\xa\x1a\xa\x0\x0\x0\xd\x49\x48\x44\x52\x0\x0\x0\x6\x0\x0\x0\x8\x8\x6\x0\x0\x0\xda\xc6\x8e\x38\x0\x0\x0\x37\x49\x44\x41\x54\x8\xd7\x65\xcc\xd1\xa\x0\x20\x8\x43\xd1\xbb\xfd\xff\x3f\xdb\x4b\xd9\x32\x41\x90\x1d\x19\x40\xed\x7d\xc6\x0\x55\xc5\x44\x9f\x63\xa2\xf3\x2b\xd1\xb3\xfb\xe0\x7\x92\x6e\x95\xa4\xe\xda\xb3\x25\x61\x1\x50\x1f\x13\x6\x81\x80\xaf\xc6\x0\x0\x0\x0\x49\x45\x4e\x44\xae\x42\x60\x82", 112);
That long string of hex values is a char array representing a small PNG image, and 112 is the number of bytes in that array, i.e. the original file's size.

I'm not aware of any existing tool that converts arbitrary files into byte strings like this, so I wrote my own in JavaScript that converts files into escaped hex strings like the one above. You can find it here. It runs in the browser, but I recommend saving that page so you can run it locally.


I only recommend doing this for very small, fixed files, the bare minimum needed to communicate to the user that the main data failed to load in the event that happens, or only if the sum size of your images is very small even when decompressed into RAM and VRAM. Including the art in your code means that the data can't be loaded and unloaded dynamically, which increases your RAM/VRAM usage. For games with larger or many textures, this can lead to running out of memory even on good hardware.

5
Graphics / Re: Arrays of vertex arrays?
« on: August 20, 2018, 12:47:52 am »
The usual way to do what you're trying to do is a single VertexArray, where every set of four vertices is a quad. So, the vertices at index 0~3 are your first quad, the vertices at index 4~7 are your second quad, and so on.

To access the Nth quad within the array, you'd use N*4+i, where i is the index of the corner of the quad that you want (i ranges from 0 to 3). N is multiplied by 4 because there are four vertices per quad. Using this, you could write some helper functions or a wrapper to give you easier reads/writes at a given quad index N.

Pages: [1]
anything