Programming games in C++
Greets, wow, first vote of confidence for neheX
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!)
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
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 :?: )
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
There's an online version near the bottom of the page here.
pdf or html, iirc. Technically, out-of-date, but still useful.
pdf or html, iirc. Technically, out-of-date, but still useful.
Thanks for the link, I'd lost it
(I've approximately 600 hundred bookmarks spread over four browsers
) 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.)
(I've approximately 600 hundred bookmarks spread over four browsers
) 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
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.
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
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
This is obviously a bug in the port...
Change the definition of TheLoop from void TheLoop(); to void TheLoop(EventLoopTimerRef timer, void *userData);
Change the definition of TheLoop from void TheLoop(); to void TheLoop(EventLoopTimerRef timer, void *userData);
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
I've uploaded fixed versions of the tutorials
I've uploaded fixed versions of the tutorials
Mark Bishop
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Graphic Programming for Games | brucegregory | 24 | 7,430 |
Dec 30, 2005 05:24 PM Last Post: ChrisD |
|

