This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes A problem about full-screen exclusive mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A problem about full-screen exclusive mode" Watch "A problem about full-screen exclusive mode" New topic
Author

A problem about full-screen exclusive mode

Zong-han Xie
Greenhorn

Joined: Feb 18, 2012
Posts: 1
Hi everyone.
One of my friends is working on a program to test a LCD screen capability. In that program, some test screen patterns (like some BMPs) are drawn on the screen and switch between these patterns with frequency of 120Hz or 240Hz, depending on the frame rate of the video card. My friend did it with DirectX. He said that the pattern must be write into VGA memory directly in order to catch the speed of the frame rate of the video card. However, DirectX is not a cross-platform library. I am now trying to complete this in Java. Can Java complete this task?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Technically it should be possible using GraphicsDevice.setFullScreenWindow, a javax.swing.Timer and either custom painting or a window-filling JLabel with the image. For 120Hz (120/s) the timer's delay should be 1000/120 which is about 8, and 1000/240 which is about 4. These might be too small to be accurately handled though.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Daniel Croft
Greenhorn

Joined: Feb 16, 2012
Posts: 21

Here's some code from a game that I'm currently writing, you might find it helpful. It uses a two buffer strategy and blits between them to avoid tearing. It also uses active rendering instead of waiting for repaint events which should help you control the frame rate. It keeps track of the frame rate, so that should help you make sure it's fast enough; just set the RenderThread.sleep() to 8 or 4 like rob said.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38068
    
  22
And welcome to the Ranch
 
jQuery in Action, 2nd edition
 
subject: A problem about full-screen exclusive mode
 
Similar Threads
Video snapshot in java
Competitive Java 2D performance?
reading data from video encoder
Game!
Size of frame problem /XP