This is Bananattack.

Eyecandy is eating me.

Posted by Overkill on July 21, 2008 at 3:43 am under Uncategorized

This week for Gruedorf, I spent more time on the graphics sections of brockoly.

I hand-optimized the crap out of the rotation blitter function, and so now it only iterates over the rectangle enclosing the rotation instead of iterating the entire image (bad), and I factored out a bunch of crazy calculation bottlenecks. I’m sure it could be further optimized, but not gonna bother since I plan on having hardware blits anyway.

I also made a nifty line drawing algorithm, which uses Cohen-Sutherland to clip the lines, and then Bresenham to draw them.

Oh and I added a fairly optimized scanline circle drawing algorithm based on some fancy-looking paper about fast circle drawing I found with google. I guess you could call that reinventing the spokeless (or infinite spoke) wheel.

I also made a bunch of slight improvements on the blending macros to make them slightly faster, and also added a global alpha that’s applied onto all blends (except Opaque — which is direct pixel copy).

With that, I’m left with gradient effects, palette maps, and drawing subregions of images for software.

I started coming up with some design planning stuff for how interaction with hardware textures will work. Here’s what I’m thinking: each of these textures each have a backend image — an image that can be retreived, drawn onto, and then applied to the texture once updates are done.

Sadly, though, I realized since a texture’s image can be changed, not all textures can be cached in memory. But the subsystems like sprites probably can be cached.

But okay there’s another interesting problem I read about — any time an SDL window resizes apparently the whole OpenGL context is discarded, so any texture bindings that were in memory are wiped out. I might have to disallow resizing of the game window at runtime just to prevent this, because this is preeeeetty bad.

I’ll be happy when all the graphical side of things is working nice, because it’s not until the graphical stuff’s done that I can really work on the cooler things, like the fancy world/area/tileset/sprite formats.

Oh right, and, The Dark Knight was epic and made of awesome. And so was playing Marvel Heroes vs Street Fighter in the arcade beforehand.

Uhm, anyway, that’s it for this week!

Tags: ,


Leafy green goodness.

Posted by Overkill on July 14, 2008 at 1:19 am under Uncategorized

So about two and half months have passed since my last blog entry, which wasn’t even about Resonance. The last Resonance posting? About 4 months ago.

The funny thing is, despite the rarity of posting, lots of design ideas were tossed around behind the scenes. Sadly, I didn’t realize that I didn’t even have a design document for Resonance the entire time I was working on it. That realization helped immensely. And so I embarked on rewriting my Lua code for my game engine, and started to make some headway.

But along the way, the same redesign also caused me lots of woes, because I realized there was a couple things that I wanted and I was frustrated with how I’d need to write them in Verge.

I tried making my own custom map format in Lua, but the lack of bitwise ops sort of killed that progress. And I didn’t want to go through the hassle of patching up Verge to support my own map format. So eventually (this past weekend) I decided enough was enough. I started writing my own game engine from scratch in C++.

Part of me knows it’s foolish amounts of extra work. But part of me thinks it’ll pay off and I figure I needed to learn how to write my own C++ game engine at some point.

I named the game engine brockoly.

This misspelled vegetable name was zeromus approved.

Originally this name was supposed to be for the custom format I was making, but I decided the engine might as well have a name of some sort.

Anyway, so far, the following things have been done:

  • Loading of software images
  • Get/SetPixel
  • Clipping regions
  • Rect, SolidRect
  • Normal blit
  • Scale blit
  • Rotate blit (needs more optimization still, IMO)
  • Builtin blend modes on every operation, that are performed by macros (and it’s my hope that gcc’s -O3 is smart enough to further optimize it):
    • Overwrite (direct pixel copy)
    • Preserve (blends source with dest pixel without changing alpha — pretty much intersection of the images (the default behaviour because it’s featureful enough for normal cases))
    • Merge (blends source with dest and changes alpha to accomodate — pretty much a union of the two images (more “what you’d expect”, but slower than Preserve, and likely to be less common so this is why it’s not the default))
    • Add (adds RGB values together while obeying alpha — useful for lighting)
    • Subtract (subtracts RGB values while regarding alpha — useful for shadows)
  • SDL — although only to manage the window and flip buffers after I’m done drawing.

And here’s some things I need/want to do still:

  • Global alpha applied to all drawing operations (right now there’s no actual way “setlucent” or similar but alpha is supported when built into the image)
  • Rotate scale blit (holding off till I can get a more efficient rotate if that’s even possible)
  • Color filtering effects
  • A notion of “palettes” and a palette map for images that allows quick and easy color replacement that can happen all at once after the image’s palette alteration is complete.
  • Tiled blit
  • For every src->dest blit, another kind that blits only a subregion of the source
  • Hardware texture versions of all the blits (where textures can be made of software images and at any point the texture’s underlying image can be updated (it looks like it can be done by glTexSubImage2D at least — I’d just to see how many migraines are caused if this requires a different pixel format than the regular software blitting.))
  • Scripting with Ruby — bound to be less crippled than Lua. As nice as Lua is, it’s lacking too many features and has a bunch of quirks that still make me cringe a bit (like any non-nil value besides false is coerced to true in boolean expressions, indexing from 1, no bitwise, no classes (and although you can make your own, you can run into more complicated things like not being able to garbage collect everything, or certain limitations on LuaBind’s class that make me use tables which have no __gc metamethod)).
  • Audio through FMOD Ex or Audiere.
  • A nifty “huge world” format that will hopefully read areas of the world into memory seamlessly. Each area would have its own tileset, theme, set of entities, set of zone types, layers, and metadata. Any region of a layer could have metadata. Each layer gets its own tile plots (duh), obstruction, zones and and entity plots (handy for multi-layer maps)
  • A tileset format that allows scripted animations and tile arrangements (brushes) and tile categorization (for labelling metadata on certain tiles — could be useful for map events to be able to name tiles, especially for random map generation or “special” tiles)
  • A sprite system that allows for custom animations and multiple hotspots (useful for stuff like ducking/crawling or other crazy poses in games (especially sidescrollers) I figure).
  • Have error messages print in the game window instead of as a popup (this is really good for fullscreen and for looking more awesome). Probably will allow a customizable background. Would still probably need popups in extreme barf cases, but I’m trying to avoid platform-dependent annoying popups for a bit.
  • Might optimize alpha blending for software to lose slight accuracy (which nobody really cares about as long as we still fade/blend okay for about +80% accuracy) in turn for better speed.

So yeah, I have hopes that I’ll one day finish most of these, and then as a result be able to make Resonance super awesome and perform great.

I am crazy, I know. But if I can finish this, it’ll be a grand accomplishment that anyone can use, since I plan on releasing the entire thing under a BSD-like license or something. Eventually when I get more progress, I’ll see about getting an SVN for it — but right now that’s sort of pointless.

Anyway, that’s a short version how I’ve been and what I’ve been up to. I’m sorry for holding off on my planning, with excuses of being busy some times, and hopes of eventually wowing people later other times.

But Grue made me realize that nothing gets done as soon as you start thinking of small progress as not worth bragging about. This is what Gruedorf is about.

Now, beware, my many adversaries! I’m back, and I will kick you in the behind (if everything continues to go well and I don’t screw this up again).

Tags: ,