I’ve started a new blog sometime ago, and I thought I’d just write it all in the same place from now on. One post per year, just like before!
Just changed the address to http://sadesaapuu.wordpress.com/
About a year ago, I searched for an OpenGL way of clipping a rectangle in 2D/3D space. To explain further: I’m making a GUI library with OpenGL, and I wanted a parent rectangle to be able to clip it’s child rectangles even if they were textured. I found glClipPlane, and tried it briefly. There was almost no documentation found, or it was very mathematical talking about plane equations without properly explaining how it should be transferred to code. I also could not find any coding examples of using them.
So, I spent about three months writing a system that would do this clipping in software. For flat rectangles this was easy, but for textured stuff it was very complex, as it was manipulating the texturecoords to get the clipping done. I somehow managed to write it, but the system was incomprehensible, added some software overhead, didn’t properly support my per widget zooming system, and I had to put all my OpenGL drawing inside this clipping subsystem. For about a year I was semi-satisfied with it, but as I changed to another way of drawing fonts, I needed either a new clipping system, or I’d have to adapt the external font code to my awful clipping system.
Then I did another search and found this page: http://local.wasp.uwa.edu.au/~pbourke/geometry/planeeq/
It’s dated 1989, and it’s another one of those mathematicians only explanations (I’m a pragmatic self-taught trial-by-error coder, with very poor mathematical knowledge, sorry). But for the first time it had something that looked a bit like pseudo-code and translated well into programming. So, I tested it and with a few first misses I was able to get the following code of it, that works for me. I’m not sure if this is the correct or best way of using plane equations, but it’s the only one that I’ve gotten working.
Horrible formatting there. I don’t know how to use wordpress to get the code looking correct…
Then I’m doing the following on each parent rectangle, just before starting to translate or draw the children:
double left_eq = planeEquation(ix1,iy1,iz, ix1,iy2,iz, ix1,iy2,iz+1.0f);
double right_eq = planeEquation(ix2,iy1,iz, ix2,iy2,iz, ix2,iy2,iz-1.0f);
double top_eq = planeEquation(ix1,iy1,iz, ix2,iy1,iz, ix2,iy1,iz-1.0f);
double bottom_eq = planeEquation(ix1,iy2,iz, ix2,iy2,iz, ix2,iy2,iz+1.0f);
So all you have to give to this planeEquation function is three points on the clipping plane. It seems that the order of them somehow dictates which side of it will be clipped and which side will be visible. In this example just changing the direction of the last Z from plus to minus, changes which side gets clipped.
I hope this is useful to someone trying to get some sense into glClipPlane and plane equations. This might all be just wrong, but it works for me! Any corrections and suggestions in the comments, please.
I thought I’d keep a low profile until my new project was finished, but as it now seems that it is progressing quite slowly, I might as well make it public for others to see.
Rae is going to be a general purpose GUI library. It’s nowhere near finished, and it is not usable for anything but making nice little demos of it. (Well you could make something like a calculator with it. Or possibly a pictureviewer of some sort with some effort. So, it’s not entirely useless…)
The keywords go something like this: D programming language, OpenGL, X11/MIT licence, (GtkD, cairo, pango), Linux, OS X, Windows.
Here’s a link to the video:
And there’s also a project page at http://www.dsource.org/projects/rae
The source in the repository is up to date, but a bigger example like seen on the video is missing. I might add it there later, when I get the time. But feel free to try and compile it. Shouldn’t be too easy. Lot’s of nasty big dependencies, that I’d want to drop later. The code is a bit hacky, but pragmatic, so if you prefer projects with perfect code, look elsewhere. One of the main features is that it uses 0% CPU when doing nothing. Yes, that’s just how it’s supposed to be, but not any of the OpenGL GUIs that I’ve seen, do that. It’s full of small graphic glithces, unfinished widgets and buggy behaviour and sometimes even bad design. But I’m willing to change all that if anyone wants to start participating in this weird and wonderful project. Progress is slow, as always, but there’s a start. Feel free to donate me time, hardware or anything useful. (I’d put a smiley here, but I’m trying to quit using them.)
Since yesterday or so, I was happy to find out that the svn trunk version of GtkD is supporting Mac OS X. This adds the supported platforms up to three. Linux and Windows are of course the other platforms.
Currently you’ll need to use the semi-official GTK+ Framework (the native Quartz port), or then if you absolutely must use the X11 version, you’ll have to edit some paths inside GtkD.
A screenshot will follow.
As I told earlier I had a little side project the other day, and wrote a demo called Frequency/Bush in D/OpenGL/SDL/gstreamerD/Linux.
Now you can watch it as a video in here.
It finished 7th in the Alternative Party 2007. Results. Get binary and the code (which is impossible to compile at the moment but is now final and closer to what was actually shown in the party). The binary is for Ubuntu Feisty (But should work with later Ubuntus and possibly other linuxes as well. Just install gstreamer-0.10-plugins-bad and other more obvious stuff). It’s not a good demo, but it’s my first, and made with D.
You can see it here. Click the right corner to see it in fullscreen.
Lately I’ve realized that coding takes a bit too much time from my life. I’ve admitted to myself that I’m addicted to coding, coding websites, blogs, news, IRC etc. It all started with me wanting to get Pihlaja working.
I did almost succeed in making it usable. The only thing missing is the export. And I got export “working” in a simple example program (which is in the /demos/gstreamer/encoding/ folder of the gtkD temporary git repo in repo.or.cz). Well, atleast it exported some video. Not the one that I wanted, but something similar anyway. So, I was quite pleased with how the 6 months went. I’m not disappointed at that at all.
Anyway. I’m not a coder. Coding in D is my hobby. I don’t get any income from it, and it is not my dream future profession. I have no education for it whatsoever. So, it’s a bit troublesome for me, when coding takes about 80% of my time. During the last year, I have not read any books (well, a couple in prison, when I wasn’t allowed to have a computer), I haven’t written any essays to my school. I have not seen and talked to people as often as I should have. And now that I’ve also started with a new job, the time I have for other things just isn’t enough. Not to mention having a 2 and a half year old child…
So, to put it briefly: I’m quitting coding for one year®. Let’s say that I won’t be coding until 1.1.2009 or something like that. I’ll also stop manically checking for updates to planet.gnome.org, dsource forums and osnews.com every three minutes. I’ll try to stop reading them. I’ll also stop going to IRC, as now I don’t have anything to ask there…
That means my projects: Pihlaja and gstreamerD will be put on hold. Feel free to ask me for rights to commit to the subversion of Pihlaja in DSource. You can take over for the time being.😀 Hope I’ll get back to coding Pihlaja with a little bit more sanity in 2009.
While not coding I’m going to get finished with my school, make a shortfilm, read books, write poems, draw and be with people.
P.S: I had a little side project the other day, and wrote a demo in D/OpenGL/SDL/gstreamerD/Linux. It finished 7th in the Alternative Party 2007. Results. Get the binary and the code (which is impossible to compile and is not final). The binary is for Ubuntu Feisty, contrary to the results file. It’s not a good demo, but it’s my first, and made with D.