Skip to content

Instantly share code, notes, and snippets.

@Beeblerox
Created May 4, 2017 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beeblerox/2bd6f015ced993ada0e91e7b654f9215 to your computer and use it in GitHub Desktop.
Save Beeblerox/2bd6f015ced993ada0e91e7b654f9215 to your computer and use it in GitHub Desktop.
Texture creation test in Lime
package;
import lime.graphics.opengl.WebGLContext;
import lime.app.Application;
import lime.utils.UInt8Array;
class Main extends Application {
public function new()
{
super();
}
public override function onPreloadComplete():Void
{
switch (renderer.context)
{
case OPENGL (gl):
createTexture(gl, 150, 150);
createTexture(gl, 150, 100);
createTexture(gl, 256, 256);
createTexture(gl, 256, 128);
trace("done");
default:
throw "Unsupported render context";
}
}
private function createTexture(gl:WebGLContext, width:Int, height:Int):Void
{
trace("trying to create texture " + width + " by " + height + "pixels.");
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
var data:UInt8Array = null;
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
gl.bindTexture(gl.TEXTURE_2D, null);
trace("success!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment