Skip to content

Commit

Permalink
Trying Away3D + Starling interoperability, but it appears to be broken
Browse files Browse the repository at this point in the history
Could be an issue with Away3D, Starling, OpenFL or Haxe - I've reported it on the discord. Will move on to just using Away3D for now instead
  • Loading branch information
TerryCavanagh committed Oct 5, 2023
1 parent f8aad7f commit d398652
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,windows,linux,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,windows,linux,macos

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# Support for Project snippet scope
.vscode/*.code-snippets

# Ignore code-workspaces
*.code-workspace

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,windows,linux,macos

**/experiments/
**/bin/

# Created by the Haxe sometimes with compiler information
**/dump/

# Generated translation strings
**/*/generated_translation_strings.csv
**/*/generated_translation_strings.json
Binary file added data/floor_diffuse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="Radio Silence" package="com.distractionware.radiosilence" version="1.0.0" />
<app main="Main" file="radiosilence" path="bin" />

<window width="1280" height="720"
orientation="landscape"
vsync="true" fps="60"
hardware="true"
allow-shaders="true"
require-shaders="true"
depth-buffer="false"
stencil-buffer="true"
background="0x000000" />

<window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />

<source path="src" />

<haxelib name="openfl" />
<haxelib name="starling" />
<haxelib name="away3d" />

<assets path="data" />

<config type="windows" output-directory="${platform}-${buildType}" />
</project>
58 changes: 58 additions & 0 deletions radiosilence.hxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="CustomBuild" />
<movie input="" />
<movie path="project.xml" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="1" />
<movie minorVersion="0" />
<movie platform="Lime" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="C:\coding\haxelib\lime\8,0,2\src" />
<class path="C:\coding\haxelib\starling\git\src" />
<class path="C:\coding\haxelib\away3d\git" />
<class path="C:\coding\haxelib\openfl\9,2,2\src" />
<class path="src" />
<class path="bin\windows-release\haxe" />
</classpaths>
<!-- Build options -->
<build>
<option directives="lime=8.0.2&#xA;starling=0.0.0&#xA;away3d=5.0.9&#xA;openfl=9.2.2&#xA;lime-harfbuzz&#xA;lime-openal&#xA;tools=8.0.2&#xA;lime-cairo&#xA;lime-opengl&#xA;no-compilation&#xA;native&#xA;lime-curl&#xA;lime-native&#xA;lime-vorbis&#xA;openfl-native&#xA;lime-cffi&#xA;fdb&#xA;windows&#xA;desktop" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="False" />
<option additional="--macro lime._internal.macros.DefineMacro.run()&#xA;--macro openfl.utils._internal.ExtraParamsMacro.include()&#xA;--remap flash:openfl" />
</build>
<!-- haxelib libraries -->
<haxelib>
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand>"$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb</preBuildCommand>
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
88 changes: 88 additions & 0 deletions src/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import away3d.containers.*;
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.utils.*;
import away3d.core.managers.Stage3DManager;
import away3d.core.managers.Stage3DProxy;
import away3d.events.Stage3DEvent;
import away3d.debug.AwayStats;

import openfl.display.*;
import openfl.events.*;
import openfl.geom.Vector3D;

import starling.core.*;

class Main extends Sprite {
//engine variables
private var stage3DManager:Stage3DManager;
private var stage3DProxy:Stage3DProxy;
private var away3dview:View3D;

private var starlinglayer:Starling;

//scene objects
private var plane:Mesh;

public function new(){
super();

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

initProxies();
}

private function initProxies() {
// Define a new Stage3DManager for the Stage3D objects
stage3DManager = Stage3DManager.getInstance(stage);

// Create a new Stage3D proxy to contain the separate views
stage3DProxy = stage3DManager.getFreeStage3DProxy();
stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, onContextCreated);
}

private function onContextCreated(event:Stage3DEvent) {
initAway3D();
initStarling();

//setup the render loop
stage.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}

private function initAway3D(){
// Create the first Away3D view which holds the cube objects.
away3dview = new View3D();
away3dview.stage3DProxy = stage3DProxy;
away3dview.shareContext = true;

//setup the camera
away3dview.camera.z = -600;
away3dview.camera.y = 500;
away3dview.camera.lookAt(new Vector3D());

//setup the scene
plane = new Mesh(new PlaneGeometry(700, 700), new TextureMaterial(Cast.bitmapTexture("data/floor_diffuse.jpg")));
away3dview.scene.addChild(plane);

addChild(away3dview);
addChild(new AwayStats(away3dview));
}

private function initStarling(){
starlinglayer = new Starling(StarlingLayer, stage, stage3DProxy.viewPort, stage3DProxy.stage3D);
}

private function _onEnterFrame(e:Event) {
//stage3DProxy.clear(0, 0, 0, 1, 1, 127);
stage3DProxy.clear();

away3dview.render();
starlinglayer.nextFrame();

stage3DProxy.present();

plane.rotationY += 1;
}
}
23 changes: 23 additions & 0 deletions src/StarlingLayer.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import starling.display.Quad;
import starling.display.Sprite;

class StarlingLayer extends Sprite{
private static var _instance:StarlingLayer;

public static function getInstance():StarlingLayer{
return _instance;
}

private var testquad:Quad;

public function StarlingLayer(){
_instance = this;

testquad = new Quad(500, 500, 0xFF0000);
addChild(testquad);
}

public function update(){
//testquad.rotation += 0.005;
}
}

0 comments on commit d398652

Please sign in to comment.