mirror of
https://github.com/MapMakersAndProgrammers/TankiOnline2.0DemoClient.git
synced 2025-10-26 18:09:07 -07:00
58 lines
1.5 KiB
ActionScript
58 lines
1.5 KiB
ActionScript
package alternativa.engine3d.materials
|
|
{
|
|
import alternativa.engine3d.materials.compiler.Linker;
|
|
import flash.display3D.Context3D;
|
|
import flash.display3D.Program3D;
|
|
|
|
public class ShaderProgram
|
|
{
|
|
public var program:Program3D;
|
|
|
|
public var vertexShader:Linker;
|
|
|
|
public var fragmentShader:Linker;
|
|
|
|
public function ShaderProgram(vertexShader:Linker, fragmentShader:Linker)
|
|
{
|
|
super();
|
|
this.vertexShader = vertexShader;
|
|
this.fragmentShader = fragmentShader;
|
|
}
|
|
|
|
public function upload(context3D:Context3D) : void
|
|
{
|
|
if(this.program != null)
|
|
{
|
|
this.program.dispose();
|
|
}
|
|
if(this.vertexShader != null && this.fragmentShader != null)
|
|
{
|
|
this.program = context3D.createProgram();
|
|
try
|
|
{
|
|
this.program.upload(this.vertexShader.getByteCode(),this.fragmentShader.getByteCode());
|
|
}
|
|
catch(e:Error)
|
|
{
|
|
trace(A3DUtils.disassemble(fragmentShader.getByteCode()));
|
|
throw e;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.program = null;
|
|
}
|
|
}
|
|
|
|
public function dispose() : void
|
|
{
|
|
if(this.program != null)
|
|
{
|
|
this.program.dispose();
|
|
this.program = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|