Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Something's wrong here.

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 1st Aug 2009 05:16 Edited at: 1st Aug 2009 05:20
Alright, decided I wanted to start on another GDK project, but hit a couple problems right out the starting gate.

Here's the source code... very simple.


Here are the problems:
1) Even though I initialize 10 objects the same way... only the first one actually gets rotated and textured. The others are unrotated and solid white (texturless)

2) I declare ct and initialize it with a value of 0... yet it's printed on screen as 7006.


Have I done something wrong here? Maybe something stupidly simple that I've overlooked?


[EDIT]
Attached a pic of what happens so you can see the problems better.


The one and only,


Attachments

Login to view attachments
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 1st Aug 2009 05:39
looking quickly, you are creating you 10 objects, but you are positioning and rotating them all exactly the same way, so they are all goin to be ontop of each other ? ie. you are positioning object i at 0, 0, 0 .. so each object will be at that position, same with the rotation, the texture is ok.

Ok, you are starting you loop at 0, and using the loop position as your object numbers, Im pretty sure in DarkGDK you cant have an object with an ID of 0, so you will need to add 1 to the value being passed to the functions, so instead of dbTextureObject(i, 1) you would have dbTextureObject((i+1), 1); .. the extra parenths arent needed in this case, it just makes intention clear.

As for you variable "ct" ... im not 100% sure why it would be changing to 7006 but I think it may have to do with passing dbStr directly to dbText, I remember reading somewhere that is a no-no as it causes a memory leak somwhere, instead you should store any pointer values like that in your own variables, that you pass to the functions, that way you can take care of their cleanup properly. The dbStr() function returns a pointer to a character array(char*), so if you dont handle it properly it will result in a memory leak.

That is a very basic explanation, im sure that someone will be able to exaplin to you more fully exactly why the above behaviour happens and how to avoid it, or you can do some research on pointers and their use in c++ by searching for some tutorials with google, I know there are a bunch of great tuts here :
http://www.cplusplus.com/doc/tutorial/ that will give you some useful things to think about.

If it ain't broke.... DONT FIX IT !!!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 1st Aug 2009 05:50
Thank you very much. It was indeed the fact that I was trying to use 0 as an object identifier.

Fixing that, the variable problem was fixed as well. I normally don't do haphazard usage of my variables like that, it was only in there to get a quick readout on some debug info.

All is well again, thanks very much!


The one and only,


Login to post a reply

Server time is: 2024-10-01 08:47:59
Your offset time is: 2024-10-01 08:47:59