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

Blank window #63

Open
RossComputerGuy opened this issue Nov 21, 2018 · 1 comment
Open

Blank window #63

RossComputerGuy opened this issue Nov 21, 2018 · 1 comment

Comments

@RossComputerGuy
Copy link

const assert = require("assert").ok;
const EventEmitter = require("events");
const fs = require("fs");
const path = require("path");
const net = require("net");
const glfw = require("node-glfw2");
const SYMS = require("./syms.js").Server;
const WebGL = require("node-webgl");

class Server extends EventEmitter {
	constructor(opts={}) {
		super();
		opts = Object.assign(JSON.parse(fs.readFileSync(path.join(__dirname,"config-defaults.json")).toString()),opts);
		
		this[SYMS["document"]] = WebGL.document();
		
		this[SYMS["canvas"]] = this[SYMS["document"]].createElement("canvas",opts.res[0],opts.res[1]);
		glfw.WindowHint(glfw.RESIZABLE,false);
		if(opts.vsync) glfw.SwapInterval(1);
		else glfw.SwapInterval(0);
		this[SYMS["document"]].setTitle("Droid.JS");
		console.log(this[SYMS["document"]]);
		
		this[SYMS["gl"]] = this[SYMS["canvas"]].getContext("experimental-webgl");
		
		this[SYMS["atb"]] = this[SYMS["document"]].AntTweakBar;
		
		this[SYMS["atb"]].Init();
		this[SYMS["atb"]].Define(" GLOBAL help='Droid.JS Alpha' ");
		this[SYMS["atb"]].WindowSize(opts.res[0],opts.res[1]);
		
		this[SYMS["document"]].requestAnimationFrame(() => this.render(),1000/opts.fps);
		
		this[SYMS["socket"]] = net.createServer(opts.net,() => {});
		this[SYMS["socket"]].listen(opts.net.port);
	}
	destroy() {
		this[SYMS["socket"]].close();
	}
	render() {
		this[SYMS["atb"]].Draw();
	}
}
module.exports = Server;

I'm working on something that requires a server, also I can't get it to not allow resizing and my DE is telling me the window isn't responding.

@RossComputerGuy
Copy link
Author

const assert = require("assert").ok;
const EventEmitter = require("events");
const fs = require("fs");
const path = require("path");
const net = require("net");
const glfw = require("node-glfw2");
const SYMS = require("./syms.js").Server;
const WebGL = require("node-webgl/lib/webgl.js");

class Server extends EventEmitter {
	constructor(opts={}) {
		super();
		opts = Object.assign(JSON.parse(fs.readFileSync(path.join(__dirname,"config-defaults.json")).toString()),opts);
		
		glfw.DefaultWindowHints();
		glfw.WindowHint(glfw.RESIZABLE,false);
		this[SYMS["window"]] = glfw.CreateWindow(opts.res[0],opts.res[1],"Droid.JS");
		glfw.MakeContextCurrent(this[SYMS["window"]]);
		if(opts.vsync) glfw.SwapInterval(1);
		else glfw.SwapInterval(0);
		
		WebGL.Init();
		
		this[SYMS["gl"]] = WebGL;
		
		this[SYMS["atb"]] = new glfw.AntTweakBar();
		this[SYMS["atb"]].Init();
		this[SYMS["atb"]].Define(" GLOBAL help='Droid.JS Alpha' ");
		this[SYMS["atb"]].WindowSize(opts.res[0],opts.res[1]);
		
		this[SYMS["clients"]] = {};
		this[SYMS["socket"]] = net.createServer(opts.net,socket => {
			// TODO: add client
		});
		this[SYMS["socket"]].listen(opts.net.port);
	}
	isRunning() {
		return !glfw.WindowShouldClose(this[SYMS["window"]]);
	}
	destroy() {
		this[SYMS["socket"]].close();
		glfw.DestroyWindow(this[SYMS["window"]]);
	}
	render() {
		var wsize = glfw.GetFramebufferSize(this[SYMS["window"]]);
		glfw.testScene(wsize.width,wsize.height);
		this[SYMS["atb"]].Draw();
		glfw.SwapBuffers(this[SYMS["window"]]);
		glfw.PollEvents();
	}
}
module.exports = Server;

This works aparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant