• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Export Room as Image?

T

TheTrophieStars

Guest
Is it possible to export a room as an image that matches the size of the room? It would make adding assets to levels so much easier.
 
T

TheTrophieStars

Guest
But if the room is larger than my monitor's resolution (which it is) and doesn't match the aspect ratio of the monitor (which it doesn't) then it won't be an accurate image. I want to be able to save the entire room so I can draw over it in photoshop. Can a surface exist outside the game window? If so, couldn't I resize the application surface to be the size of the room and capture that with screen_save?
 

Simon Gust

Member
But if the room is larger than my monitor's resolution (which it is) and doesn't match the aspect ratio of the monitor (which it doesn't) then it won't be an accurate image. I want to be able to save the entire room so I can draw over it in photoshop. Can a surface exist outside the game window? If so, couldn't I resize the application surface to be the size of the room and capture that with screen_save?
Depending on how big the room is, a surface won't do the trick. If you're using blocks or tiles with a given minimum size, you could scaled down the surface by that number.
A room of the size 1024 x 1024 and a tile size of 16x16, would make a 64x64 surface. You can draw to a surface outside the view.
Now you just need to know what assets you want to have on your surface, and how you match an asset to a colour, so reading and writing gives the same results.
Objects can be written like this
Code:
surface_set_target(surface);
with (object)
{
 var col = make_colour_rgb(object_index, 0, 0);
 draw_point_colour(x div 16, y div 16, col);
}
surface_reset_target();
Where the red component of the pixel would equal to the object index, so a long as you never ever change the asset order in your resource tree you're fine. Otherwise you have to make a defined colour for each object / asset.
 
You can use surfaces. I don't see how the size of your monitor would affect that. The problem is depending on your room size, you potentially will have a very large surface.

So the process would be

create a surface of some size (probably size of room or a factor or multiple of it). surf = surface_create(room_width,room_height);

set that surface as the target. surface_set_target(room_width,room_height);

set a projection that covers the whole room. in gms1: d3d_set_projection(0,0,room_width,room_height,0);

draw everything that you want to show up on the surface.

reset target and save surface. surface_save(surf, name_of_file);

if you are drawing things that are partially transparent, it might be necessary to first clear the surface with a solid color, and then turn off writing to the alpha channel before drawing other things to the surface. draw_set_colour_write_enable(true, true, true, false);

I guess you could just resize the application surface and use that in this process, that could be a better solution in case draw_set_colour_write_enable doesn't end up solving the transparency problems.
 
T

TheTrophieStars

Guest
How big is your room and in what kind of structure are assets placed in the room?
I have invisible collision boxes that have placeholder sprites over them. There is some complex background art that has to be added once the level is properly designed.

You can use surfaces. I don't see how the size of your monitor would affect that. The problem is depending on your room size, you potentially will have a very large surface.
I'll try this. Thank you.
 
T

TheTrophieStars

Guest
set a projection that covers the whole room. in gms1: d3d_set_projection(0,0,room_width,room_height,0);
How do I do this in GM2?
 
I don't have GMS2 so I can't tell you what the best way of doing it is. But it looks to me like the most straightforward thing would be to set a view and projection like so:

https://docs2.yoyogames.com/

it would probably look something like this:

viewmat = matrix_build_lookat(room_width/2, room_height/2, -16000, room_width/2, room_height/2, 0, 0, -1, 0);
projmat = matrix_build_projection_ortho(room_width, room_height, 1.0, 32000.0);
camera_set_view_mat(view_camera[0], viewmat);
camera_set_proj_mat(view_camera[0], projmat);
 
T

TheTrophieStars

Guest
Woo. I didn't even need a projection, oddly enough the image doesn't appear unless I open it in paint. But it works, thanks, everyone! Edit: It was because I needed to add ".png" to the end of the file name when saving it.
 
Last edited by a moderator:
Top