Jump to content

  • Log In with Google      Sign In   
  • Create Account


WEBGL Game; things started in C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 27 February 2014 - 01:13 PM

I posted two questions almost exactly two years ago, and have since done a bit of work on game logic and database interaction with C++ and mysql. I have python in there as well and I repeat some of the functionality with it, but for what I am doing, C++ seems ok and magnitudes faster than messing with data in PHP. Additionally and since two years has passed, I'm happy that I have chosen languages (C++, Python) that are stable and not here today, gone/forked/changed tomorrow.

 

I'm no expert in C++ or Python yet, but things are coming along and I want to start spitting out something visual. I'm seeing WEBGL as something viable, but I'm not sure how C++ fits, aside from a long chain of interpreters/compilers/converters - which sounds terribly messy and vulnerable to obsolescence as my development slowly chunks along year after year.

 

Language really doesn't matter at this point, as I'm not invested very heavily into anything library specific; I just don't to go back to PHP. I can do Python, would prefer C++ and understand JS is required, but I will compromise if the chain to WEBGL/JS is short.

 

I work on a remote VPS Debian/Ubuntu build, if that is any help in commenting. So I'm either going to start serving up web pages (the plan) or I need to start working on a client (huge downer, with added complication network-wise).

 

Any advice on moving forward?

 

Thank you!


Edited by trowtlip, 27 February 2014 - 01:14 PM.


Sponsor:

#2 Zaoshi Kaba   Crossbones+   -  Reputation: 3606

Like
0Likes
Like

Posted 27 February 2014 - 01:41 PM

I'm a little confused. You mention doing programming with C++ and want to create something visual; do you mean 2D or 3D game?

You can use WebGL for that, but you'll have to create everything using Javascript, C++ has no place there.

However if you wish to use C++ with graphics then you need to look into OpenGL or DirectX. There's also SFML and other options but internally they use OpenGL or DirectX.



#3 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 27 February 2014 - 01:53 PM

3D.

 

I have read of some options, which kind of get's me to this post. I learned about asm.js which will take C++ and make a sort of complied JS that works for WEBGL. Though further reading, adds further middle steps to truly make it work.

 

OpenGL, SFML.. Are these becoming web technologies so-to-speak? 

 

Sounds like I'll still be stuck with client/server solution instead of a web interface. And realistically, I could spend many months moving onto network/multiplayer stuff, so I guess I still don't need anything visual. Would be nice though - maybe flesh out some of the creative concpts.

 

Thanks for your reply!


Edited by trowtlip, 27 February 2014 - 02:01 PM.


#4 timothyjlaird   Members   -  Reputation: 404

Like
4Likes
Like

Posted 27 February 2014 - 07:12 PM

Just so you understand...WebGL is not c++...it is JavaScript and GLSL with calls to OpenGL ES2 running in an HTML5 canvas. If you are going to code CPP then use full OpenGL.

 

OpenGL ES2 has a reduced feature set targeted at lower end hardware. It it designed to run in a browser which means you have to pander to people with crappy hardware and all resources have to be loaded asynchronously (ex. textures, 3d models, shader files). It is not designed to compete with full OpenGL on performance or quality. However...it works on most peoples machines...portability is it's strength. Does that clear anything up for you?



#5 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 27 February 2014 - 09:44 PM

I'd like the browser to be my entry point. I'd like something other than JS or PHP be handle backend work, and with my VPS configured how I choose, it seems I could come up with something better than just JS. Couldn't I have C++ handle the database and backend work, with the interface in WEBGL?

 

Right now, I just want to place some objects in 3D space that I can assign data to, interact with and provide feedback through the WEBGL interface. I don't really want to deal with a client per say right now. It's a matter of convenience I suppose; I can write code through SSH as opposed to setting up a dev environment on every computer I may be at, so I can develop client. I'm figuring WEBGL in a webpage allows essentially an instant client wherever.

 

Any suggestions with all of that? Is my post in the right category?

 

Thanks for the reply btw!



#6 Karsten_   Members   -  Reputation: 1447

Like
0Likes
Like

Posted 28 February 2014 - 11:30 AM

You can have a 100% c++ solution using Emscripten (C++ -> Javascript compiler (including loads of open-source tech like SDL, GL, libpng etc...))

 

For the backend you can use Wt (http://www.webtoolkit.eu/wt) which allows you to code logic (in a similar way to PHP) but also provide an entire web server (or can be used as a cgi plugin for Apache).

 

I use both these technologies for my own projects and they work great. The only annoying bit is that even though you can code in C++, you are still constrained to what can be done in a web browser such as your client can only connect to a web socket server and you cannot write to the local filesystem using things like std::ofstream.


Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#7 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 28 February 2014 - 03:24 PM

Thank you!

 

WT looks pretty interesting in itself. I've installed it and I think I'm going to read about that. WT is probably a good foundation for what I'd like to do, so I need to get connected to SQL and get some query output from what I have going. I suppose I need some node.js or IO library of some sort, to help with the WEBGL end of it. 

 

If you have any tidbits on what you've done/experienced though WT, please let me know if you can; I'd certainly appreciate bridges over any upcoming pitfalls.



#8 Karsten_   Members   -  Reputation: 1447

Like
0Likes
Like

Posted 01 March 2014 - 05:23 AM

Well, to communicate the frontend C++/Emscripten/HTML5 to the backend C++/Wt server I needed to use websockets (since the underlying Javascript that the browser interprets cannot use raw sockets).

 

It is pretty tricky to find a decent websocket library so if you have the time, I highly recommend implementing your own. However the best one I found was (http://websocketserver.de) which once you cut the Lua out of it is much cleaner than the rest.

 

With minimal changes this websocket server can work alongside the Wt library. As for communicating with a database (which is pretty necessary for players to save their game / scores etc since javascript is unable to save locally*), I used sqlite and there were no complexities getting it working alongside websocketserver.de or Wt. I imagine something like MariaDB or Postgres will have no issues either.

 

*HTML5 might be able to store data in cookies or even using a certain API that a couple of the latest browsers support but I don't know if Emscripten can access that directly without inlining some Javascript into your program.


Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#9 papulko   Members   -  Reputation: 787

Like
0Likes
Like

Posted 01 March 2014 - 10:04 AM

I've been using Dart (https://www.dartlang.org/) for a webgl project over the last couple of weeks and i can really recommend it. It has a really clean syntax that is easy to pick up if you're coming from a c++ or java background. Also, it compiles into native (super optimized) javascript which makes browser compability a non-issue. 



#10 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 01 March 2014 - 11:06 AM

Thanks Karsten_,

 

I'll get the websocketserver running next. I don't think I will be rolling my own socket server too soon though.



#11 trowtlip   Members   -  Reputation: 119

Like
0Likes
Like

Posted 20 March 2014 - 01:12 PM

thank you for all the replies!

 

I guess I should look at Dartlang as well...

 

I'm getting terribly frustrated. Wt is more than I want; so much API to decipher to get the pieces I want. cpp-netlib is about the level I want to be working from, but doesnt intend to support websocket, and I'm not sure I want to stick myself without that option. Poco is about the same as Wt, which are both a bit more bloat than I think I need (both following the Qt idea). 

 

Maybe just use boost & write my own everything? I wasn't planning on going there (mostly for lack of experience), but it seems like the only way to get what I want.

 

Now I'm looking at node.js with (or without) native plugins (plugins = more complication, but does allow me to write the meaty parts in C++), but how long will node.js be popular? On the surface, node.js looks fantastic, and I can certainly handle JS. But what will I have years down the road? A bunch of code written upon an outdated fad library?

 

So, I don't write code; I read webpages about libraries. I'm ready to poke my eyes out.

 

In the end, I want to build an App that either fires up http or websockets (prefereably as part of the application), and allows me to spit out webpage/JS/WEBGL.

 

In the majority of my reading, most people say this is not a job that C++ can fit into. I don't understand why. To me, and aside from the obvious JS requirement, C++ is an obvious choice for inclusion in a WEBGL/HTML5 game that would anticipate high volume.

 

Ok, back to poking my eyes out.


Edited by trowtlip, 20 March 2014 - 01:14 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS