Closed darmie closed 7 years ago
I am trying to render a 2d texture using Snow OpenGL API, but I can't seem to get it to work. All I get is a blank screen.
This is my Main.hx
Main.hx
import snow.api.Debug.*; import snow.types.Types; import snow.modules.opengl.GL; typedef UserConfig = {} @:log_as('app') class Main extends snow.App { public var texture(default, null): GLTexture; private var image:AssetImage = null; function new() {} override function config( config:AppConfig ) : AppConfig { config.window.title = 'Enzo Game Engine'; return config; } override function ready() { log('ready'); //app.window.onrender = render; var imgProm = app.assets.image("assets/test.png"); imgProm.then(function(d){ image = d; log(d.image.pixels); }, function(e){ throw e; }); } override function onkeyup( keycode:Int, _,_, mod:ModState, _,_ ) { if( keycode == Key.escape ) { app.shutdown(); } } override function update( delta:Float ) { } override function tick( delta:Float ) { GL.clearColor(1.0, 1.0, 1.0, 1.0); GL.clear(GL.COLOR_BUFFER_BIT); GL.enable(GL.TEXTURE_2D); //sprite.draw(); texture = GL.createTexture(); GL.bindTexture(GL.TEXTURE_2D, texture); GL.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, this.image.image.width, this.image.image.height, 0, GL.RGBA, GL.UNSIGNED_BYTE, this.image.image.pixels); GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR); GL.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR); GL.generateMipmap(GL.TEXTURE_2D); GL.bindTexture(GL.TEXTURE_2D, null); GL.drawElements(GL.TRIANGLES, 1, GL.UNSIGNED_SHORT, 0); } }
I am trying to render a 2d texture using Snow OpenGL API, but I can't seem to get it to work. All I get is a blank screen.
This is my
Main.hx