I've just posted the fourth in a series of OpenGL tutorials geared toward game development. They are for masm, and use ATC oop model.

Tutorial #1 introduces a basic Win32/OpenGL skeleton application.
Tutorial #2 adds code for a highperformance timer.
Tutorial #3 adds code for a QuaternionRotation firstperson camera.
Tutorial #4 adds code for a class to manage an array of instanced objects.

Not a bad start, huh?
The next tutorial will introduce a class to provide Frustum Culling.

Find all this and more at my dumpsite, http://homer.ultrano.com
(The OpenGL stuff is in the Beginners section, in a popup menu).
Posted on 2005-02-20 06:38:38 by Homer
Nice, 2 more tutorials online now :D ill start reading them later today after im done making my homework.

ok i started studying the tuts now, and when i run the prog included by tutorial #1 and i run it in fullscreen my screen isnt all black but keeps flicking really fast between desktop and black, i tryed running the app from tutorial #2 and it works fine in fullscreen, any idea why this is? (havent studyed the tuts yet)

Posted on 2005-02-20 07:04:57 by Scorpie
Tutorial #1 has no real "render" code, so what you see is rather dependant on your hardware. It creates an OpenGL rendering window, yet it never renders anything.... the latter tutorials always render "something". The OpenGL Skeleton application is simplistic, in that respect. It's meant to be.

I've written the code for tutorial#5 - frustum culling (culling via the current camera view). Text for tutorial #4 (Camera) needs revision.
I'm working on the code and text for tutorial #6 at the moment - we introduce a new class for managing N instances of colored or textured 3D quad surfaces, and then start to talk about collision detection (for Sphere object with Surface) and response. The 3D quad surfaces class is currently useful for implementing the word terrain, it currently does not provide surface culling, but can and should be extended to allow it to implement instanced complex geometric objects with the aforementioned physical properties.

I'm getting very little feedback regarding the OpenGL tutorials, yet I sense some people are listening.
If you are new to all this, I'd like to hear from you - particularly I'd like to hear from those disturbed members of society who simply don't get it.
Does this sound like you? If so, yell out !! Everything is free :)
Posted on 2005-02-22 08:37:00 by Homer
well as you might have noticed (or you didnt notice me at all yet) im fairly new to assembly and especially opengl but i do hang around this subforum from time to time (depends how busy i am with school and all).

I've almost finished with the timer tutorial now and i really like your tutorials i seem to learn more from them then other tuts which just have a big piece of text that contains a few lines of code from time to time since your tutorials force me to read the code better to understand it and i like to check out all the extra files included to see the macro's you use and how they work.

i've noticed some things that could be faster imo and some things like calling GetModuleHandle twice and all but i dont have much comment on them yet really, i'd say keep up the good work 8)


edit: i got a little question about the timer in the using QueryPreformanceCounter since i've never worked with FPU before, it's regarding the following part

;   Return the elapsed time


fld qword ptr [TIMERPC_qwTime]
fsub qword ptr [TIMERPC_llLastElapsedTime]
fdiv qword ptr [TIMERPC_llQPFTicksPerSec]
fstp dword ptr [TIMERPC_fElapsedTime]

fld qword ptr [TIMERPC_qwTime]
fstp qword ptr [TIMERPC_llLastElapsedTime]

fld dword ptr [TIMERPC_fElapsedTime]


wouldnt the following code result into the same?
;   Return the elapsed time


fld qword ptr [TIMERPC_qwTime]
fst qword ptr [TIMERPC_llLastElapsedTime]

fsub qword ptr [TIMERPC_llLastElapsedTime]
fdiv qword ptr [TIMERPC_llQPFTicksPerSec]
fst dword ptr [TIMERPC_fElapsedTime]


Posted on 2005-02-22 09:13:43 by Scorpie
Short answer - Yes.
Longer answer - don't blame me for Scronty's Timer code - I only added the "frame to frame" elapsed time thingy. Don't blame Scronty either, I believe the code was rather directly translated from dx8? sdk.
I'm sure these and other optimisations lay in wait, my goal here is to provide relatively useful (hopefullly commented) sourcecode and descriptive narrative, not to write the world's tightest x86 asm.
I sometimes deliberately omit obvious optimisations in my quest for the provision of moron-friendly tutorials - it has to be easy to read, thats what counts. Since you have noticed I place emphasis on the sourcecode rather than the narrative, I'm sure you would appreciate this. I could just as well optimize every line of source and give you something totally alien to read, and who would benefit from that?
Posted on 2005-02-22 09:40:36 by Homer
thanks for the awnser it was more a question to get understand the FPU better, and for tutorials its indead better to not optimise the code while people dont even understand what it does exactly.

I do have discovered one little line in the timer tutorial that you've commented wrong (well reading it i think the line is wrong not the comment)

inside OGL_Camera.asm:
	invoke glTranslatef , r4_0_0, r4_0_0 ,r4_m5_0;				// Move Left 1.5 Units And Into The Screen 6.0

you declare the "fpm1p5 REAL4 -1.5f" and "fpm6 REAL4 -6.0f" a few lines above it but you just didnt use them in the code :)
if the comment is wrong it should only be Move 5 Units into screen.

Edit: where can i find the class32.inc i tryed searching for it but i dont seem to be able to find it i need it to compile (can only find ultrano's CLASS.inc but when i rename that one i get a lot off compile errors so i gues it isnt the right one)
Posted on 2005-02-22 09:54:06 by Scorpie
I've uploaded Class32.inc for you : http://homer.ultrano.com/Class32.inc
That comment you mentioned is wrong and I'll modify it when I find a spare moment.
I also have to find some time to rewrite the text for Tutorial #4 because I ended up rewriting the Camera class and that code no longer matches its description.
Tutorials #5 (FrustumCulling) and #6 (Surfaces) are well underway - the code for #5 is ready.

Have a nice day :)
Posted on 2005-02-22 22:27:48 by Homer
Two new classes were written today for Tute#6.
They are called TextureManager and SurfaceQuads.

SurfaceQuads class manages an array of flat 3D rectangles ("quads") which may be textured or plain (have pervertex color).
It contains code for adding, modifying and rendering surfacequads.
It also contains code to spew its content to a binary datafile (save all quads), and later I'll add code to (re)load from such files, and possibly to import from some common geometry file formats like OBJ.

TextureManager class manages two arrays (NameStrings and TextureIDs) and provides methods for adding textures and for looking up "texturename by id" and "id by texturename".

I've already implemented plain surfaces in the demo executable.
I'll implement textured surfaces and then write up Tutorial #6 without covering collision detection and response, which will likely be covered in Tutorial #7.

Have a nice day :)
Posted on 2005-02-23 01:49:33 by Homer
thanks for uploading the class32.inc. I got some errors while compiling with this file on line 451-453 its about BOOL so i commented it out now for a sec.
But i have errors with Code_3DMath.inc and CQuaternion.inc because i dont have i dont have any files containing the macros for the __JGE etc functions i guess they are in your macros.inc but they are not in the version on your site so if they should be in there can i get the new version?
Posted on 2005-02-23 04:10:39 by Scorpie
The floating point macros like __FJG come from one of the files in Caleb's DX8 includes called d3dx8math_fkt.def
I merely helped myself to what I needed (floating point compare macros in this case).

I've uploaded it to http://homer.ultrano.com/d3dx8math_fkt.Def for you.
I also uploaded my existing macros.inc file to http://homer.ultrano.com/macros.inc

Have a nice day :)
Posted on 2005-02-23 06:59:26 by Homer
Thanks for uploading those files, the new macros.inc did the trick its compiling and running fine now 8)
Looking forward to the new tutorials, keep up the good work

Posted on 2005-02-23 09:22:54 by Scorpie
Text for OGL Tutorial#3 was revised.
This tutorial describes the data fields of an OOP-based FirstPerson Camera, including basic physics for camera such as linear deceleration (simulates air resistance in direction of travel which is proportional to velocity).

Text for OGL Tutorial#5 was published.
This one covers FrustumCulling, and uses the "plane grabbing" method of constructing the frustum from the current camera view.
Posted on 2005-02-23 22:27:59 by Homer
nice ill read tut 3 again and have a look at tut 5, the text of 4 isnt upgraded yet right?

edit: havent read them yet ill do it later tonigh i think. I've started working on a class which allows you to load models from files and draw them onto the screen, for now it only has a square in it but i think it looks sweet :) ill let you know more once it has some improvements and can do more than just draw a square. (btw, my first try with OOP in Asm and i love it already :alright: )
Posted on 2005-02-24 12:20:59 by Scorpie
Tutorial #4 (Sphere primitive and Manager classes) is fine as it stands as far as I am aware, although it has been extended recently to support collision detection between a given Sphere and given Surface Plane (where Plane is defined by Surface Normal).

I make only the assumption that all surface quads are FLAT, because I calculate the SurfaceNormal from the first Triangle in the quad.

You can probably see that the Sphere/Spheres classes and the Surface_Quads class are becoming rather closely knit.
Posted on 2005-03-01 02:08:41 by Homer
If I receive some expressions of interest, I will write tutorial 5 part B to describe the inner workings of the Camera class in detail.
Otherwise I expect people will just use it without a deeper understanding, which is also fine, since any source I post here is 100% free to use as you please, without license. I only ask that you credit me where applicable, and that is likewise a matter of your own conscience.
Posted on 2005-03-01 02:12:46 by Homer
hmm question, do you prefer working with quads instead of triangles? and if so can you explain why?

well i like your tutorials but i already understand how a camera works since i also did some software 3D rendering before i still need to read a more detailed tutorial about quaternions though but i got it already, just need the time :)
Posted on 2005-03-01 10:52:01 by Scorpie
I'm working with Quads because I felt like it.
I'd already implemented Spheres, and now I wanted to collide them with one or more surfaces. It made sense to start off with one big flat FLOOR QUAD and then maybe later add some slopes and walls.
The other reason is that some time ago I wrote a 2D/3D MAZE GENERATOR which to this day has not been implemented in a graphic application, and all it really needs is a way to create walls, floor and ceiling quads and I can get it up and running fast.
What have I got against triangles? Well nothing really.
In fact, all the surface collisions stuff I'm using for the Quads is really meant for Triangles - it involves collision with the theoretical infinite PLANE, which I calculate from the FIRST TRIANGLE IN EACH QUAD (I assume my Quads are flat - they better be !)
You have given me an idea on how to improve my Quads class further though. It currently stores two arrays ("plain" and "textured" quads), with textured quads each storing a textureid. I should store N arrays of textured quads, with a textureid per array, thus I have all my Quads sorted by texture, making rendering much more efficient (avoids texture thrashing). I might work on that later today, although it'll mean reworking the Load and Save methods a fair bit...
Posted on 2005-03-01 22:50:47 by Homer
GameTutorials.com is now charging $5 for even the most basic of tutorials, with only a handful of free tutorials remaining.

All of a sudden my little dump is getting big hits... If anyone wants asm translations for the first 30 odd GameTutorials.com demos, let me know.

As far as I am concerned, they were free and unlicensed at the time I translated them - my translations of them remain free and unlicensed.
Posted on 2005-03-02 07:21:39 by Homer
i'll be sticking to Nehe's tutorials, no need to pay :)
your tuts are cool too Evil.
Posted on 2005-03-02 09:48:11 by wizzra

GameTutorials.com is now charging $5 for even the most basic of tutorials, with only a handful of free tutorials remaining.

All of a sudden my little dump is getting big hits... If anyone wants asm translations for the first 30 odd GameTutorials.com demos, let me know.

As far as I am concerned, they were free and unlicensed at the time I translated them - my translations of them remain free and unlicensed.

I will, please. Pretty please :)
Posted on 2005-03-27 01:14:14 by scarpelius