Programming games in C++

xDexx
Unregistered
 
Post: #16
any idea when more neheX tutorials will be up? thanks!
-brett
Quote this message in a reply
Moderator
Posts: 697
Joined: 2002.04
Post: #17
Greets, wow, first vote of confidence for neheX Smile As for the glTranslatef() oddity, my badÖ I fixed the problem in the rotation tutorial and onwards, but haven't had a chance to update the others.

xDexx, the glTranslatef() oddity is caused by me reseting the 'centre' of the context manually, i.eÖ

[sourcecode]
Label_GraphicsLoop:
etc();
// In the graphics loopÖ
// Move the centre of the context some values.
glTranslatef(someX, someY, someZ);
DrawSomeGraphics();
// Move the centre of the context negatively the original values, i.e. reverting back to the original position.
glTranslatef( - (someX), - (someY), - (someZ));
etc();
goto Label_GraphicsLoop;
[/sourcecode]

Öwhere I should have used the glLoadIdentity() function instead (don't ask why I didn't, I don't know :sorry: )
So, when you change a glTranslatef() value in the first translate, but not the negative but equal value in the second translate, as you don't change the negative value, you don't reset to the original centre of the context, and so the drawn polygons move slowly offscreenÖ what should be there instead is thereforeÖ

[sourcecode]
Label_GraphicsLoop:
etc();
// In the graphics loopÖ
// Move the centre of the cvontext some values.
glTranslatef(someX, someY, someZ);
DrawSomeGraphics();
// Revert to the original centre of the context.
glLoadIdentity();
etc();
goto Label_GraphicsLoop;
[/sourcecode]

If this explanation makes no sense, blame it on the beginnings of a migraine, and email me and I'll email you the fixed source-code so you can compare.

As to when the next batch of neheX tutorials will be uploaded, sometime this weekend I'll upload the last in the 'introductory' catergory and Bryan Blackburns Cocoa ports, and the first of the 'intermediate' catergory tutorials, pending unexpected disastersÖ (we need a Godzilla smiley!)

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Moderator
Posts: 697
Joined: 2002.04
Post: #18
Forgot to reply to your original query xDexx; glTranslatef() effectively moves (ergo the 'translate') the centre of the context.

All drawing of vertices is done relative to the current centre of the context. For the 'proper' explanation, consult the Red Book (I'll post the link to the online version laterÖ)

(And yes, I know these explanations are wrong 'factually' in so many ways, but 'effectively' they're correct :?: )

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
w_reade
Unregistered
 
Post: #19
There's an online version near the bottom of the page here.

pdf or html, iirc. Technically, out-of-date, but still useful.
Quote this message in a reply
Moderator
Posts: 697
Joined: 2002.04
Post: #20
Thanks for the link, I'd lost it Blush (I've approximately 600 hundred bookmarks spread over four browsers Wacko ) I'll put a link to that and the Blue Book on the front-page of neheX.

Ah, just checking, but those html links are dead (the .pdf dl link still works though.)

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Moderator
Posts: 697
Joined: 2002.04
Post: #21
Found an online copy of the Red Book, now searching for BlueÖ and found these two links (1, 2) which seem to replicate the contents of the Blue Book.

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #22
If you're on Mac OS X, most of the blue book is available through the man pages -- type man glTranslate into the terminal, or 3 glTranslate into PB's "open man page" dialog.
Quote this message in a reply
xDexx
Unregistered
 
Post: #23
im trying to get these nehex tutorials to compile as a cpp file. it seems to have problems with this line:
InstallEventLoopTimer(GetMainEventLoop(), kEventDurationSecond/kFramesPerSec, NewEventLoopTimerUPP(TheLoop),Null, &theEventLoopRef);

the error its giving me is:
invalid conversion from 'void (*)()' to 'void(*)(__EventLoopTimer*,void*)'

any ideas? i really wanna get this working with c++ so i can use objects. thanks for all your help!
-brett
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #24
This is obviously a bug in the port...

Change the definition of TheLoop from void TheLoop(); to void TheLoop(EventLoopTimerRef timer, void *userData);
Quote this message in a reply
Moderator
Posts: 697
Joined: 2002.04
Post: #25
This was already pointed out by w_reade, but since it compiled properly as C, I didn't have it as a priority to fix, sorry Blush

I've uploaded fixed versions of the tutorials Blush

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Graphic Programming for Games brucegregory 24 7,840 Dec 30, 2005 05:24 PM
Last Post: ChrisD