Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Stage3D Implementation #24

Open
wants to merge 49 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e798f84
Initial Stage3D Stuff
Fancy2209 Sep 10, 2024
ae53bb0
Add Stage3D to SecurityDomain
Fancy2209 Sep 10, 2024
675767c
Commit Progress
Fancy2209 Sep 10, 2024
b9e8186
Consitency Fix
Fancy2209 Sep 10, 2024
af7ae3a
Add comment to remind myself
Fancy2209 Sep 10, 2024
e5edc12
Fixed by eslint
Fancy2209 Sep 10, 2024
5d8f5da
Fix requested Context Profile and Minor Fixes
Fancy2209 Sep 10, 2024
6b49026
Comit current work
Fancy2209 Sep 10, 2024
a50c368
Update Stage.ts
Fancy2209 Sep 11, 2024
723bb11
Commit work
Fancy2209 Sep 11, 2024
073ca3c
Commit Work
Fancy2209 Sep 11, 2024
2bd0f96
Commit work
Fancy2209 Sep 11, 2024
d0882ea
Vectors suck
Fancy2209 Sep 11, 2024
10ba69b
it almost works?
Fancy2209 Sep 12, 2024
7423401
Commit work
Fancy2209 Sep 13, 2024
e9ac84d
Fix
Fancy2209 Sep 13, 2024
1d2a3eb
fix
Fancy2209 Sep 13, 2024
f7ba23b
Temp Prog 3D Fix
Fancy2209 Sep 14, 2024
388d0a2
Fix DataPerVertex in VertexBuffer & Fixed by eslint
Fancy2209 Sep 16, 2024
26e0923
Merge branch 'awayfl:dev' into stage3d
Fancy2209 Sep 16, 2024
cb8705b
Add Missing classes from shumway and temp fix for setProgramConstants…
Fancy2209 Sep 16, 2024
d8d1d4c
Merge branch 'stage3d' of https://github.com/fancy2209/playerglobal i…
Fancy2209 Sep 16, 2024
9b47776
forgot to comm some changes
Fancy2209 Sep 16, 2024
10b5828
Add missing Context3D Getters and fix some oversights
Fancy2209 Sep 17, 2024
2fbf9fc
Cleanup
Fancy2209 Sep 17, 2024
ac525b3
check event
Fancy2209 Sep 17, 2024
c9f561d
Listen dor events
Fancy2209 Sep 17, 2024
1b27c86
Minor Fix
Fancy2209 Sep 20, 2024
36d2450
Implement Binary URLLoader
Fancy2209 Sep 23, 2024
4438bda
Fix flash.system.Capabilities.version
Fancy2209 Sep 23, 2024
413a535
Implement Textures
Fancy2209 Sep 23, 2024
67d90da
Ignore Mips for now, ignore setVertexBufferAt if no Program is set, p…
Fancy2209 Sep 23, 2024
81bfd52
Fix based on stage change
Fancy2209 Sep 24, 2024
cd8da2b
Revert Null Fix (Didn't work, just made nothing render)
Fancy2209 Sep 24, 2024
e2d5d5a
Fix null stuff
Fancy2209 Sep 24, 2024
7612f9e
Additional null fix
Fancy2209 Sep 24, 2024
27a99f1
Final fix for Null setVertexAt (for now)
Fancy2209 Sep 24, 2024
f923db7
Make requestContext3D async (doesn't fix all starling issues)
Fancy2209 Sep 30, 2024
869f233
Fix LoaderInfo.UncaughtErrorEvents
Fancy2209 Sep 30, 2024
6c048f0
Fix contentScaleFactor (0 breaks stuff who checks it)
Fancy2209 Sep 30, 2024
8323f4f
Comit work, fix WebPack without dist
Fancy2209 Oct 3, 2024
8d2c2f3
Merge branch 'dev' of https://github.com/awayfl/playerglobal into sta…
Fancy2209 Oct 3, 2024
89f4b90
Merge branch 'dev' of https://github.com/awayfl/playerglobal into sta…
Fancy2209 Oct 4, 2024
13357e3
Merge branch 'awayfl:dev' into stage3d
Fancy2209 Jan 29, 2025
01d1cff
Merge branch 'awayfl:dev' into stage3d
Fancy2209 Jan 29, 2025
480043c
Update Stage3D.ts
Fancy2209 Jan 29, 2025
35477a9
Update link.ts
Fancy2209 Jan 29, 2025
4d8cae4
Update link.ts
Fancy2209 Jan 29, 2025
fcf2a71
Update link.ts
Fancy2209 Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Commit Progress
Fancy2209 committed Sep 10, 2024
commit 675767cddb921e3c78153cc2c4085b41c0c8764e
7 changes: 6 additions & 1 deletion lib/display/Stage3D.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ContextGLProfile, ContextMode, Stage as AwayStage, Stage, StageManager } from "@awayjs/stage";
import { EventDispatcher } from "../events/EventDispatcher";
import { Context3D } from "../display3D/Context3D";
import { Event } from '../events/Event';
import { Context3DProfile } from "../display3D/Context3DProfile";
import { AVMStage } from "@awayfl/swf-loader";

@@ -24,6 +25,10 @@ export class Stage3D extends EventDispatcher {

}

public get context3D():Context3D {
return this._context3D
}

public requestContext3D(context3DRenderMode:String = "auto", profile:String = "baseline"):void
{
this._context3D = new Context3D(this._adaptee, profile)
@@ -49,6 +54,6 @@ export class Stage3D extends EventDispatcher {
break;

}

super.dispatchEvent(new Event(Event.CONTEXT3D_CREATE))
}
}
108 changes: 55 additions & 53 deletions lib/display3D/Context3D.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,85 @@
import { ContextWebGL, Stage as AwayStage, StageEvent } from '@awayjs/stage';
import { ContextGLDrawMode, ContextGLVertexBufferFormat, Stage as AwayStage, StageEvent } from '@awayjs/stage';
import { EventDispatcher } from "../events/EventDispatcher";
import { Context3DVertexBufferFormat } from "../display3D/Context3DVertexBufferFormat"
import { IndexBuffer3D } from "../display3D/IndexBuffer3D"
import { VertexBuffer3D } from "../display3D/VertexBuffer3D"
import { Program3D } from "../display3D/Program3D"
import { Matrix3D } from "../geom/Matrix3D"


export class Context3D extends EventDispatcher {
private _adaptee:AwayStage
private _errorChecking:boolean

constructor(awayStage:AwayStage, profile) {
super()
awayStage.addEventListener(StageEvent.CONTEXT_CREATED, function() {
this._adaptee = awayStage }
awayStage.addEventListener(StageEvent.CONTEXT_CREATED,
function() {
this._adaptee = awayStage
}
)}

// Properties
public get backBufferHeight():number {
return this._adaptee.height
}

public set backBufferHeight(value:number) {
this._adaptee.height = value
}

public get backBufferWidth():number {
return this._adaptee.width
}

public set backBufferWidth(value:number) {
this._adaptee.width = value
}

public get driverInfo():string {
return ""
}

public get enableErrorChecking():boolean {
return this._errorChecking
}

public set enableErrorChecking(value:boolean) {
this._errorChecking = value
public clear(red:number = 0.0, green:number = 0.0, blue:number = 0.0, alpha:number = 1.0, depth:number = 1.0, stencil:number = 0, mask:number = 0xffffffff):void
{
console.log("Mask: " + mask)
this._adaptee.clear(red, green, blue, alpha, depth, stencil, mask)
}


public get maxBackBufferHeight():number {
return
public configureBackBuffer(width:number, height:number, antiAlias:number, enableDepthAndStencil:boolean = true, wantsBestResolution:Boolean = false, wantsBestResolutionOnBrowserZoom:Boolean = false):void {
this._adaptee.configureBackBuffer(width, height, antiAlias, enableDepthAndStencil)
}

public set maxBackBufferHeight(value:number) {

public createIndexBuffer(numIndices:number, bufferUsage:string = "staticDraw"):IndexBuffer3D {
return new IndexBuffer3D(this._adaptee.context, numIndices)
}

public get maxBackBufferWidth():number {
return this._adaptee.width
public createProgram():Program3D{
return new Program3D(this._adaptee.context)
}

public set maxBackBufferWidth(value:number) {

public createVertexBuffer(numVertices:number, data32PerVertex:number, bufferUsage:string = "staticDraw"):VertexBuffer3D {
return new VertexBuffer3D(this._adaptee.context, numVertices, data32PerVertex)
}

public get profile():string {
return this.profile
public drawTriangles(indexBuffer:IndexBuffer3D, firstIndex:number = 0, numTriangles:number = -1):void {
if (numTriangles != -1){
var numIndices = numTriangles
} else {
var numIndices = numTriangles*3
}
this._adaptee.context.drawIndices(ContextGLDrawMode.TRIANGLES, indexBuffer._adaptee, firstIndex, numIndices)
}

public static get supportsVideoTexture():boolean {
return false
public present():void{
this._adaptee.present()
}

public get totalGPUMemory():number{
return 512
public setProgram(program:Program3D):void{
this._adaptee.context.setProgram(program._adaptee)
}

//Functions
public clear(red:number = 0.0, green:number = 0.0, blue:number = 0.0, alpha:number = 1.0, depth:number = 1.0, stencil:number = 0, mask:number = 0xffffffff):void
{
console.log("Mask: " + mask)
this._adaptee.clear(red, green, blue, alpha, depth, stencil, mask)
public setProgramConstantsFromMatrix(programType:string, firstRegister:number, matrix:Matrix3D, transposedMatrix:boolean = false):void {
//TODO: Figure out how to use ContextGL's setProgramConstantsFromArray with a Matrix3D
}

public configureBackBuffer(width:number, height:number, antiAlias:number, enableDepthAndStencil:boolean = true, wantsBestResolution:Boolean = false, wantsBestResolutionOnBrowserZoom:Boolean = false):void {
this._adaptee.configureBackBuffer(width, height, antiAlias, enableDepthAndStencil)
public setVertexBufferAt(index:number, buffer:VertexBuffer3D, bufferOffset:number = 0, format:String = "float4"):void{
switch(format) {
case Context3DVertexBufferFormat.BYTES_4:
var awayFormat = ContextGLVertexBufferFormat.BYTE_4
break;
case Context3DVertexBufferFormat.FLOAT_1:
var awayFormat = ContextGLVertexBufferFormat.FLOAT_1
break;
case Context3DVertexBufferFormat.FLOAT_2:
var awayFormat = ContextGLVertexBufferFormat.FLOAT_2
break;
case Context3DVertexBufferFormat.FLOAT_3:
var awayFormat = ContextGLVertexBufferFormat.FLOAT_3
break;
case Context3DVertexBufferFormat.FLOAT_4:
var awayFormat = ContextGLVertexBufferFormat.FLOAT_4
break;
}
this._adaptee.context.setVertexBufferAt(index, buffer._adaptee, bufferOffset, awayFormat)
}

}
7 changes: 7 additions & 0 deletions lib/display3D/Context3DVertexBufferFormat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum Context3DVertexBufferFormat{
BYTES_4 = "bytes4",
FLOAT_1 = "float1",
FLOAT_2 = "float2",
FLOAT_3 = "float3",
FLOAT_4 = "float4"
}
21 changes: 21 additions & 0 deletions lib/display3D/IndexBuffer3D.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ASObject } from "@awayfl/avm2";
import { IContextGL, IIndexBuffer } from "@awayjs/stage";

export class IndexBuffer3D extends ASObject {
static classInitializer = null;

static axClass: typeof IndexBuffer3D;

public _adaptee:IIndexBuffer

constructor(context: IContextGL, numIndices: number) {
super()
this._adaptee = context.createIndexBuffer(numIndices)
}

public uploadFromVector(data:Array<number>, startOffset:number, count:number):void{
var uint16ArrayData = new Uint16Array(data)
this._adaptee.uploadFromArray(uint16ArrayData, startOffset, count)
}

}
27 changes: 27 additions & 0 deletions lib/display3D/Program3D.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ASObject } from "@awayfl/avm2";
import { ByteArray as AwayByteArray } from "@awayjs/core";
import { IContextGL, IProgram } from "@awayjs/stage";
import { ByteArray } from "../utils/ByteArray";

export class Program3D extends ASObject {
static classInitializer = null;

static axClass: typeof Program3D;

public _adaptee:IProgram

constructor(context:IContextGL){
super()
this._adaptee = context.createProgram()

}

public dispose(){
this._adaptee.dispose()
}

public upload(vertexProgram:ByteArray, fragmentProgram:ByteArray):void {
AwayByteArray
this._adaptee.upload(vertexProgram, fragmentProgram)
}
}
20 changes: 20 additions & 0 deletions lib/display3D/VertexBuffer3D.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ASObject } from "@awayfl/avm2";
import { IContextGL, IVertexBuffer, VertexBufferWebGL } from "@awayjs/stage";

export class VertexBuffer3D extends ASObject {
public _adaptee:IVertexBuffer

static classInitializer = null;

static axClass: typeof VertexBuffer3D;

constructor(context:IContextGL, numVertices, dataPerVertex) {
super()
this._adaptee = context.createVertexBuffer(numVertices, dataPerVertex)
}

public uploadFromVector(data:Array<number>, startVertex:number, numVertices){
var dataFloat32Array:Float32Array = new Float32Array(data)
this._adaptee.uploadFromArray(dataFloat32Array, startVertex, numVertices)
}
}