Created
May 4, 2017 15:49
-
-
Save Beeblerox/2bd6f015ced993ada0e91e7b654f9215 to your computer and use it in GitHub Desktop.
Texture creation test in Lime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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