Giter Site home page Giter Site logo

openfl-stage3d's People

Contributors

beeblerox avatar drkibitz avatar greg209 avatar longde123 avatar m22spencer avatar player-03 avatar wighawag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openfl-stage3d's Issues

Can't draw more than 2 triangles with the code from demo

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:

  1. added data for 4 additional vertices into vertices array;
  2. set the new number of vertices in the createVertexBuffer() (8 instead of 4);
  3. set the new number of vertices in the uploadFromVector() (8 as well);
  4. added 6 vertex indicies into indexes array (just duplicated existing indicies);
  5. set new number of vertex indicies in createIndexBuffer() (12 instead of 6);
  6. set the new number of vertex indicies in 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

Bunnymark

@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!

no work on flash

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

is it there a some error of glsl shader vec3?

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);
            }";

no work on html5

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 it okay to use this in closed source applications?

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.

Unknown class Stage3D for cpp targets

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".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.