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 / Game laggs in fullscreen

Author
Message
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 29th Nov 2011 21:37 Edited at: 29th Nov 2011 21:38
I'm making a simple 2D game. I run it in a 800x600x32 window. If I add the command dbSetWindowOff(); at the begining the game laggs teribly. How come? (sorry about the title typo)

Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 30th Nov 2011 01:21
What are your systems specs?
Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 30th Nov 2011 01:29 Edited at: 30th Nov 2011 01:30
When you "fullscreen" a game, if the resolution is not set to the system's current settings (and vice-versa), the image is rendered, then has to be scaled to fit the screen. This re-render can potentially take a LOT of memory, and often cannot be completed in time with the screen's synchronization.

Try using dbSetDisplayMode ( int Width, int Height, int Depth ) to set the screen resolution to that of your game first.

Tunnel vision yet? Have a carrot!
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 30th Nov 2011 18:38
I see. But then I also have to reposition and resize the sprites (2D game). Also, if other people play this, how can I make the game automatically adjust to the players resolution?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st Dec 2011 17:35
Quote: "how can I make the game automatically adjust to the players resolution?
"

I think the commands are:
dbDesktopWidth()
dbDesktopHeight()

Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 1st Dec 2011 18:11
Ok found it. It's dbScreenWidth , dbScreenHeight and dbScreenDepth. But why doesn't this work?


WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 1st Dec 2011 21:14
You will also have to use dbSetWindowOff() to activate fullscreen mode.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st Dec 2011 21:31
Try what I said

Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 3rd Dec 2011 02:40 Edited at: 3rd Dec 2011 02:41
Quote: "But then I also have to reposition and resize the sprites (2D game). "
No, you don't. When you set the resolution to that of your game's, it just fills the screen with your game WITHOUT the post-render resizing effect. The resize is not needed, as the screen is physically rendering more or less pixels (I'm assuming your game is smaller than the default resolution, so less pixels would be drawn).

Tunnel vision yet? Have a carrot!
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 3rd Dec 2011 14:06
Matty H: dbDesktopWidth() and dbDesktopHeight() don't exist.

Mister Fuzzy: My game's sprites are 800x600 pixels big. If I set the screen to my computer's resulution and fullscreen it it looks like this:


Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 3rd Dec 2011 18:06
I recommend you use 3D textured planes then, the will be in a 3D space so they will always be in the same position, and are much more flexible than sprites.
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 3rd Dec 2011 22:43
The game is already half done. I'll just make make a function that resizes and positions the sprites accroding to the resolution. The quaestion remains, how do you get the game to automatically adjust to the players resolution?

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 4th Dec 2011 00:31
Lookup the win32 Ali getsystemmetrics(). It will have what you're looking for.

JTK
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 4th Dec 2011 02:33
Here's how I do it:



Of course, there are other ways, but this one works fine too...

JTK
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 4th Dec 2011 19:09 Edited at: 4th Dec 2011 19:10
Whoah. I'm not really a pro so I don't know what some of that code does. But this is fine too right?



newfavo
User Banned
Posted: 5th Dec 2011 07:43
Congrats TGC!
It is pretty cool to see you standing next to the GIANT!



______________
protection programs
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 7th Dec 2011 19:29
Quote: "Congrats TGC!
It is pretty cool to see you standing next to the GIANT!"


What?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Dec 2011 21:12
Quote: "Matty H: dbDesktopWidth() and dbDesktopHeight() don't exist."


They do, I just tried it. I don't think they are documented.

Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 7th Dec 2011 22:17


Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Dec 2011 23:34
Weird, there are two possibilities as far as I can see.

1. We are using different versions of GDK
2. I have had to add the function declarations to the header file and forgot I did it.

In case of 2, put this at the top of your code:



JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 8th Dec 2011 01:03
That's why I created a new "GDK_MissingDefs.h" that has what I've needed to add as I discover them. Then include that file too...


JTK
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 8th Dec 2011 05:41
In keeping with what I believe Mr Bigglesworth is referring to, here's some sample code with a ton of comments to explain what's happening when...

First, it sets the game's window size to match the current screen resolution. It does not use dbSetWindowOff() because that causes other problems that (to me anyway) you're not ready for. Unless you already have a means to detect and handle a user that uses alt+tab to switch to some other program during your game, you should avoid using dbSetWindowOff(). This sample provides an alternative to avoid those headaches...

Anyway, it then loads an image (currently set to "media\\background.jpg" but can be set to whatever image you want) and follows that with several calculations based on a few assumptons, the loaded image size and the full screen size...

After the calculations are complete, a 3D-Plane (plain) object is created, position and textured using the loaded image.

Finally, some global commands are used to satisfy the *assumptions* used during the calculations before entering the main loop (which itself simply plasters the image to the screen until the escape key is pressed)...



I know it may seem a bit overwhelming but it really isn't that bad once you understand what's happening. It illustrates two points from the posts above:

- How to set the game screen size to the player's current configuration, and;

- How to stretch an image (using 3D-Plains) across the full screen.

You can just copy/paste this code into a new project, change the image to be loaded and trace through the code using the debugger to get a better understanding of what's actually happening under-the-hood.

Hope this helps,

JTK

Login to post a reply

Server time is: 2024-11-19 06:54:57
Your offset time is: 2024-11-19 06:54:57