Total members 11895 |It is currently Mon Dec 30, 2024 7:49 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi all , In this lesson i will explain full screen graphics concepts:


I will start with some question What is the difference between video card and monitor?
-Video card: stores what's on the screen in its memory and has several functions for modifying what's displayed. and push what's in its memory to the monitor.
-The Monitor: simply displays the information that the video card tells it to.

Screen Layout:
The monitor's screen is divided into tiny little color pixels that are all the same size.is a single point of light displayed by the monitor.The number of horizontal and vertical pixels that make up a screen is called the screen's resolution.

The screen's origin is in the upper-left corner of the screen.The pixels are stored in video memory like you read a book, starting from the upper-left corner and reading left to right, top to bottom. A location on the screen can be expressed as (x,y), where x is the number of horizontal pixels from the origin, and y is the number of vertical pixels from the origin.

What resolutions you can pick depends on the capabilities of the video card and monitor.Typical resolutions are 640x480, 800x600, 1024x768, and 1280x1024.

Pixel Color and Bit Depth:

As a child, you were probably taught the three primary colors of red, yellow, and blue. You also probably heard the phrase, "yellow plus blue is green." The idea is that when you are painting or using another physical medium, you can combine these three colors to create any color you want. This is known as a subtractive color model, in which the absence of all color is white. (Actually, it's not an exact color model modern printers use a more sophisticated color model using cyan, magenta, yellow, and black instead.)

The number of colors a monitor can display depends on the bit depth of the display mode. Common bit depths are 8, 15, 16, 24, and 32 bits.

  • 8-bit color has 28 = 256 colors. Only 256 colors can be displayed at a time
  • 15-bit color has 5 bits for red, green, and blue, for a total of 215 = 32,768 colors.
and so on.

Most modern video cards support 8-, 16-, and 32-bit modes. Because the human eye can see about 10 million colors, 24-bit color is ideal. 16-bit color is a little faster than 24-bit color because there is less data to transfer, but the color quality isn't as accurate.

Refresh Rate:

Even though your monitor looks like it's displaying a solid image, each pixel actually fades away after a few milliseconds. To make up for this, the monitor continuously refreshes the display to keep it from fading. How fast it refreshes the display is known as the refresh rate. The refresh rate is measured in Hertz (Hz), which means cycles per second. A refresh rate between 75Hz and 85Hz is usually suitable for the human eye.

Switching the Display to Full-Screen Mode:

You'll need a few objects to switch the display to full-screen mode:

Window object: The Window object is an abstraction of what is displayed on the screen, think of it as a canvas to draw on. The examples here actually use a JFrame, which is a subclass of the Window class and can also be used for making windowed applications.

A DisplayMode object: The DisplayMode object specifies the resolution, bit depth, and refresh rate to switch the display to.

GraphicsDevice object: The GraphicsDevice object enables you to change the display mode and inspect display properties. Think of it as an interface to your video card. The GraphicsDevice object is acquired from the GraphicsEnvironment object.

Here's an example of how to switch the display to full-screen mode:

java code
JFrame window = new JFrame();
DisplayMode displayMode = new DisplayMode(800, 600, 16, 75);

// get the GraphicsDevice
GraphicsEnvironment environment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = environment.getDefaultScreenDevice();

// use the JFrame as the full screen window
device.setFullScreenWindow(window);

// change the display mode
device.setDisplayMode(displayMode);

Afterward, to switch back to the previous display mode, set the full-screen Window to null:

device.setFullScreenWindow(null);


Which Display Mode to Use :

A lot of display modes are available, but which one should your game run at? Well, make sure your game runs in at least two resolutions. The general rule is to allow players to change display modes so they can pick the one they like best on their display.

If possible, initially run your game at the same resolution as the current resolution. On LCDs, the current resolution is most likely the LCD's native resolution, so the game will look nicer if you use the current one.

As for bit depth, using 16-, 24-, or 32-bit color is a good idea for modern games. 16-bit color is usually a little faster, but use a higher bit depth if you need more accurate color representation. Also, a refresh rate between 75Hz and 85Hz is suitable for the human eye. There are an attachment Full-screen.java class which switch the display to full screen mode for 5 seconds and then return to the normal mode.





Code:
  ACK. Developing games in java book.




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 109
Have thanks: 5 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Full Screen graphics (Lesson 2).
 full Screen Graphics     -  
 Splash Screen     -  
 Graphics commands list in C++     -  
 My Header is Not Fitting to the Screen!     -  
 Screen Capture and multicast     -  
 MacBook Pro Turned Into a Blue Screen     -  
 Flashing Graphics animations with threads     -  
 double buffering-applet animates graphics     -  
 how to screen scrape or grab some parts of a website?     -  
 JNI Basics lesson 1     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com