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 / d3dfont help

Author
Message
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 24th Sep 2009 20:23 Edited at: 24th Sep 2009 20:47
Hello, im trying to make my first class to create buttons, and to write text on it, so i wanted to use 3d3font to display it, and here is the code:


So when my program executes Font->DrawText() function it breaks and print unhandled exception at this line.

what am i doing wrong? although this example is taken from a directX9.0 book and edited abit to compile it without errors.
in the book DarwText() doesnt have the first parameter (the sprite), other parameters are same as what is writen in the book

oh and also, do i have to create a new device? or there is one already created by dgdk? and in the book the drawtext function is writen between Device->BeginScene() and Device->EndScene(), when i wrote that it made some errors, i shouldnt use those two functions while working with the DGDK right?

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 24th Sep 2009 22:17
I don't claim to be an expert on this but when I was working on my Image class, which does get down to the dx level, I tried writing text to an image. What I got wasn't an exception. I just didn't get the text I expected. Some online queries at gamedev.net gave an indication that the image you were drawing on needed to have been created with a particular usage property. Since I was working with a DGDK generated image I assumed that the image wasn't created with the necessary attributes. Maybe you're running into that from a different angle.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 24th Sep 2009 22:43
im not adding the text to the image itself, i just want to show it on the screen, didnt want to use dbText() because i wanted to work directly with directX, because i was thinking that sooner or later, if i focus on game creating the dgdk wont be enough and ill have to use directX for more controlling in my program, so i wanted to get used to it by making a simple text.

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 24th Sep 2009 23:55 Edited at: 24th Sep 2009 23:59
you need to grab gdks d3d device to display any text , dbgetdirect3ddevice() you will have to search the headers for the correct function spelling .

try this site http://www.toymaker.info/Games/html/text.html for an easy explanation of text functions.

chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 00:39
So instead of
IDirect3DDevice9* Device = 0;
i should use
dbGetDirect3DDevice() ?

also, i tried using CD3DFont class to display text, which caused some headaches for me

book code:


display text code:




i used the code above to display text in my game which caused some errors:


chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 25th Sep 2009 00:57
I think cd3dfont is a managed class , not sure whether it mixes well with gdk .

Give me half an hour and i will sort you some code out for this .


chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 01:23 Edited at: 25th Sep 2009 01:24
do you need all the files related to this code?

here : http://filebeam.com/1e87d5ca215313c341b0835a0e5e9c7a

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 25th Sep 2009 01:32
here you go its a quick function i made for you , prolly mistakes in there lol but its something you can base yours off .

good luck .


chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 01:38 Edited at: 25th Sep 2009 01:46
Ok i replaced Device with dbGetDirect3DDevice() and the program didnt crash, but i didnt get any text shown, tried to modify somethings in the structure but couldnt test it because my VC++ is screwed up somehow (read "few questions" topic, last post), oh well and about that ID3DXFont:: DrawText(), the first parameter is LPD3DXSPRITE, i saw a code on the net after a google search where it was NULL, do you have an idea about what is that parameter used for?



edit: thanks for the code, ill test it as soon as i get my VC++ working

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 25th Sep 2009 01:48
the first param is for a sprite , you can use your own d3dx sprite to display the text on and it renders faster , but its much easier to let directx handle it for you by passing NULL.

If you look on the site i posted above it shows somewhere how to create your own sprites these can also be used with gdk .

chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 01:50
Alright thanks a lot.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 16:07
Great, i got my class to work but there is only one problem left, my sprite appears over the text so the text is not shown, how can i solve this problem?

chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 25th Sep 2009 22:59 Edited at: 25th Sep 2009 23:00
in dbpro there is a command called draw sprites last/first or something like that look in the headers or docs for it that may work or make sure the text is before the sprites in the loop .

chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 25th Sep 2009 23:49 Edited at: 25th Sep 2009 23:57
void dbDrawSpritesFirst ( void );
void dbDrawSpritesLast ( void );

found these, ill test it right now.

ahh....again unable to start the program. I SO HATE THAT THING.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 26th Sep 2009 09:21 Edited at: 26th Sep 2009 09:22
alright, cool im almost done, one more thing left, when i call the destructor:

Nothing happens, the button (the sprite) doesnt get deleted.

here is the source code:



also, how do i delete the text? should i just add 'delete text;' in the destructor? oh well i did that and it triggers unhandled exception.

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 27th Sep 2009 01:47 Edited at: 27th Sep 2009 01:52
ok dbCLS() (even though its slow) solved the problem, but i found a new one ( ) i want to make an update function in the class, so when the mouse is over it it moves abit around, and when the mouse is away it goes back to its position, the question is the following:

see my code:

UIClasses.h

UIClasses.cpp

main.cpp


so as you see when i call the function button::Update() in the loop it works fine, updates the position but it doesnt remove the old sprite, so it looks like 2 sprites over each other, even though they both have the same sprite ID, looks like this:

....____________
...|___________...|
|........................|..| <----- old sprite
|........................|_|
|____________| <--------new sprite

Login to post a reply

Server time is: 2024-11-25 00:27:28
Your offset time is: 2024-11-25 00:27:28