Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Changing from windowed mode to full-screen...am I doing something dangerous?  (Read 2807 times)
0 Members and 1 Guest are viewing this topic.
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Posted 2012-09-05 01:53:47 »

Hi!

I'm making a side-scrolling shooter, and I've successfully implemented resolution change and windowed/fullscreen-mode changing. Only problem is, very rarely the screen goes black when I change to windowed mode. I end up with a black fullscreen window, I have my custom cursor and if I Alt-Tab I can see from the little preview Windows 7 gives me at the taskbar, that the menu is being shown in my game, but when I enter it again it is still black, with the cursor. Then I click where I think the "Apply" button is, and it changes to the correct windowed resolution WITH my menus being shown.

It's really weird, and I think it might have something to do with my brute-force way of changing the displaymode. Could someone tell me what might be causing this?

The if-statements are there, because I use these functions to set the screen windowed/full-screen depending on settings loaded from a configuration-file when the game starts. So the if-statements are skipped when the game starts, but if the settings are changed within the options-menu, it'll transfer the current input-handlers and cursor from the window to the full-screen frame and vice versa.

I have separate methods for changing resolutions for windowed mode and full-screen mode respectively, when the windowed-mode flag has not been changed in the options menu, and those work just fine.

Pastebin link

- Jonas
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #1 - Posted 2012-09-27 19:55:47 »

Well, I know it's wrong to bump Sad , but I've yet to find a fix for this. I've tried so many things by now, and I just can't stop this from happening on rare occasions. Sometimes it's on first try, and sometimes I have to do it 40 times before it happens, but it always does eventually.

Please, someone with intricate knowledge of the way the graphics environment for 2D works, help me. Many medals will come in an answer's wake Cheesy

- Jonas
Offline 65K
« Reply #2 - Posted 2012-09-27 21:50:34 »

1  
2  
3  
4  
try {
    vc.setDisplayMode(dm);
} catch (Exception ex) {
}

An empty catch block ?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #3 - Posted 2012-09-28 01:18:58 »

1  
2  
3  
4  
try {
    vc.setDisplayMode(dm);
} catch (Exception ex) {
}

An empty catch block ?
Thanks for your input! Much appreciated!
Well, maybe...I'll try to debug it. That really shouldn't ever fail, though. But I hope that's it.

- Jonas
Offline DrHalfway
« Reply #4 - Posted 2012-09-28 02:50:01 »

1  
2  
3  
4  
try {
    vc.setDisplayMode(dm);
} catch (Exception ex) {
}

An empty catch block ?
Thanks for your input! Much appreciated!
Well, maybe...I'll try to debug it. That really shouldn't ever fail, though. But I hope that's it.

Can't assume such things unfortunately  Grin

never hurts to print or dump the error into a file for exceptions such as those.

Offline 65K
« Reply #5 - Posted 2012-09-28 07:48:18 »

Otherwise, if things only sometimes fail, it results often from incorrect threading.

Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #6 - Posted 2012-09-28 12:48:53 »

It could be because you keep dumping the frame everytime you switch modes. Try using a single JFrame for the entire lifecycle of the game whether you are in fullscreen or windowed mode.

Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #7 - Posted 2012-09-28 17:28:08 »

Otherwise, if things only sometimes fail, it results often from incorrect threading.
Yeah, maybe I should put the game in a state where nothing is updated or drawn until the change has been achieved. It's just that this is all called from one controller-class, so it should never trip over itself. The changes should be executed completely linearly.

It could be because you keep dumping the frame everytime you switch modes. Try using a single JFrame for the entire lifecycle of the game whether you are in fullscreen or windowed mode.
Hmm, yeah I'd like to do that, but there are some reference-problems associated with that.

Can't assume such things unfortunately  Grin

never hurts to print or dump the error into a file for exceptions such as those.
I'll definitely do that, and see if it ever fails.


In conclusion, it could well be all these three rather simple things. Thank you very much for your inputs. I guess I have an evening of destroying my graphics adapter in front of me XD
I'll post back if I find a solution that keeps the weirdness away.

- Jonas
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #8 - Posted 2012-09-28 18:11:58 »

Well, it's not to do with the unhandled exception.
On to the game-state safety-lock...

EDIT: Not fixed by inserting continuity safety-locks

Then it has to be the changing between frames...

- Jonas
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #9 - Posted 2012-09-28 20:38:18 »

*frustrated troll-face*

I can't get this to work! If I use just 1 frame, and change that between being fullscreen and windowed, either the windowed state wont draw anything, or the change to fullscreen doesn't work. I can get one state to work at a time.

*heart breaking*

Why?! It works fine using the pastebin'ed-way, except for that small little thing. I can't even get it to spit out any errors or anything. I've scattered messages all over, wherever it could possibly return a null or something unusable (that's quite a few places!), and none report back to me when it happens. And the weirdest thing is, when I get the black screen and Alt-Tab out, the Windows taskbar taunts me by showing a preview of my application correctly displaying the graphics...WTF?!

I'm tempted to just leave it there...but it's the basis of the game. It's the ScreenManager-class... I have to use this for all my games. And it's being picky.

Sorry for ranting. I'll dive back into it.

- Jonas
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2


Make it work; make it better.


« Reply #10 - Posted 2012-09-29 05:08:59 »

One other thing. Have you downloaded your most recent graphic drivers?

Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #11 - Posted 2012-09-29 09:56:54 »

One other thing. Have you downloaded your most recent graphic drivers?
Well, not the absolutely newest, but they're not more than a couple of months old. It IS a laptop, though. Geforce 525M /w 1024mb. But surely that can't be it. But good point, nonetheless; check the hardware. I shall have to test on my desktop computer

- Jonas
Offline Zixradoom

Innocent Bystander





« Reply #12 - Posted 2012-10-03 17:56:46 »

Did you call the change function in the EDT, Someone else mentioned concurrency issues, so it could be something between your update thread and the EDT.

Woo Hoo Java!!
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #13 - Posted 2012-10-03 19:06:43 »

The control-polling, updating and drawing is all happening in the same thread. Only loading of assets is done in another thread, and has nothing to do with this problem.

I just can't figure it out...

- Jonas
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #14 - Posted 2012-10-04 00:21:49 »

Your computer is going to explode. Stop doing this!

Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #15 - Posted 2012-10-05 11:34:21 »

Your computer is going to explode. Stop doing this!
What should I stop doing?! David Spade is NOT usually scary to me!

- Jonas
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!