|
|
Goombert
|
|
Reply #2 Posted on: January 13, 2014, 06:41:29 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
GM8, the sprite font is occupying 91 KB, but in ENIGMA it's taking up 28 MB . File size is not the same as memory size, images generally take up a lot more in memory than they do on your file system. The formula that LGM calculates that size is only an estimate and it is... # of Images * Width * Height * 4 Bytes each pixel This is just meant to be an estimate of the image decompressed at runtime, since even compressed PNG's or JPEG's or GIF's will be as large as a bitmap in RAM once your game actually loads it, I found it to be more useful than the file size which is what GM shows you. I went and tested in LGM and created a sprite with 220 subimages all 9x14 and it read the memory usage as 81.21KB. So I will probably need to see that font and the GMK so I can figure out what is going wrong. Also why does it show as 219 subimages in GM and 8x13 which is different than the ENIGMA picture? Anyway, as Harri said try calling texture_set_interpolation(false); directly before drawing text with that font. And again it would also help if you could give us a GMK with the font causing the issue.
|
|
« Last Edit: January 13, 2014, 06:54:35 am by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
mazapan
|
|
Reply #3 Posted on: January 13, 2014, 05:56:13 pm |
|
|
Joined: Oct 2012
Posts: 15
|
This is just meant to be an estimate of the image decompressed at runtime, since even compressed PNG's or JPEG's or GIF's will be as large as a bitmap in RAM once your game actually loads it, I found it to be more useful than the file size which is what GM shows you.
Yes, i thought GM was showing the file size instead of memory size. Also why does it show as 219 subimages in GM and 8x13 which is different than the ENIGMA picture?
The font in question is "Myriad Pro". I created two versions of it. V1 is 8pts size (8x13) and V2 is 9pts size (9X14). The capture from GM shows Myriad V1. Here is the 9x14 font: https://www.dropbox.com/s/jt8qecpz05wzrty/myriad9x14.PNGI added texture_set_interpolation(false) to the DRAW EVENT, but it's not working, the font is still distorted.
|
|
|
Logged
|
|
|
|
Goombert
|
|
Reply #4 Posted on: January 13, 2014, 11:21:51 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Ok so I investigated some more and LGM is definitely reporting the memory usage of the image wrong. As you can see I imported the image and then deleted all frames at it was reporting 100kb's per frame. It appears my Mario game has the same issue. I believe the actually memory usage was correct, since the method I am using asks Java's BufferedImage for its data size. This size is dependent upon the file format the image was loaded and decompressed from. So I believe it is correct in that it is showing the correct serialized memory usage, but incorrect in that it is not showing the correct ENIGMA memory usage without the compression information, which is what we want it to do. The following stack overflow question seems to back this up. http://stackoverflow.com/questions/3294388/make-a-bufferedimage-use-less-ramI have updated LateralGM on the extra packages page with the bug fix that will give a much better estimate of memory usage and actually use the width * height * 4 bytes per pixel formula I originally thought it was using. http://enigma-dev.org/docs/Wiki/Install:Extra_Packages#LateralGMJust download it and replace the lateralgm.jar in your enigma folder inside the enigma-dev folder. As for the drawing bug. draw_set_font(fnt); draw_text(0, 0, "!!!!!!!!!!!!!!!!!"); That code produces the following image with the one character 128x128. This is interesting because my Mario game uses a sprite font at that exact size and renders fine. So I am still looking for the drawing issue and a resolution to it.
|
|
« Last Edit: January 14, 2014, 12:47:00 am by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
Goombert
|
|
Reply #6 Posted on: January 14, 2014, 01:07:27 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
I might have it fixed tonight I don't know, I just finished investigating the memory bug in like 5 minutes. But as you can see I can reproduce the drawing bug easily and the glitched texture looks like something I've encountered before, I just need to look.
But on a side note, if you don't mind me asking. In your opinion as a game developer, which is more useful to you... a) the file size b) as close to or an approximate of memory usage Which of those do you find more useful? I decided to use memory usage because you can see file usage on your computer, memory gives you an idea of RAM usage for your game. So do you like it being memory or file size shown in the resource editors?
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
mazapan
|
|
Reply #7 Posted on: January 14, 2014, 03:37:15 am |
|
|
Joined: Oct 2012
Posts: 15
|
Which of those do you find more useful? I decided to use memory usage because you can see file usage on your computer, memory gives you an idea of RAM usage for your game. So do you like it being memory or file size shown in the resource editors?
From the point of game development, I think memory usage is more useful. You can check File size in windows, or in image viewers. But what about having the two of them in the editor? As a ENIGMA user, i guess that would be the better choice. I'd say i prefer memory usage as close as possible, but an approximation is enough.
|
|
« Last Edit: January 14, 2014, 03:48:13 am by mazapan »
|
Logged
|
|
|
|
|
Goombert
|
|
Reply #9 Posted on: January 14, 2014, 09:49:30 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
But what about having the two of them in the editor? As a ENIGMA user, i guess that would be the better choice. That is just the thing though, to get that size I'd have to write it to the hard drive each time you open an editor or make a change, which I'm afraid would make the editors kind of laggy. I'd say i prefer memory usage as close as possible, but an approximation is enough. It is about as close as you can get though, because like every program when it loads an image it becomes decompressed and 4 bytes per pixel. Images are usually never stored with compression in RAM. However, it is important to note, the sound editor does give the exact size of your sound file because it actually stores the file where as images are just converted to BMP when saved into the GMK, I think it is part of the spec? How do you just bind sprite as a font? You need to use the newly implemented draw_text_sprite (I haven't tested that function though) or we need to implement/fix font_add_sprite function. I will also pull the newest commit and try a sprite font. Usually a bug like that showed by Robert is when a) Batcher didn't change the texture before drawing or b) The texture is just non-existent. Ok, what Harri? When you use a sprite font you call font_add_sprite which returns an index to a newly added font that is made from the sprite, it packs the subimages together. Also, OpenGL1 does not use batching, which is why that doesn't explain the problem. Anyway, this is the new way sprite fonts were meant to work, thus why draw_text_sprite was deprecated. At any rate, I realized my Mario game does not actually use the font_add_sprite call it has the sprite with the characters and calculates what subimage to use on it's own, I have no idea why I did it that way. Edit: Greg's game Ass Blasters uses a sprite font the correct way and it renders properly with dimensions 36x72 Edit 2: I have found the issue. It appears to be an issue with the font packing function, I tried importing the glyphs with a 12x12 and 15x15 pixel size and they stopped coming out all messed up, well they look mashed together because I imported them that way but I mean the image scanlines are not all distorted the characters are legible. So for now just resize all the glyphs so that width and height are a multiple of 3 or 4 byte aligned, not quite sure. I have submitted a bug to the tracker for you as well. https://github.com/enigma-dev/enigma-dev/issues/614
|
|
« Last Edit: January 14, 2014, 10:43:19 am by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
|
|
mazapan
|
|
Reply #13 Posted on: January 15, 2014, 03:12:10 am |
|
|
Joined: Oct 2012
Posts: 15
|
So for now just resize all the glyphs so that width and height are a multiple of 3 or 4 byte aligned, not quite sure. I have submitted a bug to the tracker for you as well.
I resized the subimages to 9 X 15, but now the game crashes.Running "C:/Users/Maz/AppData/Local/Temp/egm455983022837088688.exe" Game returned -1073741819
the 9X14 font doesn't crash the game. I also have another question. I created the font so the gray border around the letters is not fully opaque. When the PNG is imported into ENIGMA, the border looks 100% opaque. Is ENIGMA discarding the alpha information? Thank you guys. EDIT: Sorry, the crash was caused by me: i forgot using font_add_sprite for the 9X15 font . The 9X15 font is still distorted. A 12 X 12 subimage size displays the font properly.
|
|
« Last Edit: January 15, 2014, 04:35:00 pm by mazapan »
|
Logged
|
|
|
|
Goombert
|
|
Reply #14 Posted on: January 16, 2014, 05:29:44 pm |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Alrighty good to know we've resolved the issue to the metrics of the font sheet then. When the PNG is imported into ENIGMA, the border looks 100% opaque. Is ENIGMA discarding the alpha information? There is an easy way to test that, hit the edit button and see if the transparency was lost with Paint.NET or whatever image editing tool you use, and, of course, no it shouldn't be doing that.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|