wighawag / openfl-stage3d Goto Github PK
View Code? Open in Web Editor NEWStage3D API for openfl
License: zlib License
Stage3D API for openfl
License: zlib License
I've ported some simple test https://github.com/Beeblerox/openfl-stage3d-perfomance-test
and it works normally on flash and neko targets, but windows target crashes 1 second after application start, and i don't know the source of this problem, since it doesn't give me any information about the problem causing it.
Hello! i'm trying to use your lib. It's looking Great, but i have some problems (mostly because i'm newbie with OpenGL stuff).
I've took the code from your demo ( https://github.com/wighawag/OpenFLStage3DTest ) and tried to draw 4 triangles instead of 2 - i've changed only one function in Main class, here is how it's looking now:
private function onReady(event : Event) : Void{
context3D = stage3D.context3D;
context3D.configureBackBuffer(stage.stageWidth, stage.stageHeight, 0, false);
context3D.enableErrorChecking = true;
var vertexShaderSource =
"attribute vec3 vertexPosition;
attribute vec2 uv;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
//uniform mat4 matrix;
varying vec2 vTexCoord;
void main(void) {
gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);
//gl_Position = matrix * vec4(vertexPosition, 1.0);
vTexCoord = uv;
}";
//var vertexAgalInfo = '{"varnames":{"uv":"va1","matrix":"vc0","vertexPosition":"va0"},"agalasm":"m44 op, va0, vc0\\nmov v0, va1","storage":{},"types":{},"info":"","consts":{}}';
var vertexAgalInfo = '{"varnames":{"uv":"va1","modelViewMatrix":"vc0","projectionMatrix":"vc4","vertexPosition":"va0"},"agalasm":"m44 vt0, va0, vc0\\nm44 op, vt0, vc4\\nmov v0, va1","storage":{},"types":{},"info":"","consts":{}}';
var fragmentShaderSource =
"varying vec2 vTexCoord;
uniform sampler2D texture;
void main(void) {
vec4 texColor = texture2D(texture, vTexCoord);
gl_FragColor = texColor;
}";
var fragmentAgalInfo = '{"varnames":{"texture":"fs0"},"agalasm":"mov ft0, v0\\ntex ft1, ft0, fs0 <2d,wrap,linear>\\nmov oc, ft1","storage":{},"types":{},"info":"","consts":{}}';
var vertexShader = new GLSLVertexShader(vertexShaderSource, vertexAgalInfo);
var fragmentShader = new GLSLFragmentShader(fragmentShaderSource, fragmentAgalInfo);
sceneProgram = new GLSLProgram(context3D);
sceneProgram.upload(vertexShader, fragmentShader);
var logo = openfl.Assets.getBitmapData("assets/hxlogo.png");
texture = context3D.createTexture(logo.width,logo.height, Context3DTextureFormat.BGRA,false);
texture.uploadFromBitmapData(logo);
var vertices : Array<Float> = [
-100, -100, 0, 0, 0,
100, -100, 0, 1, 0,
-100, 100, 0, 0, 1,
100, 100, 0, 1, 1,
-50, -50, 0, 0, 0,
50, -50, 0, 1, 0,
-50, 50, 0, 0, 1,
50, 50, 0, 1, 1
];
vertexBuffer = context3D.createVertexBuffer(8, 5);
vertexBuffer.uploadFromVector(flash.Vector.ofArray(vertices), 0, 8);
indexBuffer = context3D.createIndexBuffer(12);
var indexes : Array<UInt> = [0,1,2,1,2,3, 0,1,2,1,2,3];
indexBuffer.uploadFromVector(flash.Vector.ofArray(indexes), 0, 12);
context3D.setBlendFactors(flash.display3D.Context3DBlendFactor.SOURCE_ALPHA, flash.display3D.Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
context3D.setRenderCallback(renderView);
}
So, as you can see, i've done following:
vertices
array;createVertexBuffer()
(8 instead of 4);uploadFromVector()
(8 as well);indexes
array (just duplicated existing indicies);createIndexBuffer()
(12 instead of 6);uploadFromVector()
(12 as well)And it didn't worked for me (it draws only first two triangles, and ignores other).
But if i want to draw one triangle and make similar changes in code (just reduce the numbers), then it works.
So i don't know where is the problem: is it me, or is it library problem.
Thanks in advance, Alexander
@wighawag Hello, I recently came across this project, and was wondering if it might be ready for worth adding it to this project of mine https://github.com/drkibitz/openfl-bunnymark
I've been trying to get my own version using OpenGLView up and running, but I am totally not there yet.
Let me know when you get a chance, thanks!
Hi wighawag,
Stage3D uses "null" in setVertexBufferAt/setTextureAt/setScissorRectange/.. APIs to release resources. Could you help implement them in openfl-stage3d?
Thank you.
Jian
It seems like it works incorrectly. Here what i have on flash:
and here what i have on cpp (windows):
the code for this test can be found here: https://github.com/Beeblerox/openfl-stage3d-perfomance-test/tree/master/space3d
It is ignored on native targets, so graphics is being drawn without any clipping
E:\user\desktop\OpenFLStage3DTest-master>openfl build project.xml flash
D:\HaxeToolkit\haxe\lib/stage3d-glsl/0,1,0/flash/display3D/shaders/ShaderUtils.h
x:11: characters 7-40 : Class not found : com.adobe.utils.AGALMiniAssembler
i can't see any DisplayObject which had been added to stage on native targets (but it works on flash target).
Maybe it is connected somehow with http://www.openfl.org/index.php?cID=11989&ccm_paging_p=1&time=1376130309#msg12694
i made a 3d framework of openfl stage3d.
but the cpp target not work with light.
https://github.com/matrix3d/native3d.
so i change your project with vec3.find it have some error or not?
var fragmentShaderSource = "varying vec2 vTexCoord; uniform sampler2D texture; uniform vec3 c1; void main(void) { vec4 texColor = texture2D(texture, vTexCoord); gl_FragColor = texColor * vec4(c1, 1); }";
E:\user\desktop\OpenFLStage3DTest-master>openfl build project.xml html5
D:\HaxeToolkit\haxe\lib/openfl-stage3d/0,1,0/flash/display3D/textures/Texture.hx
:58: characters 113-117 : flash.utils.ByteArray should be js.html.Uint8Array
D:\HaxeToolkit\haxe\lib/openfl-stage3d/0,1,0/flash/display3D/textures/Texture.hx
:58: characters 113-117 : For function argument 'array'
D:\HaxeToolkit\haxe\lib/openfl-stage3d/0,1,0/flash/display3D/Context3D.hx:434: c
haracters 30-38 : openfl.gl.GLUniformLocation should be Int
Is this still GPL? Or, is it okay to use this code with less-strict licenses like MIT? I've heard that current Stage3D impl is based on the code from this repo.
I've also found Stage3D layer code in https://github.com/away3d/away3d-core-openfl and says nothing specifically about licensing of Stage3D layer.
We've moved source code to OpenFL repo long time ago because we thought it was licensed under MIT license.
@jgranick is now thinking about switching to new code base, partly because of licencing issue, but I cannot switch to that one immediately. So I want to keep using code which originated from this repo.
Flash target works well, but when I select cpp target (windows/android) compiler says:
Class not found : flash.display.Stage3D
My environment Windows 7 sp1 32-bit, openfl 2.2.1, FlashDevelop 4.6.4.1.
Probably it's openfl syntax issue, may be with it's packages auto substitution "openfl" instead of "flash".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.