surface_get_texture

Returns the texture id for the given surface.

Syntax:

GML Code Example

surface_get_texture(surface_id);


Argument Description
surface_id The ID of the surface to get the width of.


Returns: Pointer


Description

This function returns a special pointer for the surface texture. This value can then be used in other draw functions, particularly in general 3D and some of the 2D primitive functions.

NOTE: When working with surfaces there is the possibility that they can cease to exist at any time due to them being stored in texture memory. You should ALWAYS check that a surface exists using surface_exists before referencing them directly. For further information see Surfaces.


Example:

GML Code Example

var tex;
 tex = surface_get_texture(surf);
 draw_primitive_begin_texture(pr_trianglestrip, tex);
 draw_vertex_texture(0, 480, 0, 0);
 draw_vertex_texture(640, 480, 1, 0);
 draw_vertex_texture(640, 480, 1, 1);
 draw_vertex_texture(0, 480, 0, 1);
 draw_primitive_end();
 

The above code will draw a 4 vertex triangle strip textured with the texture held in the "tex" variable, which is itself taken from a previously created surface.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here