• 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!

Windows [Solved] Drawing transformed views, surfaces, or what ever works.

Brenden

Member
I am trying to draw a portion of the application surface and then draw it at a different area. The thing I want to do is to transform that portion of the surface so each corner has its own x and y. An example would be to transform the surface to look like a trapezoid.

The reason why I am using surfaces and not sprite transformations, is to get the objects that I have within that portion of the application surface to be stretched and moved with it.

My intent is to have 6 portions of the application surface and have them drawn to look like a cube. (only 3 faces will be visible at a time)

If this would be possible without using d3d (3d stuff in gamemaker) that would be great.
 

CMAllen

Member
You could use draw_primitive_() functions, I think. In both GMS1.4 and GMS2, the manually only explicitly states support for sprites or backgrounds (which is odd for GMS2, since it doesn't have 'background' assets anymore), which means destroying and recreating them every step to reflect changes to the application_surface. I'm not sure that's an ideal solution. I do recall a free extension on the marketplace that handled skewing, which should accomplish the same thing, but I think that was for sprites.

Doing this with surfaces does not seem to be an innate part of GMS capabilities.
 

Brenden

Member
So I think I have it, yet the surface isn't being drawn to the screen.
Here is what I have.
Code:
if !surface_exists(surface1){
    surface1 = surface_create(400, 400);
    surface_set_target(surface1);
    draw_clear_alpha(c_black, 0);
    surface_reset_target();
    view_surface_id[1] = surface1;
}

draw_set_colour(c_white);
var tex = surface_get_texture(surface1);
draw_primitive_begin_texture(pr_trianglestrip, tex);
    draw_vertex_texture(face1[? "x3"], face1[? "y3"], 0, 1);//bottom left
    draw_vertex_texture(face1[? "x1"], face1[? "y1"], 0, 0);//top left
    draw_vertex_texture(face1[? "x4"], face1[? "y4"], 1, 1);//bottom right
    draw_vertex_texture(face1[? "x2"], face1[? "y2"], 1, 0);//top right
draw_primitive_end();
So I'm creating a surface named respectively surface1. I then clear the surface and assign it to view[1]. Next I get the texture for the surface and draw a primitive (which at the moment is just a rectangle) with the previous texture.

The face1[? #] are just ds maps for the x and y chords.
I do know that the primitive drawing dose work with a background texture, but not the surface that I have on it at the moment.

I am using a view in the game to only show a fraction of the room if that has any weird effect.

If I'm doing something wrong please tell me.

EDIT:
So it turns out it was because the view was not active or turned on. The surface now draws to the screen as a primitive! Yay.... I'm going to mess around with it until it works the way I hope.
 
Last edited:
Top