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 / text (specifically int->chat conversion) issues

Author
Message
Vesper
14
Years of Service
User Offline
Joined: 22nd Nov 2009
Location:
Posted: 28th Jan 2010 01:31
I suppose my first topic i want to ask about is text on top of sprites, i got it working but i notice its really really slow. Heres how im doing it:





is there any faster more efficient way of doing this? as it takes a lot lot lot of time, would i gain any noticeable speed from making a function for this?

second is im trying to convert the returned data from dbMouseX to a readable char array to output with db text but i keep getting wierd data which i assume is garbage or some misconversion. Ill include a zip of my program as well as full source. but yeah heres the source.



Show me your combat algorithms(programmers read this NOT in a programming state of mind)

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 28th Jan 2010 01:54
Quote: "second is im trying to convert the returned data from dbMouseX to a readable char array to output with db text but i keep getting wierd data which i assume is garbage or some misconversion"


dbChr() returns a character from a passed ASCII value, to construct a c-style string from a value you want either sprintf or stringstream:



or



Stay away from dbStr as if your life depended on it.

Vesper
14
Years of Service
User Offline
Joined: 22nd Nov 2009
Location:
Posted: 28th Jan 2010 03:48
ok thanks i fixed it using the sprintf_s function however now i only get around 1fps still when the mouse is moving, if mouse is not moving i get around 45-50. I altered the code to only grab the new screen if mouse moves. any ideas how to make this more efficient and faster? sorry about all the questions but this is the only way i could find to put text on top of sprites



Show me your combat algorithms(programmers read this NOT in a programming state of mind)
pepebotellas
14
Years of Service
User Offline
Joined: 22nd Jan 2010
Location:
Posted: 28th Jan 2010 06:00
Hey,

I was looking around a while ago because my FPS was very slow, and tried to optimize my code but improvement wasn't so great.

Reading some posts I saw ppl complaining that dbText, and all functions related with text drawing like dbInk and the like were very slow.

This is a plugging that you can use to draw text faster.
http://forum.thegamecreators.com/?m=forum_view&t=57964&b=22

Your code looks reasonable so I am guessing it might be the same problem I had (i.e dbText slows you down). Give it a try and hopefully it will solve your problem.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 28th Jan 2010 07:09
If by on top you just mean layered, and not as part of the sprite then I'd advise you only use dbPasteSprite, that way you get full draw-order control. Thus, as soon as you create the sprite initially(dbSprite), just hide it and only paste it when you need it, also, that way you only need to load each type of sprite once.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 28th Jan 2010 22:48
Though it probably won't speed up the frames any I'd recommend using the itoa function instead of sprintf. It's dedicated to integer conversions where there's a little overhead for sprintf needing to analyze the formatting string and doing conversions based on choices.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Vesper
14
Years of Service
User Offline
Joined: 22nd Nov 2009
Location:
Posted: 30th Jan 2010 08:34 Edited at: 30th Jan 2010 08:35
Okay with the text addon i got maybe 1 or 2 fps increase (now at 3 or 4) using the edited version given in that post, and with itoa i sometimes get 1 extra. heres my edited source, i can figure out for the life of me how to get text on top like I want without sacrificing speed(I only lose speed when the mouse is moving btw which makes me think its the get image part)

Text.h

Text.cpp

My Source


also with itoa my mouse x variable displays a letter now so it can say like 20a or 150b mostly only a's and b's tho

Show me your combat algorithms(programmers read this NOT in a programming state of mind)

Login to post a reply

Server time is: 2024-10-01 23:28:21
Your offset time is: 2024-10-01 23:28:21