yage.system.window
Authors:
Eric Poggel
License:
LGPL v3
- class
Window
: yage.core.object2.IRenderTarget;
- This class is for creating and managing the
Window
that Yage uses for rendering.
Due to the same limitation in SDL, Yage only supports one
Window
at a time.
Example:
System.init(); // required
auto window = Window.getInstance();
window.setResolution(640, 480); // window is created/recreated here
- int
getWidth
();
int
getHeight
();
- Get the width/height of this Window's display area (not including title/borders) in pixels.
- Vec!(2,int)
getViewportPosition
();
- Vec!(2,int)
getViewportSize
();
- void
minimize
();
- Minimize the Window.
- void
setCaption
(char[] title, char[] taskbarName = null);
- Set the caption for the Window.
Params:
char[] title |
The caption shown on top of the window |
char[] taskbarName |
The caption shown on the window's taskbar entry. Defaults to title. |
- void
setResolution
(int width, int height, ubyte depth = cast(ubyte)0, bool fullscreen = false, ubyte samples = cast(ubyte)1);
- Create (or recreate) the window singleton at this resolution.
Unfortunately this resets the OpenGL context on Windows, which currently causes a crash on subsequent calls.
Params:
int width |
Width of the window in pixels |
int height |
Height of the window in pixels |
ubyte depth |
Color depth of each pixel. Should be 16, 24, 32, or 0 for auto. |
bool fullscreen |
The window is fullscreen if true
; windowed otherwise. |
ubyte samples |
The number of samples to use for anti-aliasing (1 for no aa). |
- void
setViewport
(Vec!(2,int) topLeft = opCall(0), Vec!(2,int) widthHeight = opCall(0));
- Set the viewport position and size
Params:
Vec!(2,int) topLeft |
Top left coordinates of the viewport in pixels. |
Vec!(2,int) widthHeight |
Width and height of the viewport in pixels. If zero, defaults to window width/height. |
- void
resizeWindow
(int width, int height);
- Stores the dimensions of the current window size.
This is called by a resize event in Input.checkInput().
- ImageBase
toImage
(Buffer buffer = cast(Buffer)0);
- Get an image from the Window's back-buffer (where image operations take place).
Params:
Buffer buffer |
Can be COLOR, DEPTH, or STENCIL to get the corresponding buffer. |
Returns:
Image1ub for the stencil buffer, Image1ui for the depth buffer, or Image3ub for the color buffer.
Example:
IImage image = Window.getInstance().toImage(Window.Buffer.DEPTH);
ubyte[] data = image.convert!(ubyte, 1).getBytes(); // convert image from 32-bit grayscale to 8-bit grayscale
File file = new File("depth.raw", File.WriteCreate); // Photoshop can open raw files
file.write(image.convert!(ubyte, 1).getBytes());
file.close();
- static Window
getInstance
();
- Returns:
The singleton Window instance.
- class
Window2
;
- This class is the unimplemented successor to Window.
It will use native system calls instead of SDL.
All windows should share the same OpenGL context, created and destroyed in System.init/deInit, or perhaps created lazily?
|