How does WebGL (on firefox) work? - browser

I grabbed firefox 3.7a (note go to about:config and enable webgl) and ran the examples on this site http://www.iquilezles.org/apps/shadertoy/
The examples were cool then it hit me. How is it running? Code is being ran is it not? Is this an implementation of LLVM? is something else going on? Would i be able to run my own examples and do something like a command line text based game?

The shader examples on that site are written in a C-like language called GLSL, which is the (Open/Web)GL Shader Language. When they're executed, the JavaScript WebGL code sends the shader source off to your graphics driver's OpenGL functions, which compile it down to a machine code that runs directly on your GPU.
BTW, the shader-only style of coding, while very popular and a great way of writing cool demos, is not an entirely typical use of WebGL. Normally the shaders are used to do a lot of the heavy-duty number crunching, but the design and animation of the various objects that make up your scene is done in JavaScript. (In OpenGL, you would see a similar split between GLSL and some other language, such as C or C++.)
If you want to learn more about coding WebGL, you could do worse than visit the tutorials on my site, learningwebgl.com. I frequently link to other people's demos and tutorials too, so if you don't like my examples you should easily be able to find something better :-)

Related

Anjuta/Glade Tutorials or Better IDE?

I am attempting to develop a GUI application for Tails. I'm doing the initial development on Debian 8 since development directly in Tails can be a pain.
I started out using Anjuta, but the documentation is essentially non-existent. The Anjuta website has nothing at all about how Glade is integrated or how to use it. I can't even track down documentation on how to change the main window title. The only tutorial I found has you start a project and build it using the default files that are generated for a GTKmm project.
Is there a good book or online tutorial out there for doing GUI development in Anjuta?
This is maybe not a complete answer, but it's too large to put in as a comment. I use Anjuta fairly regularly, but I share your feeling about the missing documentation (which is, by the way, not unique for Anjuta). I appreciate Anjuta (and Glade) very much, so don't take the following as criticisms on either program.
I would recommend you consider using PyGTK for GUI creation. It is a lot more productive. You can design the GUI in Glade - exactly the same way you would do for C/C++ - and then implement the code in Python, which you can also edit and manage from Anjuta. There are plenty of code examples, for example on the nullege code search engine.
About the work flow in Anjuta (for C/C++). It is based mainly on the Autotools system, so you should really read up a little on make, Makefile, and related tools. Though in principle Anjuta manages this, you will, sooner or later hit a problem, and some knowledge about Autotools will help you a long way (also this tutorial or this one. This slide series is interesting - probably because it is more graphical. There are even some video tutorials, like this one.).
There is no real necessity to use Glade from inside Anjuta. In fact, Glade has passed a long process distancing itself from 'code generation'. It now only contains an XML generator, which can be called separately. I find the screen space left for Glade inside Anjuta insufficient for comfortable work anyway.
So, in conclusion: If you mainly need a GUI, consider Python + Gtk. If you do need C or C++, Anjuta is a great IDE, but look at Gtk Development examples (like this one). Following those, the use of Anjuta should be a lot clearer.
EDIT:
Very useful answer. I have some underlying legacy code that has to be
C++. Is there a way to mix Python and C++ in Anjuta, or do you know of
any guideposts or tutorials for such?
You can open a C++ project in Anjuta - maybe even import you legacy code directly as a Makefile project. You can also add new files to your C/C++ project and create them as Python files. I've never tried to do that though, and I'm not sure how Anjuta would treat them, for example, in the Makefile(s). I don't have large projects mixing languages at the moment, but for small projects, I like 'Geany', because it doesn't get in the way. You do have to maintain the Makefiles manually.

Writing a Linux Terminal emulator

I'd like to write a x11 terminal emulator, but I don't know how I should spawn and communicate with the shell, is there any basic (pseudo- or C) code for that? like what sort of PTY to create, how to bind the shell to it, what signals I have to catch or send, etc. don't really feel like sorting through the whole xterm sources.
EDIT: oh and I want to implement a way of communicating with any applications in it, how shall I do the feature discovery? some hidden ansi sequence in the "clients", hoping it's not colliding with other terminal emulators? some environment variable, hoping it's not colliding with the "clients" or removed by the shell?
YAT (yet another terminal) https://github.com/jorgen/yat is suitable for embedding in Qt Quick programs. Contributions for improvement are welcome. (Disclaimer: a friend started that project, and I work on it sometimes.) It takes a mostly correct approach (e.g. it uses a Linux pseudo-terminal properly, something I didn't know about before my friend was explaining that), and has a lot of features; however the parser is written from scratch and is not feature-complete or bug-free yet.
Unfortunately most terminal implementations so far have been starting from scratch, or with a one-off monolithic fork (from rxvt for example), which is a lot of work and results in all of them being incomplete. So I think a better alternative would be to use a reusable logic-only library called libvterm: http://www.leonerd.org.uk/code/libvterm/ or to base your terminal on one which already uses that. That way if you find bugs and fix them, you'll improve the whole ecosystem.
https://github.com/timmoorhouse/imgui-terminal is interesting, and works (at least somewhat) but is a prime candidate to be rewritten with libvterm, IMO. If you are into immediate-mode rendering in OpenGL, it might be a good choice anyway.
http://41j.com/hterm/ does use libvterm, and adds a few features which libvterm doesn't have, for inline graphics rendering (ReGIS and PNG). But the code is not elegant enough or portable enough, IMO, and the graphics rendering "floats" over the text rather than being truly inline. It still might be an adequate starting point for some use cases. In my fork https://github.com/ec1oud/hackterm I got it to build with mostly modern system libraries, however it still depends on an outdated version of SDL, which is included.
OK, if anyone also need this, and is using lua, I found the http://www.tset.de/lpty library works fine. still testing ansi escapes and stuff, but should work.

Haskell `ncurses` library

I would like to use a text-based UI in my Haskell program. I found some bindings for the ncurses library (see also hscurses or ncurses, which one to use?). The hscurses and nanocurses packages are just simple wrappers around the C library, while vty isn't very well documented and a bit ugly (for example mixing snake_case and CamelCase).
The ncurses library on Hackage looks much more pretty and provides API which nicely fits Haskell. The problem is that it doesn't seem to implement some crucial features, like resizing or refreshing the windows.
So my question is:
is there any other Haskell text UI library, either ncurses-based or not, which I missed?
if there isn't anyone, is it possible to extend the ncurses Haskell library to at least support window refreshing and resizing? (this should be probably consulted with the project owner, but I need the solution quickly)
EDIT:
I finally used nscurses without windows (and panels) to avoid the troubles with refreshing them. I had problems with output to bottom-right corner of a window (a very similar issue was reported for Python's ncurses binding). I solved it by not writing there :).
Have you looked at vty-ui? It has a very nice user manual with lots of examples. I believe it's essentially a wrapper around vty.
I've used nanoncurses and hscurses succesfully, my hmp3 app has a binding that was the basis for nanocurses.
No matter what you probably will want a nice high level API. hscurses does have a box abstraction at least.
You'd be fine going with hscurses.
There is another good choice for Text-based user interfaces in haskell;
Brick is written by jtdaugherty, the same person that developed vty-ui which is Deprecated now.
The API is Declarative, which is Better for Presenting a language like Haskell.
also the Documentation was great and complete.

simple game development on linux

I'd like to develop simple 2d games on linux. Something like one below. The only decent tecnology I've found was PyGame. Is there any other worth taking a look? Is there a possibility to develop flash games on linux?
Thanks in advance.
I will have to agree with previous user , pygame is an amazing powerful and easy to use library.
Now about your flash games, there is a back door.
First forget about flash. Yes I know that this seems a bit out of topic , but no worries you can compensate for this.
Now python has something called Pyjamas, dont laugh its actually a very serious package. What pyjamas does is to convert python code to javascript code, all this happens automatically and you dont need to know a single line of javascript , even though knowing javascript could help as well. Of course the benefits of converting python to javascript means that not only you can run python apps inside any browser and any device supporting a browser including iPad, iphone, and pretty much anything else you can also use javascript libraries. Actually you can use only javascript libraries , so forget about using pygame with pyjamas.
Now HTML5 is the future, its still an ongoing project and far from finished, but YouTube already is using it with alot of success. Html5 together with the new version of javascrip offer features very similar to Flash, with the added advantage unlike Flash which is tied to Adobe , HTML5 is open source and a web standard. That means that borwser support Html5 out of the box with no need to install anything. So you could use HTML5 and Javascript to build your browser games. I think that HTML5 will replace the Flash in the near future. Remember because you will be using pyjama you will writing your code in python only, but of course you could mix it with some javascript code if you wish so.
I will advice for the time being epxlore pygame , because its dead easy to use, and when the right time comes and feel confident with python, take a look at pyjamas and fire away your browser games. The important thing to remember is that unlike other easy to lear language Python is a serious language used for almost anything, so you never run out of option. So do your coding and have fun.
Oh in case you need to check out pyjamas its right here.
Pyjamas Website
Here's a list of some open source game engines in general. You'll want to look at the cross-platform, 2D-oriented engines and see which one best meets your needs as far as programming language and features.
However, PyGame is pretty well-developed, and Python is an exceptionally easy and fun language to do anything in, including game development. I recommend you check out PyGame first, I think it would work well for your task.
As for developing flash games on Linux, there's little chance of that. To develop flash games you need Adobe's suite, and it is only compatible with Windows and Mac. So unless your computer can handle the stress of Adobe software (which is pretty high) in an emulated environment (Wine, which adds considerable hardware overhead), you'd need Windows or Mac OS X to do that. You can still play them, however.
There are flash libraries for games that work in linux. It's a but more of a pain in the ass but maybe all the hassle will teach you a thing or two ?
Here are some usefull links
http://flashgamedojo.com/go/
http://www.flixel.org/download.html (mentions some linux options)

Method for building lightweight, cross-platform, text editor

I'm planning to build a simple, lightweight text editor that combines a great look with keyboard focused input.
I want to have a lot of control over things like antialiasing and all the graphics in general, but I don't care about having a whole library of widgets. Almost the entire UI will be text-based and in the main canvas/window of the app.
Toolkits like GTK and Qt seem like overkill - tons of widgets I don't need and a complex codebase.
Titanium, AIR, and XULRunner are even bigger in some ways - dev would be quick, but that's not exactly the lightweight approach.
Shoes seemed like a nearly perfect fit, but it's a little too small and doesn't support enough events (e.g. no window resize).
What do you think, should I just build it on Cairo/Pango or another graphics library and roll the platform specific stuff myself? I'd rather use a framework of some kind.
Basically all I want is:
good event handling
windowing
menus
drawing with really great type rendering choices
I would love to build this cross-platform from the start.
Even if you use just Cairo/Pango you still need windows on the screen.
The simplest combination would be cairo + pango + GDK (the windowing part of GTK+)
however even in that case you have no menus, and constructing menus with pure Cairo
would be a tough (but not impossible) accomplishment.
If you insist on lightweight and crossplatform then check the following
Fast Light Toolkit
Fox Toolkit
wxWidgets (goes great with Python)
Scintilla is a cross-platfrom source code editing component (based on GTK+) with excellent support for syntax highlighting, code folding, text zooming, and of course all the usual text editing functions; it should be an excellent foundation for a text editor.

Resources