Emscripten without SDL - c++

I'm trying to get started with emscripten but I don't seem to be able to find all that much information about it. I have followed the tutorial, and got a simple hello world working. From what I gather the normal GL calls automatically get translated into WebGL, but what I'm wondering about is how to set up the rendering target, context and all that without SDL or GLUT or anything along those lines.
Is there a way to use WebGL on emscripten without SDL\GLUT (including mouse/keyboard input, etc)? Where can I get some more info, examples, etc about emscripten?

I suggest you use Cheerp - an alternative to emscripten - Cheerp has a working WebGL demo, it also has much more coherent/updated docs/examples

Related

How to embed Chromium Embbeded Framework into GLFW

I am trying to do as the title implies. I am looking for a tutorial or an existing github project that will show me how to make this possible. As far as what I have or haven't tryed: nothing. I have been at a lose of documentation on CEF and don't know where to begin. I am aware of the alternatives (librocket, awesomium, and berkelium). If any of these have been embbeded in GLFW successfully link appropriately. As far as finding no documentation, I have looked on CEF's website and wiki and found installation instructions and an example that uses #include <window.h> instead of opengl.
It took a bit of massaging to get it to work, as the libcef.so file is too big to be stored on github and the cef implementation is a few years old, however, I've posted a few "issues" with fixes and suggestions here to assist you. The software here is pretty good however it's completely lacking of decent documentation, and it depends greatly upon what directory you launch it from. Big hint: Launch the software from the base directory of this git.
https://github.com/andmcgregor/cefgui
Hope this helps.
I think this is a bit too much for a novice programmer. GLFW is a down-to-the-absolute-minium framework for creating OpenGL applications. CEF on the other hand depends on many utilities provided by the application it's built into. GLFW doesn't offer them, so you have to implement them in a way that CEF can live within GLFW. That's feasible, but requires some expierience. If you look at https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage there's one short paragraph "Off-Screen Rendering". This is what you want to integrate it into a OpenGL project. Render off-screen and present the result through a textured quad (either viewport space aligned).

Importing a blender model into a DirectX 11.2 C++ application

I'm new to DirectX applications, with a decent knowledge of C++ and some experience in working with Blender. So for starters i would like to know how could i import, say, a UV sphere from Blender into a DirectX 11.2 C++ application. I'm using november edition compiler. Is there a tutorial for working with Blender models in DirectX applications that is up to date? Because i read that the .X format is not supported anymore after DirectX 10, and i need to use it in a DirectX 11.2 enviroment. I'm pretty much clueless about what to do and in what direction to go, so any help would be much appreciated.
If you 'just' want to display some 3D objects using native DirectX there is no other way than doing all the initialization stuff, writing a file loader for some kind of format that Blender is able to export and setting up a respective render pipeline. Indeed the way is long until you can see your Blender model in your own application. But if you intend to write your own graphics engine eventually it is a way you have to take. If this is not your goal I recommend you to use an open source 3D engine of your choice.
I used a very good online tutorial on a web page which unfortunately does not exist any more and of course the MSDN libraray to learn about DirectX 11. You can still find these tutorials at an internet archive. Additionally I found another tutorial which seems to look good at a first glance.
If you don't need to do very special things which Blender must write into the file you are exporting, I suggest using the .obj format since it is easy to understand and to load.
By chance I'm writing my own graphics engine in the moment. So if you have any further questions concerning this topic feel free to contact me.
You can always make your own format if its, i dont know, just for some school project or something like that (wild guess). Format your data the way you want, for example:
X,Y,Z,R,G,B\n
X,Y,Z,R,G,B\n
X,Y,Z,R,G,B\n...
for vertices and after you list all your vertices you could use some char like '$' or '%' or something like that which will signify end of vertices and start of indices which will make it easier to parse later. You can assume it is always TriangleList topology but you may also dedicate first line of file to configuration and have int 1 for instance represent that you will use trinagleList and so on...
Hope it helps!
P.S.: Julians answer is better in my opinion, its always good to learn new useful stuff for future projects (like in Bioware :D ), just proposing alternative here.

I'm trying to integrate a 3D model viewer into my GUI, but have not found a single library that will allow me to do this easily. Any suggestions?

I've tried with VTK, PCL and Qt (using the QVTKWidget.h), however, using CMake is incredibly inconvenient, as the second I update any one of the many libraries that my GUI uses, I have to spend at least another day trying to sort out the linker issues. Additionally, a lot of the time, a lot of information is lost from the 3D models using these libraries.
Note: I am focusing on using PLY as it holds color and geometry information in the same file, but any other format that does the same would be fine
I am currently trying to create a Meshlab plugin, but the support for this library is sparse, and I am yet to successfully compile the Meshlab source.
Any input or direction would be really appreciated. If you guys want to know anything more, please do let me know.
If it wasn't clear in the beginning, I am using Qt (C++) to create the GUI.
Use the QT OpenGL widget and write some OpenGL code to display your model.
PLY textural format is really simple and you can write a parser yourself.
Have you tried Coin3D? This is a Free implementation of OpenInventor wich was made by SGI back in the day as a C++ wrapper around OpenGL.
As for integration with Qt there is a library called SoQt (in the same site). They also have a newer library called Quarter that integrates more like a Qt component.
I've had greatest success with Coin + SoQt + Qt.

Rudimentary 3D graphics in C++ .NET

I am looking to implement an extremely rudimentary FPS game with extremely rudimentary 3D graphics using C++ .NET and DirectX.
I'm not interested in any third party libraries or anything special like that.
Having never done graphics based programming besides 2D stuff I don't really know where to get started or even how to find the right resources online.
I have a few weeks to build this game so im trying to keep it simple.
Can anyone give me a little guidance on how to get started?
This looks as though it may give you a push in the right direction:
http://zophusx.byethost11.com/tutorial.php?lan=dx9&num=0
I always found that OpenGL was easier to learn though. So unless it's necessary for you to use DirectX, I'd suggest you have a quick look at GL and see what you think.
If you download DirectX SDK you can find plenty of samples there in C++ and C#.
May I recommend "Introduction to Game Programming in DirectX 9" by "Wordware" Publishing. I know you just want something very simple like the rotating cube classic, so do not be put off by the 'game' element. I got 3/4 the way through and wrote a screen saver! DX10 is now available but I stick to 9 - card backward compatibility.
The maths can get silly in 3D, but if you can get the basics, the rest will follow very quickly.
If you haven't done so already the "DirectX SDK" download is also a must - it contains (most important) the help files for the methods, functions etc. and a few not so helpful getting started stuff.
You might want to have a look at SlimDX, even if you're not interested in third-party libraries.
Although I don't have Visual C++ 2008/2010 Express installed, you could add SlimDX as a reference to your project. Be sure you check out the tutorial section, even though it's in C#, but if you know C++/CLI pretty well, you should be able to convert the code to C++/CLI.

What is the best approach to use openGL in the web?

I wrote a program in C++/OpenGL (using Dev-C++ compiler) for my calculus 2 class. The teacher liked the program and he requested me to somehow put it online so that instead of downloading the .exe I can just run it on the web browser. Kinda like java applets run on the browser.
The question is:
How if possible, can I display a C++/OpenGL program in a web browser?
I am thinking of moving to JOGL which is a java interpretation of OpenGL but I rather stay in C++ since I am more familiar with it.
Also is there any other better and easier 3D web base API that I can consider?
There is a lot activity recently with WebGL. It is a binding for Javascript to native OpenGL ES 2.0 implementations, designed as an extension of the canvas HTML5 element.
It is supported by the nightly builds of Firefox, Safari, Chrome and Opera.
Have a look at these tutorials, based on the well known NeHe OpenGL tutorials.
Several projects based on WebGL are emerging, most notably Scenegraphs APIs.
From Indie teams: SceneJS, GLGE, SpiderGL.
From Google: the team behind O3D plugin is trying to implement a pure WebGL backend (source) for the project, so that no plugin will be necessary.
From W3C/Web3D: There is an ongoing discussion to include X3D as part of any HTML5 DOM tree, much like SVG in HTML4. The X3DOM project was born last year to support this idea. Now it is using WebGL as its render backend, and is version 1.0 since March 2010.
I'm almost sure that WebGL is the way to go in the near future. Mozilla/Google/Apple/Opera are promoting it, and if the technology works and there is sufficient customer/developer demand, maybe Microsoft will implement it on IE (let's hope that there will be no "WebDX"!).
AFAIK, there's only 3 options:
Java. it includes the whole OpenGL stack.
Google's Native Client (NaCL), essentially it's a plugin that let's you run executable x86 code. Just compile it and call it from HTML. Highly experimental, and nobody will have it already installed. Not sure if it gives you access to OpenGL libraries.
Canvas:3D. Another very experimental project. This is an accelerated 3D API accessible from JavaScript. AFAICT, it's only on experimental builds of Firefox.
I'd go for Java, if at all.
OTOH, if it's mostly vectorial works (without lots of textures and illumination/shadows), you might make it work on SVG simply by projecting your vectors from 3D to 2D. In that case, you can achieve cross-browser compatibility using SVGWeb, it's a simple JavaScript library that allows you to transparently use either the browser's native SVG support or a Flash-based SVG renderer.
Do you really have the time to rewrite it? I thought students were meant to be too busy for non-essential assignment work.
But if you really want to do it, perhaps a preview of it running as a flash movie is the easiest way. Then it's just a matter of doing that and you could provide a download link to the real application if people are interested.
Outside of Java, in-browser OpenGL is really in its infancy. Google's launched a really cool API and plugin for it though. It's called O3D:
http://code.google.com/apis/o3d/
Article about the overall initiative:
http://www.macworld.com/article/142079/2009/08/webgl.html
It's not OpenGL, but the Web3D Consortium's X3D specification may be of interest.
Another solution is to use Emscripten (a source-to-source compiler).
Emscripten supports C/C++ and OpenGL and will translate the source into html/JavaScript.
To use Emscripten you will need to use SDL as a platform abstraction layer (for getting an OpenGL context as well as loading images).
Emscripten is currently being used in Unreal Engine and will also be used in the Unity 5 engine.
Read more about the project here:
https://github.com/kripken/emscripten
Two approaches:
Switch to Java. However, your application will suffer from a loss of performance as a trade off for portability. But since Java is everywhere, this approach ensures that your code can be executed in most browsers.
Use ActiveX, which allows you to run native binary code for Microsoft Windows. This is not recommended in production because activeX is well known as a potential security hole, but since your lecturer is the one viewing it, security doesn't seem to be a big deal. This is applicable for Microsoft platform (Windows+IE) only.