1 /*
2  * Copyright (c) 2002-2008 LWJGL Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of 'LWJGL' nor the names of
17  *   its contributors may be used to endorse or promote products derived
18  *   from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
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
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 package org.lwjgl.opengl;
33 
34 /**
35  * This is the Display implementation interface. Display delegates
36  * to implementors of this interface. There is one DisplayImplementation
37  * for each supported platform.
38  * @author elias_naur
39  */
40 
41 import java.nio.ByteBuffer;
42 import java.nio.FloatBuffer;
43 import java.nio.IntBuffer;
44 import java.awt.Canvas;
45 
46 import org.lwjgl.LWJGLException;
47 
48 interface DisplayImplementation extends InputImplementation {
49 
createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y)50 	void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException;
51 
destroyWindow()52 	void destroyWindow();
53 
switchDisplayMode(DisplayMode mode)54 	void switchDisplayMode(DisplayMode mode) throws LWJGLException;
55 
56 	/**
57 	 * Reset the display mode to whatever it was when LWJGL was initialized.
58 	 * Fails silently.
59 	 */
resetDisplayMode()60 	void resetDisplayMode();
61 
62 	/**
63 	 * Return the length of the gamma ramp arrays. Returns 0 if gamma settings are
64 	 * unsupported.
65 	 *
66 	 * @return the length of each gamma ramp array, or 0 if gamma settings are unsupported.
67 	 */
getGammaRampLength()68 	int getGammaRampLength();
69 
70 	/**
71 	 * Method to set the gamma ramp.
72 	 */
setGammaRamp(FloatBuffer gammaRamp)73 	void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
74 
75 	/**
76 	 * Get the driver adapter string. This is a unique string describing the actual card's hardware, eg. "Geforce2", "PS2",
77 	 * "Radeon9700". If the adapter cannot be determined, this function returns null.
78 	 * @return a String
79 	 */
getAdapter()80 	String getAdapter();
81 
82 	/**
83 	 * Get the driver version. This is a vendor/adapter specific version string. If the version cannot be determined,
84 	 * this function returns null.
85 	 * @return a String
86 	 */
getVersion()87 	String getVersion();
88 
89 	/**
90 	 * Initialize and return the current display mode.
91 	 */
init()92 	DisplayMode init() throws LWJGLException;
93 
94 	/**
95 	 * Implementation of setTitle(). This will read the window's title member
96 	 * and stash it in the native title of the window.
97 	 */
setTitle(String title)98 	void setTitle(String title);
99 
isCloseRequested()100 	boolean isCloseRequested();
101 
isVisible()102 	boolean isVisible();
isActive()103 	boolean isActive();
104 
isDirty()105 	boolean isDirty();
106 
107 	/**
108 	 * Create the native PeerInfo.
109 	 * @throws LWJGLException
110 	 */
createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs)111 	PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException;
112 
113 //	void destroyPeerInfo();
114 
115 	/**
116 	 * Updates the windows internal state. This must be called at least once per video frame
117 	 * to handle window close requests, moves, paints, etc.
118 	 */
update()119 	void update();
120 
reshape(int x, int y, int width, int height)121 	void reshape(int x, int y, int width, int height);
122 
123 	/**
124 	 * Method for getting displaymodes
125 	 */
getAvailableDisplayModes()126 	DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
127 
128 	/* Pbuffer */
getPbufferCapabilities()129 	int getPbufferCapabilities();
130 
131 	/**
132 	 * Method to test for buffer integrity
133 	 */
isBufferLost(PeerInfo handle)134 	boolean isBufferLost(PeerInfo handle);
135 
136 	/**
137 	 * Method to create a Pbuffer
138 	 */
createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs, IntBuffer pixelFormatCaps, IntBuffer pBufferAttribs)139 	PeerInfo createPbuffer(int width, int height, PixelFormat pixel_format, ContextAttribs attribs,
140 			IntBuffer pixelFormatCaps,
141 			IntBuffer pBufferAttribs) throws LWJGLException;
142 
setPbufferAttrib(PeerInfo handle, int attrib, int value)143 	void setPbufferAttrib(PeerInfo handle, int attrib, int value);
144 
bindTexImageToPbuffer(PeerInfo handle, int buffer)145 	void bindTexImageToPbuffer(PeerInfo handle, int buffer);
146 
releaseTexImageFromPbuffer(PeerInfo handle, int buffer)147 	void releaseTexImageFromPbuffer(PeerInfo handle, int buffer);
148 
149 	/**
150 	 * Sets one or more icons for the Display.
151 	 * <ul>
152 	 * <li>On Windows you should supply at least one 16x16 icon and one 32x32.</li>
153 	 * <li>Linux (and similar platforms) expect one 32x32 icon.</li>
154 	 * <li>Mac OS X should be supplied one 128x128 icon</li>
155 	 * </ul>
156 	 * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
157 	 *
158 	 * @param icons Array of icons in RGBA mode
159 	 * @return number of icons used.
160 	 */
setIcon(ByteBuffer[] icons)161 	int setIcon(ByteBuffer[] icons);
162 
163 	/**
164 	 * Enable or disable the Display window to be resized.
165 	 *
166 	 * @param resizable set to true to make the Display window resizable;
167 	 * false to disable resizing on the Display window.
168 	 */
setResizable(boolean resizable)169 	void setResizable(boolean resizable);
170 
171 	/**
172 	 * @return true if the Display window has been resized since this method was last called.
173 	 */
wasResized()174 	boolean wasResized();
175 
176 	/**
177 	 * @return this method will return the width of the Display window.
178 	 */
getWidth()179 	int getWidth();
180 
181 	/**
182 	 * @return this method will return the height of the Display window.
183 	 */
getHeight()184 	int getHeight();
185 
186 	/**
187 	 * @return this method will return the top-left x position of the Display window.
188 	 */
getX()189 	int getX();
190 
191 	/**
192 	 * @return this method will return the top-left y position of the Display window.
193 	 */
getY()194 	int getY();
195 
196 	/**
197 	 * @return this method will return the pixel scale factor of the Display window useful for high resolution modes.
198 	 */
getPixelScaleFactor()199 	float getPixelScaleFactor();
200 }
201