OpenGLView, Render, Objects3D

Hello everyone!
I’m try understand how to make architecture classes with OpenGLView. But… Have some troubles in it.

In example, class View3D (OpenGLView):

import openfl.display.OpenGLView;
import openfl.display.Sprite;
import openfl.geom.Rectangle;

class View3D {

	private var view:OpenGLView;
	private var objects:Array<Object3D>;
	public function new(layer:Sprite) {
		if (OpenGLView.isSupported) {
			view = new OpenGLView();
			view.render = _render;
	public function add(object:Object3D):Void {
		if (objects == null) objects = [];
	private function _render(rect:Rectangle):Void {
		GL.clearColor(0.0, 0.0, 0.0, 1.0);
		//render objects:
		if (objects != null) {
			for (i in 0...objects.length) {
	private function _update():Void {
		//Time to make anything.

Question. What i need realize in class Object3D? In example, Object3D is realize the cube. Then i need func for initialize buffer/texture and render func for calls from View3D. Need to create a shader program in Object3D (or it’s need make in View3D)?

I want to make 3D scene and just create any primitives to adding on scene.

view3d.add(new Object3D());

Some like this. May be the question is not clearly. Sorry for my english.
I understand how to draw primitives (in single class Main), but I want to split all tasks on the classes.

I think you’re mixing metaphors

If you use OpenGLView, it works like WebGL. That’s one whole route

The openfl.display3d.* classes are designed to try and emulate Stage3D, which is a whole set of Flash-based APIs for 3D. If you have a choice, I’d recommend going straight OpenGLView, with standard WebGL code.

Check out the “SimpleOpenGLView” or “HerokuShaders” samples for examples of what it looks like

1 Like