Skip navigation.

Software Development

Correcting The Future

Project V: Demo of GUI Environment in the Works

I'm building a demo. I'd call it small, but it's going to be bigger in size than I'd like. The Unicode library I'm using is 10MB just by itself. I doubt I need it all, but I can't be bothered to figure out the settings and recompile it. Hopefully, it'll compress well.

It'll ONLY be a GUI environment Demo. It's not Project V. I've disabled almost everything that has to do with that because it's simply not done yet. I might leave in a few blank components just to have something on the screen, but they'll be empty and useless.

I'll show a few visual components, but that's kind of boring. What I'm going to show is a little from each item in this list.

  • Fonts.
  • Text functionality.
  • Layering.
  • Alpha channels.
  • Video and audio player.
  • Line drawing.
  • Spline Drawing.
  • Rectangles (rounded and outline options).
  • Circles (full and outlined).
  • Ability to trigger multiple tasks at once.
  • A little fun with math and parametric equations.
  • Textures.
  • Image loading.


I'll be adding more stuff, but I can't remember them all just now. I didn't list it, but this is a full GUI system. Some GUI components I'm still missing, but I have listviews, treeviews, textboxes, popup boxes, listboxes, radio buttons (and ability to group them and make them mutually exclusive), checkboxes, text buttons, image buttons (all buttons can optionally be pushdown buttons), image viewer, panes (containers), views (main display layer), button panels, scrollbars, video player, labels and zoom box. Everything can be custom drawn or you can insert your own graphics for some of the elements. I'm not going to show that in the demo though. So I'm listing it here.

All these GUI components and everything in the list above will be available within Project V. Anyhow, there are two different and unrelated kinds of components. There are Project V components and then there are GUI components. I'm going to show the GUI components and a few examples of what they can do, especially the custom drawing stuff since you have full access to the video card. Project V components will be available at a later time that will allow you to do exactly what you will see in the demo and more.

Requirements are:

- DirectX 9.
- The demo should work on most video cards. Needs PS 1.4 or better. VS 1.1 or better. And 64MB of texture RAM I suppose. I never really measured it.
- DivX, XVID or other Mpeg 4 codec to play the video.
- MP3 codec to play the audio.

Oh, and for those curious as to where I'm at with my events in Project V, I've got about 4 events left to go. I got a cold this weekend so I couldn't finish it. Again, note that these events are for the Project V components and NOT the GUI components. The GUI components have most of their events all set to go.

Not sure if that cleared up anything or just confused things, but there you go. In a few days, Monday at the latest, I'll put up a GUI functionality demo. Don't expect much. I just want to do this to finally get something out there. And that it's possible to actually build stuff with the C++ internal library. The Project V beta (the actual development environment) will be coming a few weeks to a few months from now.

Programming, Can There Be Something New? Ever?

First off, let me say that I've been busy with all sorts of other things. So if you don't see articles here, that's why. I have been working on Project V as well, though not as much as I'd like of course. But the other day, I was on proggit and saw this article about how tools get better, but the basic concepts surrounding programming essentially stay the same. That most of the current programming languages are based on those of 50 year ago.

Programmers from 30 years ago might be surprised that we use lower case letters in our programs, but little else would startle them about the code we write.



You should read the rest of that article. There are some more good lines in there.

Read more...

Do Arguments Against Goto's Also Apply to Functions?

Via proggit comes a Dr. Dobbs article by Andrew Koenig about Dijkstra's Go To Statement Considered Harmful. (And yes, "go to" is two words.) I usually like Andrew Koenig's articles. And this one is no exception. But I do have an issue with it.

First, let's recap his objective. It's that most people dismiss out of hand the use goto's without understand exactly why goto's are considered harmful. He claims, and I have no reason to dispute it, that personal opinions are the end of the argument. Andrew then mentions arguments that are NOT personal opinions. I always see this as a red flag. Not that it's automatically wrong. But an undebatable truth rarely goes unchallenged.

Read more...

Collapsing indexes

There are specific topics that I just code up, but never really seen anyone talk about. Mostly because they are rather simple. And because this deals with optimization.

Suppose I have a list, but I have dual indexes. In this case, I have a set name and an owner. Different owners can have sets by the same name. For example, if I have two base classes, then I can override both of their "Properties" set by simply specifying the owner.

typedef std::map<NEntry*, ForwardPair*> ForwardLink;
typedef std::map<UnicodeString*, ForwardLink*, StringInternCompare> ForwardMap;


ForwardMap indexes by interned string. And ForwardLink indexes by owner (the NEntry*).

ForwardPair contains some flags and the set itself, but I moved the flags directly into the set. It's not really where it should go, but it's a lot simpler this way. I know I'll never add anything else and even if I do, there's no problem adding a separate data section to the set. So I now have this:

typedef std::map<NEntry*, TypeList*> ForwardLink;
typedef std::map<UnicodeString*, ForwardLink*, StringInternCompare> ForwardMap;


TypeList is the set.

So far so good for the simplification. I've removed an extra class that I didn't really need.

Now I want to combine these two lists into one. I do have a SHA256 class that can produce hashes based on different inputs. So I was thinking to give it the set name along with the owner's NID (which is itself a SHA256 hash code). This will produce a new hash code for my index.

typedef std::map<NID*, TypeList*, NIDInternCompare> ForwardMap;
NID* CreateForwardHash(UnicodeString &setname, NEntry *owner) const;


This isn't so hot though. I can't enumerate the list of sets. (edit: Actually I can since the keys are also stored with the set itself, but I still couldn't retrieve all sets with a certain name without going through the entire list). I could add another list with this information, but that seems ridiculous considering I just removed a list. Also, creating hashes for every lookup seems rather tedious. Sure, it's once per set. And the hash is computed on a small array of data. But I don't think this is the way to go.

What do you do with dual keys? For now, I'll keep my original two lists sans the class I removed.

I've wrapped access to this with a class that can create, search and delete sets. So it's not that bad. But sometimes I have to iterate manually. Is there such a thing as a multi key list? I think I should build one. It'd be awfully useful. And by multi key, I don't mean having multiple items with the same key in the same list. I'm talking about needing two or more keys to access a single item.

I'm not sure how I would go about it. Can templates do variable length parameters? I have no idea. I haven't done that much template programming.

template <class Key1, class Key2, class Compare = less<Key> > class dualkeymap
{
}


Not sure how to implement this though so that it works with as close as possible to other STL templates. Mainly iterators. Never implemented one before. I'd find it useful.

C++ Futures

I've been hearing about futures for a while. Aside from the fact that there are plenty of old C++ compilers out there that will never support these new features, it's still interesting to see these new additions considering that I said C++ was dead a while back. Uh... that was 2006... January! Three years ago.

Anyhow, I'm doing some unrelated, yet hairy, C++ programming lately. So why not talk about futures too. From this article, which I consider very good in explaining the topic, it looks like you can spawn off computations where you can retrieve the result(s) at a later time.

Does this seem like juggling to anyone? And where have we seen that term used before? Right! With pointers. But now we're gonna be juggling execution. And you can already see in the linked article that the same solutions to pointers are gonna be used with futures.

I understand the need for it. Heck, I'll probably use them myself if I can get a compiler that supports it. But the problems listed at the end of that article are very relevant. Did the C++ committee just decide to avoid what history has taught us these last 20 years?

The funny thing about this is that it resembles what Vladas has been talking about for a while, but with all of the useful things stripped out. No composability. No concurrency. No parallel constructs. No nothing.

I thought I was mistaken with C++ being dead because of the new extensions. But I think that adding features that were never meant to be part of the language is a nail in the coffin. I like C++. It's my favourite language. Well, "like" is perhaps a bit too strong a word. I hate all languages and C++ is the one I hate the least. But I think all current languages, not just C++, are fast approaching the point of no return. You've all seen it. When your program becomes so bloated and has changed so much that a complete rewrite would work better than the alternative. I believe this is called the Big Ball of Mud syndrome.

Time will tell.

Amdahl's Paradox

There is no official concept called Amdahl's Paradox. I made it up to represent the topic presented here. There is an Amdahl's Law which says how much speedup you can expect from using multiple processors. Generally, you cannot achieve a linear speedup because there will always be certain parts that cannot be executed in parallel.

In an earlier post, when I was still discovering the ideas behind dataflow, concurrency and a whole host of ideas that are not popular in contemporary software development, I said the following:

There have been discussions in the past about multiple processors not being able to scale well. You don't get 200% increase in speed with 2 CPU's. Nor 400% with 4 CPU's, etc. I don't believe this to be true. While there is latency in transferring data, this can be overcome by the fact that each core has its own cache.



In the wikipedia article linked at the top, it says this:

According to Amdahl's law, the theoretical maximum speedup of using N processors would be N, namely linear speedup. However, it is not uncommon to observe more than N speedup on a machine with N processors in practice, namely super linear speedup. One possible reason is the effect of cache aggregation. In parallel computers, not only does the number of processors change, but so does the size of accumulated caches from different processors. With the larger accumulated cache size, more or even the entire data set can fit into caches, dramatically reducing memory access time and producing an additional speedup beyond that arising from pure computation.


Read more...

Project V Development Techniques

Wanted to try and start a discussion about Project V development techniques. These are not set in stone and may change as I go along. Some haven't been decided on yet.

Read more...

What If We Had The Same Obstacles As Hardware Designers

First off, this has to do with the No Silver Bullet essay. Don't worry! I'm not rehashing anything in it. I'm actually not even going to mention it directly. I'm simply taking a different look at things. But I do talk about what can be considered Silver Bullets and where we are headed, so regular readers may want to skip this one if they are tired of the subject. I'll have another topic soon.

Second, I'm not a hardware designer. I have no idea what ALL the obstacles are. But let's try a few.

1. Can't send updates without shipping a new piece of hardware. For software, we'll assume the cost of an update is a significant portion of the original development costs. Not only do we need to recall the defective software, but we have to ship new ones. And we'll assume that software must be shipped on some kind of expensive cartridge that isn't rewritable just like the 80's! Oh Yeah!

2. We'll assume that the initial "cartridge" production costs are insane compared to future production runs.

Read more...

Project V: Implementing Event Systems

Not sure if anyone reading this has ever implemented an event system, but there is one little problem I encountered that can really mess things up. Deletion. And I'm not talking about implementing an event. I'm talking about the other side of the coin. The part of the system that actually invokes or triggers events.

I've now got two event system in Project V. One in the GUI and one in the node system (aka type system). The GUI one works fine, but that's because I've written plenty of GUI systems in the past. But even in the GUI event system, I had to include a separate, global function to delete GUI components. This global function doesn't actually delete anything. It simply queues the GUI component for deletion, but removes it from any and all container components. So any further events can still use said GUI component without crashing or getting a NULL pointer exception. When all events are done, I delete everything in the deletion queue.

I don't have a global creation function in either event systems. Maybe I should. But it doesn't seem necessary at this point. With the GUI, events come in from the OS. So I basically pass it on. So when the GUI event handling function returns, I simply clear the deletion queue. But with the node system, the events don't come from the OS. Rather, they come from the user (or other code) that will add, delete, insert, remove or update nodes. The user can also create and delete sets. So there's no real area when I know for sure that the node system isn't being updated. Since Project V components can themselves be executing at design time, these can trigger events outside of the GUI.

Read more...

DirectX: D3D Mouse Lag

I've been trying to solve this problem for ages. I knew it was common, but didn't understand why it was happening. Finally, I have solved it. This problem happens in many commercial games and professional products alike. Although less noticeable on faster machines, it can still happen there especially if the CPU is as fast or faster than the GPU.

What can happen is one of two things:

1. The mouse seems to move behind where you expect it to be even though the game runs at acceptable speeds. It'll feel like your mouse is gliding on ice. This can also be delayed character movements, etc. but the game and character runs at full speed.
2. The mouse moves fine, but the display is behind by up to a second or more.

I was getting #2 because I use the default Windows mouse cursor.

So what is going on here? Why would this happen?

Read more...

January 2010
S M T W T F S
December 2009February 2010
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30