flipCode - Tech File - Muresan Robert [an error occurred while processing this directive]
Muresan Robert
Click the name for some bio info

E-Mail: Robert.Muresan@email.ro



   03/28/2000, Introduction & Programming Issues


Hello! My name is Muresan Robert and i am a first year student at a Computer Science University in Romania (Babes-Bolyai University). My favourite hobby is programming. It all started 5 years ago when I decided to attend at a Computer Science High School. My programming knowledge back then was 0. I learned Pascal in one year then i wrote 2 First Person shooters, using Pascal and with almost no documentation (I haven't heard about Flipcode then, Internet in my country was like a having a Ferrari). After that i learned a lot of languages such as Basic, Assembler, Delphi, Visual Basic, etc. I saw that writing 3D graphics in Pascal was no good, I learned C, C++ and after that OpenGL, so now i can write pretty good 3D graphics.


My Project


Currently i have started developing a 3D game engine mostly for research. It is based on OpenGL and it's written in Visual C++ 5.0. My main goal is to achieve a good scalability and portability in my engine. I want to make it very easy to modify and port to other platforms. You will hear more about it as will talk in my .tech file about it, when i will cover some features. Enough with the introduction, so let's start some tech file subjects:


How To Write Portable & Easy To Understand Code


Since i want my 3D engine to be portable and easy to modify, I have came up with some tricks to achieve that. It may not be the best but it is OK for me. Let's take a look: We create an abstract interface to all we need in our engine, and put it in a separate folder(I learned some from the Quake sources :))

 Video interface
 os_windows\video.h and create our functions
    int  Init_Device() 
    void Close_Device()
    void Render_Triangle()
    void Set_fog()
    etc...
We even can achieve very easy API portability (use Direct3D instead of OpenGL, or anything else)

 Audio interface
  os_windows\audio.h and create the functions
  void Init_Device()
  etc...
And we will write an interface for everything: Input, Network, File management. After having done with this headers we start writing our 3D engine, in pure C or C++ language and the only function we will call will be those in the OS folder. That's nothing new (you will say), but here comes the fun part: Create a os_null folder and copy all your headers their but leave the function empty. For example:

 -os_null\video.h
int  Init_Device();
 -os_null\video.c
int  Init_Device()
{
  // do nothing
  return 0;
}
And since our engine is written in pure C and the only functions called, are those in the headers contained in the os_something folder, by including the ones in os_null you will be able to recompile your engine under any platform.After that all you have to rewrite are the function in the headers. Pretty easy isn't it?


A Very Simple Engine Arhitecture


I always wanted to make my engine simple, so that i can add new features very easy. Here is how i am going to achieve this: I define everything in my engine as an "entity" :

class something {
      void Init();
      void Update();
      void Render()
}

how does this help me? I want to add fog for example:

class fog{
      void Init()
      {
        read_fog_parameters_from_level_file()
	glEnable(GL_FOG);
	//etc...
      }
      void Update()
      {
        //nothing
      }
      void Render()
      {
       // nothing
      }
}
I can define the player as a class like this one, and i also can define particle systems, monsters, bots, skydomes, everything. Each class will have it's separate header wich i will only have to include and add these lines to my code:

#include "class\new_feature.h"
Init_Engine()
{
  new_feature.Init();
}
Update_Engine()
{
  new_feature.Update();
}
Render_Scene()
{
  new_feature.Render();
}
Well that's it for the moment. Next time i would like to talk about a thing that is bugging me for some while: Details in game when look very close to a wall for example, and how to improve it. If you have any questions you can email me at my new address: muresan@fcmail.com





  • 06/26/2001 - Tech File Update
  • 06/19/2000 - Back Again...
  • 04/20/2000 - Detail And Hardware
  • 03/28/2000 - Introduction & Programming Issues

  • This document may not be reproduced in any way without explicit permission from the author and flipCode. All Rights Reserved. Best viewed at a high resolution. The views expressed in this document are the views of the author and NOT neccesarily of anyone else associated with flipCode.

    [an error occurred while processing this directive]