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 / Can you change the color of Text in Dark GDK?

Author
Message
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 17th Oct 2009 09:47
Is there a way of changing a text color on Dark GDK.Nothing jumps out at me in the list of commands.Right now I\'m working on putting up the score as text.

dbText(0,0,dbStr(score));

is what I have down in a function right now.But because my space background is black I\'m wondering if the text is being displayed in black as well rendering it virtually invisible.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Oct 2009 09:51
dbInk()

Though I wouldn't use it too often as GDK isn't known for its 2D prowess(though sprites are pretty fast, but they are technically 3D).

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 17th Oct 2009 10:17
Thanks for the quick reply.I tried it out but still nothing.I tried several of the commands that had to do with text but so far no text is on my screen...this is the function I have so far..



and I placed the call to that function in the loop portion of the main.cpp page. No errors or anything.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Oct 2009 13:49
What does your main loop look like?

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 17th Oct 2009 17:20
This is my main.cpp file.I tried to call this function from in the loop and from outside it.But both attempts ended the same no text displayed.



It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Oct 2009 17:47 Edited at: 17th Oct 2009 17:48
Looks fine to me, are you sure nothing 2D is drawn to the screen after you display the text? Like your background image or something. Also I'm not sure how GDK sprites(non-pasted ones) behave with the 2D drawing functions, they may get drawn after.

Also I forgot to mention this before but you shouldn't do: 'dbCenterText(400,0,dbStr(score));' as it will cause a memory leak every time you call this, as dbStr dynamically allocates memory for the string and it's up to you to free it which you can't do in code like that. I'd advice you store a char array buffer(to be used as a string) on the stack and use sptrintf() to create the formatted strings from various variables using this buffer; it's more flexible and doesn't require you to handle the memory deletion.

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 18th Oct 2009 03:25
Alright I saw people approaching it that way on some earlier topics I found in this forum.I'll try it that way and see if I come up with a better result.Thanks for the help.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 18th Oct 2009 14:16 Edited at: 18th Oct 2009 14:18
The function Score is commented out in your main loop... It won't even be called, maybe that's why it doesn't work?
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 20th Oct 2009 19:23
I see what you're saying Mirebin...That's because I sometimes have trouble figuring out where in the code I should place things.So sometimes I will place the call to a function in two places and comment one out to see where it should be in the code.I have tried it with the call to Score() uncommented in the while loop but still nothing...

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 20th Oct 2009 22:30
OK, another guess. There is a reference to a background image at the end of the program. Isn't the text behind the background picture? But I see that Dark Coder has already mentioned this. Nothing seems to be wrong with the text and colour commands.
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 6th Nov 2009 08:07
I'm sorry I took so long to come back to this problem but I was kinda frustrated.I commented out the background and sure enough Mireben you were right.But I don't get why.The setup.h file is the first thing read.I even went back in the code and moved the Score() function to the last part of the while loop and it's still drawn in back of the background.Is there any command I can use to make sure that the background is as far back as I can get it?

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 6th Nov 2009 18:33
Sorry about the double post but I figured this part out.Required a little digging but I found a command that helped.



This is the code.dbDrawSpritesFirst() was the function I needed.The command is usually used in 3d though and causes all 2d to take a back seat to 3d objects on the screen.seems to work for text as well... who knew.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

Login to post a reply

Server time is: 2024-10-01 16:36:37
Your offset time is: 2024-10-01 16:36:37