2
2
* Copyright (c) 2002-2008 LWJGL Project
3
3
* All rights reserved.
5
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
6
* modification, are permitted provided that the following conditions are
9
* * Redistributions of source code must retain the above copyright
9
* * Redistributions of source code must retain the above copyright
10
10
* notice, this list of conditions and the following disclaimer.
12
12
* * Redistributions in binary form must reproduce the above copyright
13
13
* notice, this list of conditions and the following disclaimer in the
14
14
* documentation and/or other materials provided with the distribution.
16
* * Neither the name of 'LWJGL' nor the names of
17
* its contributors may be used to endorse or promote products derived
16
* * Neither the name of 'LWJGL' nor the names of
17
* its contributors may be used to endorse or promote products derived
18
18
* from this software without specific prior written permission.
20
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22
22
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
27
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
29
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
30
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
40
* Test class for Display & DisplayMode
42
42
* @author Brian Matzon <brian@matzon.dk>
43
* @version $Revision: 2983 $
44
* $Id: DisplayTest.java 2983 2008-04-07 18:36:09Z matzon $
43
* @version $Revision: 3418 $
44
* $Id: DisplayTest.java 3418 2010-09-28 21:11:35Z spasi $
46
46
public class DisplayTest {
49
49
* Creates a new DisplayTest
51
51
public DisplayTest() {
60
60
setDisplayModeTest();
61
setDisplayConfigurationTest();
61
setDisplayConfigurationTest();
65
65
* Prints some info about the current mode
67
67
private void currentTest() {
68
68
System.out.println("==== Test Current ====");
70
70
System.out.println("Info about current:");
71
71
System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion());
72
System.out.println("Resolution: " +
73
Display.getDisplayMode().getWidth() + "x" +
74
Display.getDisplayMode().getHeight() + "x" +
75
Display.getDisplayMode().getBitsPerPixel() + "@" +
72
System.out.println("Resolution: " +
73
Display.getDisplayMode().getWidth() + "x" +
74
Display.getDisplayMode().getHeight() + "x" +
75
Display.getDisplayMode().getBitsPerPixel() + "@" +
76
76
Display.getDisplayMode().getFrequency() + "Hz");
77
77
System.out.println("---- Test Current ----");
81
81
* Tests querying for modes
83
83
private void queryModesTest() throws LWJGLException {
84
84
DisplayMode[] modes = null;
86
86
System.out.println("==== Test query ====");
87
87
System.out.println("Retrieving available displaymodes");
88
88
modes = Display.getAvailableDisplayModes();
105
105
System.out.println("---- Test query ----");
110
110
* Tests setting display modes
112
112
private void setDisplayModeTest() throws LWJGLException {
113
113
DisplayMode mode = null;
114
114
DisplayMode[] modes = null;
116
116
System.out.println("==== Test setDisplayMode ====");
117
117
System.out.println("Retrieving available displaymodes");
118
118
modes = Display.getAvailableDisplayModes();
120
120
// no modes check
121
121
if (modes == null) {
122
122
System.out.println("FATAL: unable to find any modes!");
127
127
System.out.print("Looking for 640x480...");
128
for(int i=0; i<modes.length;i++) {
129
if (modes[i].getWidth() == 640 &&
130
modes[i].getHeight() == 480) {
132
System.out.println("found!");
128
for ( DisplayMode mode1 : modes ) {
129
if ( mode1.getWidth() == 640 &&
130
mode1.getHeight() == 480 ) {
132
System.out.println("found!");
138
138
if (mode == null) {
139
139
System.out.println("error\nFATAL: Unable to find basic mode.");
143
143
// change to mode, and wait a bit
144
144
System.out.print("Changing to mode...");
153
153
System.out.println("done");
155
System.out.println("Resolution: " +
156
Display.getDisplayMode().getWidth() + "x" +
157
Display.getDisplayMode().getHeight() + "x" +
158
Display.getDisplayMode().getBitsPerPixel() + "@" +
155
System.out.println("Resolution: " +
156
Display.getDisplayMode().getWidth() + "x" +
157
Display.getDisplayMode().getHeight() + "x" +
158
Display.getDisplayMode().getBitsPerPixel() + "@" +
159
159
Display.getDisplayMode().getFrequency() + "Hz");
168
168
e.printStackTrace();
170
170
System.out.println("done");
172
System.out.println("---- Test setDisplayMode ----");
172
System.out.println("---- Test setDisplayMode ----");
176
176
* Tests the DisplayConfiguration
178
178
private void setDisplayConfigurationTest() {
179
179
System.out.println("==== Test setDisplayConfigurationTest ====");
181
181
System.out.println("Testing normal setting");
182
182
changeConfig(1.0f, 0f, 1f);
184
184
System.out.println("Testing gamma settings");
185
185
changeConfig(5.0f, 0f, 1f);
186
186
changeConfig(0.5f, 0f, 1f);
188
188
System.out.println("Testing brightness settings");
189
189
changeConfig(1.0f, -1.0f, 1f);
190
190
changeConfig(1.0f, -0.5f, 1f);
191
191
changeConfig(1.0f, 0.5f, 1f);
192
192
changeConfig(1.0f, 1.0f, 1f);
194
194
System.out.println("Testing contrast settings");
195
195
changeConfig(1.0f, 0f, 0f);
196
196
changeConfig(1.0f, 0f, 0.5f);
197
197
changeConfig(1.0f, 0f, 10000.0f);
199
199
System.out.print("resetting...");
201
201
Display.setFullscreen(false);