Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    7
  • comments
    12
  • views
    5852

About this blog

Procrastination and Game Development

Entries in this blog

 

Comments and Documentation

Doxygen
Lately I've been using Doxygen throughout all of my code. You might think it's a bit over the top or unnecessary to use a documentation generator for projects that are never going to involve more than yourself, but I have to say that if you dont use it - you should! I found that being able to browse through my code as HTML Documentation, is a great way to refresh my mind as to what I wrote one or two weeks ago (or perhaps even yesterday). Try It!

1K Journal Views
and counting...

Direct3D Rendering Counterpart
The OpenGL renderer that has been implemented now has a Direct3D counterpart. The whole system uses the Abstract Interfaces code that I posted the other day, basically the Direct3D and OpenGL renderers exist as derived classes of an IRenderer interface. I was a little concerned that both APIs wouldn't work neatly under the same interface, given that D3D is COM and GL is straight C. Things seem to have worked out okay though.

As a test of the new Direct3D renderer, I wrote a small texture blending app using HLSL (yep, the D3D interface implements shaders). The demo blends 3 textures (rock, sand, grass) using a single rgb alpha map.





I'm getting a little tired of worrying about graphics APIs lately, so I'm sure to start working on actual game code soon. But first I want to get some sort of Scene Graph up and running.

-- Oh and those example textures aren't mine. I found them while searching for examples of texture blending shaders. I believe they're from a book on terrain texture blending in DX9.

FunLogic

FunLogic

 

Abstract Interfaces

Abstract Interfaces
Lately I've been brushing up on some of the more advanced c++ topics. The book I've found really helpful in this is C++ for Game Programmers. Something that I've picked up from this book and really want to use in my current projects are Abstract Interfaces. Here's a quick example from the book that I've been playing about with to understand the idea of interfaces a little better.



// Abstract Interface that provides a rendering interface to
// derived classes
class IRenderable
{
public:
virtual void Render(void) = 0;

};

// Abstract Interface that provides a simple physics interface to
// derived classes
class IPhysical
{
public:
virtual void UpdatePhysics(void) = 0;

};

// Game Entity base class
class Entity
{
public:
virtual void Update(void) = 0;

QUERY_INTERFACE_BEGIN
QUERY_INTERFACE_END

};

// A Tree Game Entity (not to be mistaken for a tree data structure) this is one of
// those green things out the window. Has rendering capabilities
class TreeEntity : public Entity, IRenderable
{
public:
void Render(void);
void Update(void);

QUERY_INTERFACE_BEGIN
QUERY_INTERFACE_ADD(IRENDERABLE, IRenderable)
QUERY_INTERFACE_END

};

// A Player Game Entity has both physics and rendering capabilities
class PlayerEntity : public Entity, IRenderable, IPhysical

{
public:
void Update(void);
void Render(void);

void UpdatePhysics(void);

QUERY_INTERFACE_BEGIN
QUERY_INTERFACE_ADD(IRENDERABLE, IRenderable)
QUERY_INTERFACE_ADD(IPHYSICAL, IPhysical)
QUERY_INTERFACE_END

};






Using this setup I can store all of my game objects in a single array / vector / list. Iterate through them and at runtime decide whether or not I need to call Render() and / or UpdatePhysics(). Pretty neat, considering before this I was either using an isVisible boolean flag or storing visible objects in a seperate container. Here's a sample of these classes being used:


int main(void)
{
std::list entityList;

entityList.push_back(new TreeEntity());
entityList.push_back(new PlayerEntity());
entityList.push_back(new TreeEntity());
entityList.push_back(new PlayerEntity());

std::list::iterator itr;
for(itr = entityList.begin(); itr != entityList.end(); itr++)
{
void* pInterface;

(*itr)->Update();

pInterface = (*itr)->QueryInterface(IPHYSICAL);

if(pInterface != NULL)
{
IPhysical* pInst;
pInst = static_cast(pInterface);
pInst->UpdatePhysics();
}

pInterface = (*itr)->QueryInterface(IRENDERABLE);

if(pInterface != NULL)
{
IRenderable* pInst;
pInst = static_cast(pInterface);
pInst->Render();
}
}

system("pause");
return 0;
}






-- On a side note, I had to make a change to the code presented in the book in order to get it to work. I'm pretty sure it was correct but if someone could double check this for me it would be great. In the book, the QueryInterface() method is implemented just in the base class and isn't virtual, the only way I could get it to work was as follows:


#define QUERY_INTERFACE_BEGIN virtual void * QueryInterface(Interface interface) {
#define QUERY_INTERFACE_ADD(q, p) if(interface == q){p* inst = static_cast(this); return (void *)(inst);}
#define QUERY_INTERFACE_END return NULL;}





FunLogic

FunLogic

 

Python, Blender and More

New Features
The engine now uses VBOs (Vertex Buffer Objects) almost exclusively aside from the use of display lists as a fall back option (for
Blender and Python Scripts
Today I've started work on a really basic model format that I can use within the game. The biggest problem I've found with getting this task done is writing the exporter plug-in for Blender. Initially I was trying to make my model file sizes as small as possible by exporting in a binary format, but after several hours of crawling through Python and Blender API documentation I decided to stick with just writing to an ASCII file.

A 507 vertex model exports with a file size of 15KB which I suppose is quite a lot considering all it contains is raw vertex data and nothing else (I still have to add normal, and texture coordinate data). If anyone has had any success with writing a small exporter script for Blender I'd be interested to hear how you went about it.

V-Sync and PFNWGLSWAPINTERVALFARPROC
Another problem I'm experiencing is with getting wglSwapIntervalEXT() to work. On some occasions when I run my application the FPS caps at 75fps and calling wglSwapIntervalEXT(0); will disable V-Sync and send the FPS counter upto around 550fps -- pretty normal. However, on other occasions the fps will cap at 65fps and any attempt to disable V-Sync through the necessary extension fails. Any Ideas?

FunLogic

FunLogic

 

TrueType Fonts and more...

TrueType Fonts
I'm no longer using bitmap fonts, thanks to the FreeType Library I can render TrueType fonts at much higher quality than I was initially. Here's a shot to prove it:



(True Type font is the bottom one [smile])

XML Parsing (TinyXML)
Just added really basic support for using XML to define 'rooms' within the game through TinyXML. If you look back to yesterday's entry, you will see a textured 4x4 room, which is now defined in XML by:



"1.0" encoding="utf-8"?>
"1" name="Test Room" size="4">
"wall_01.tga" />
"floor_01.tga" />




The room element's id attribute will be used by the game engine to find the next room to enter when the player exits the room they are currently in.

At the moment the floor and walls of a room don't offer much flexibility in terms of texturing. Eventually a room will be stored as a 2-dimensional array where each cell can have it's own unique texture sets.

FunLogic

FunLogic

 

Starting an Isometric Game / Engine

Wow, it's been two months since my last post! Unfortunately I haven't really been up to much over the past 8 weeks, but just recently (today) I have started work on an Isometric Game. Here's the result of my work so far:



Not much I know, but it's a start. The full list of features are:
OpenGL Renderer
Uncompressed TGA Textures
Orthographic Projection
Simple Ambient Lighting
Bitmap Font Support (not shown)
At the moment it's all fixed function and uses immediate mode for everything. My next task is to see about getting support for Display Lists / Vertex Arrays and VBOs. Here's another shot, showing the scene in wire frame mode:


FunLogic

FunLogic

 

Progress?

Two assignment deadlines fall within this week and before I can even start work on them, there are one or two other things I have to get done first. So you will have to excuse either the lack of updates or at least the lack of - interesting - updates for the next week.

Articles Inbound

You might have noticed the article links at the top of the page, you can try clicking them but they won't get you very far. I still have to format the articles into a HTML document and upload them to my GDNet+ web space. The titles are pretty self-explanatory but for those of you wanting a slightly more detailed description, here goes:


Understanding and Implementing the Singleton

Alexandrescu's Modern C++ Design proved invaluable to me in writing this article about the Singleton Design Pattern. For those of you who aren't aware of the Singleton, this article will not only explain it's concepts but also provide a fairly robust implementation that you can customise as much as you wish.

Integrating Lua with C/C++ (Neatly)

I've always loved the idea of embedding scripting languages as a means to extending the functionality of a hard coded C++ application. It opens up all sorts of possibilities; including user generated content and rapid prototyping. This article will show you how to compile and integrate the Lua scripting language into a C++ application via a 95% object orientated solution.

A Brief Introduction to Smart Pointers

Writing this one was a bit of a learning process for me, so it is quite brief and will best suit a person who [like me] has never implemented any kind of smart pointer before.

As I have already said I've got a lot of work to do over this week, so these articles may not be posted for a few days.

FunLogic

FunLogic

 

Hello GDNet!

Hello GDNet, how's it going?

I've not exactly been the most active member of this community since my registration - more of a lurker really - so I guess an introduction is called for. Well my name is Adam, and I'm a Computer Games Programming student. Over the coming months, I'll be using this journal to report back on progress I'm making with a number of projects as well as to complain about random things [probably game or programming related].

My programming experience this far has mostly consisted of self-taught C/C++, as well as C# and some DirectX / OpenGL. As well as that I've also been involved in some XNA work, since I attended the GSE Launch Event in Warwick and got given my free Creators Club Membership [smile]. However at the moment, I'm turning my attention to getting back up to speed with DirectX 9 and starting to look into GPU programming.

In 6 months time I start my second year of university and begin searching for an internship - suffice it to say I want to be prepared, so I'll also be brushing up on more advanced C++ [I'm currently working through Sutter's Exceptional C++ so expect a bit of commentary from me on that].

Also - If your hoping for another 'awesome picture everyday' journal, then you'd best bookmark this one for a much later date.

Stay tuned for more updates!

FunLogic

FunLogic

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!