Welcome to NemoX engine tutorial 2
This tutorial will show you how to make windowed application with NemoX engine.
All base code for typical NemoX engine code structure will be explained here

----TUTORIAL 2---

Making a 3d windowed application

You will Need The NemoX engine Get it Here

download the Visual Basic Source code here


In this tutorial we wil know how to declare correctly The main NemoX object and how to initialize them. Before reading that part of our tutorial series Make sure you have downloaded the NemoX engine Files and have correctly registered them.If not go to the previous tutorial.


1. Main Object Declaration and initialization

2. Game Loop Creation with a keyboard handler


1:Main Objects Declaration and initialization

NemoX engine provides classes that encapsulates important DirectX 8.1 methods such as Rendering function,Xfile,special Effects..ect.. We will learn in the futur tutorials how to use them.

For This tutorial We will use only One class NemoX class. This class allow to start en terminate all the engine.It's the Main engine components All ather components use NemoX class. So we have to Initialize it first and Deinitialize it after we free all other components that we use.


First thing the Declararion:

'The first thing to do is to Declarate the Object that
'we will use for this demo

'The Main One is The NemoX renderer
Dim Nemo As NemoX

'we use only this object for this example



For that step we will add a standart initialization sub for all the tutorial we will use.


we will used that sub for the engine initialization
 Sub InitEngine()
    'first thing allocate memory for the main Object
    Set Nemo = New NemoX
    'we use this method
    Nemo.Initialize Form1.hWnd
    'set the back clearcolor
    Nemo.BackBuffer_ClearCOLOR = RGB(255, 0, 0)
     'call the main game Loop
    Call gameLoop
 End Sub

We use this NemoX object function:

Function Initialize(HAND As Long,   'it's the handle of the main Form
Optional DeviceType As NEMO_DEVICE_TYPE = NEMO_HAL_DEVICE,  To use Acceleration
Optional Windowed As Boolean = 1, 'we want to stay in Windowed mode
Optional Wi = 640,  'if fullscreen the window width
Optional HI = 480,  'if fullscreen the window height
Optional BPP = 16,  'the depthbit for the zbuffer
Optional TnL As Boolean = False,  'activate the Hardware lighting and transform device
Optional VertSincOFF As Boolean = True,  'for the vertical refresh syncronization
Optional GamaLevel = 1,  'the gama level
Optional NumBUFFERS = 1 'the number of backbuffer to use) As Boolean
Now to launch the Demo we just have to add this in the Form_load sub:

Private Sub Form_Load() 
  'call the initializer sub
  Call InitEngine
End Sub


2:Game Loop Creation with a keyboard handler

Making a game loop is very easy We use a simple Do.....Loop statement with inside a Rendering part as shown in that piece of Vb code source


'this sub is the main loop for a game or 3d apllication
 Sub gameLoop()
             'loop untill player press 'ESCAPE'
                '=====Keyboard handler can be added here
                'start the 3d renderer
                      '===============ADD game rendering mrthod here
                'show the FPS at pixel(5,10) color White
                Nemo.Draw_Text "FPS:" + Str(Nemo.Framesperseconde), 5, 10, &HFFFFFFFF
                'end the 3d renderer
             'check the player keyPressed
     Loop Until Nemo.Get_KeyPress(NEMO_KEY_ESCAPE)
             'end of the demo
             Nemo.Free  'free resources used by the engine
 End Sub

This is the end of the Tutorial #2 Fullcode source can be downloaded here..

If All code is okay the screen should look like in that shot bellow


See you in the next Tutorial.....sincerly Polaris..Don't forget Any Bugs detected mailMe


The Previous Tutorial 1 :Setting up the NemoX engine

The Next Tutorial 3 :Making a 3d Fullscreen application