Unit GraphicsConsole

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo Graphics Console Interface unit

The Graphics console unit provides access to the underlying framebuffer device as a pixel interface that allows putting blocks (or rectangles) of pixel data on to the screen or getting rectangles of pixel data from the screen. Functions are also included to copy a rectangle from one part of the screen to another and to put text (with a specified font) on to the screen.

Most image formats either consist of, or can be decoded to, a block of data that is a number of horizontal rows each with a number of pixels (columns) with each pixel containing color information in a certain bit size (8/16/24/32) and format (RGB/BGR/RGBA etc).

If the data exists in memory as a single contiguous block with each row following directly after the previous row then that can be passed directly to the functions in this unit (eg GraphicsWindowDrawImage) to be drawn on the screen.

Many graphics libraries do image manipulation, rendering and compositing to a memory buffer in a form that is compatible with the functions in this unit so a complex image can be constructed in memory and then transferred to the screen in a single operation. This is sometimes referred to as a bit block transfer or BitBlt and is a very standard technique for rendering both text and images to a framebuffer device.

This unit extends the console unit by creating a new type of console window (WINDOW_MODE_GRAPHICS) and therefore allows both text console windows and graphics console windows to co-exist on the screen at once.

The functions in this unit cannot be used to draw on a text console window (WINDOW_MODE_TEXT) and vice versa the functions in the console unit cannot be used to draw on a graphics console window.

Like the console unit, the graphics console supports setting a viewport for a specified window to allow masking the area to be written to. However the graphics console does not support tracking a cursor X and Y position. Setting a window as the default is also not supported since that functionality is purely intended to support the RTL functions for text output.

Graphics windows can only be created on console devices which have a mode of CONSOLE_MODE_PIXEL.

Notes: Unlike the Console unit, Graphics console coordinates are always based on pixels not characters. Graphics console coordinates begin at 0,0 and extend to Width - 1, Height - 1. Graphics Window coordinates X,Y are always based on pixels, beginning at 0,0 and extending to Cols - 1, Rows - 1.

Constants


None defined

Type definitions



Graphics window enumeration callback

TGraphicsWindowEnumerate = TConsoleWindowEnumerate;

Graphics window types

[Expand]

PGraphicsWindow = ^TGraphicsWindow;

TGraphicsWindow = TConsoleWindow;


Class definitions



Graphics console specific classes

TGraphicImage = class(TObject)


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure GraphicsConsoleInit;
Description: Initialize the GraphicsConsole unit


Graphics console functions

[Expand]
function GraphicsWindowCreate(Console:PConsoleDevice; Position:LongWord):TWindowHandle;
Description: Create a new Graphics window


[Expand]
function GraphicsWindowCreateEx(Console:PConsoleDevice; Font:TFontHandle; Size,State,Mode,Position:LongWord):TWindowHandle;
Description: Create a new Graphics window


[Expand]
function GraphicsWindowDestroy(Handle:TWindowHandle):LongWord; inline;
Description: Close and Destroy an existing console window


[Expand]
function GraphicsWindowShow(Handle:TWindowHandle):LongWord; inline;
Description: Make an existing console window visible and show it on screen


[Expand]
function GraphicsWindowHide(Handle:TWindowHandle):LongWord; inline;
Description: Make an existing console window invisible and hide it on screen


[Expand]
function GraphicsWindowActivate(Handle:TWindowHandle):LongWord; inline;
Description: Make an existing console window the active window


[Expand]
function GraphicsWindowDeactivate(Handle:TWindowHandle):LongWord; inline;
Description: Make an existing console window inactive


[Expand]
function GraphicsWindowNext(Console:PConsoleDevice; Visible:Boolean):TWindowHandle; inline;
Description: Get the next console window starting with the active window


[Expand]
function GraphicsWindowPrevious(Console:PConsoleDevice; Visible:Boolean):TWindowHandle; inline;
Description: Get the previous console window starting with the active window


[Expand]
function GraphicsWindowAt(Console:PConsoleDevice; X,Y:LongWord; Visible:Boolean):TWindowHandle; inline;
Description: Find the console window that X and Y coordinates are within


[Expand]
function GraphicsWindowFind(Console:PConsoleDevice; Position:LongWord):TWindowHandle; inline;
Description: Find an existing console window in the position specified


[Expand]
function GraphicsWindowEnumerate(Console:PConsoleDevice; Callback:TGraphicsWindowEnumerate; Data:Pointer):LongWord; inline;
Description: Enumerate existing console windows on the specified console device


[Expand]
function GraphicsWindowCheckFlag(Handle:TWindowHandle; Flag:LongWord):Boolean; inline;
Description: Check an existing console window to determine if a flag is set or not


[Expand]
function GraphicsWindowUpdateFlag(Handle:TWindowHandle; Flag:LongWord; Clear:Boolean):LongWord; inline;
Description: Set or clear a flag on an existing console window


[Expand]
function GraphicsWindowGetMode(Handle:TWindowHandle):LongWord; inline;
Description: Get the window mode of an existing console window


[Expand]
function GraphicsWindowGetState(Handle:TWindowHandle):LongWord; inline;
Description: Get the window state of an existing console window


[Expand]
function GraphicsWindowGetPosition(Handle:TWindowHandle):LongWord; inline;
Description: Get the position of an existing console window


[Expand]
function GraphicsWindowSetPosition(Handle:TWindowHandle; Position:LongWord):LongWord;
Description: Set the position of an existing console window


[Expand]
function GraphicsWindowGetProperties(Handle:TWindowHandle; Properties:PWindowProperties):LongWord; inline;
Description: Get the properties for the specified console window


[Expand]
function GraphicsWindowGetMinX(Handle:TWindowHandle):LongWord;
Description: Get the current minimum X of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetMinY(Handle:TWindowHandle):LongWord;
Description: Get the current minimum Y of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetMaxX(Handle:TWindowHandle):LongWord;
Description: Get the current maximum X of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetMaxY(Handle:TWindowHandle):LongWord;
Description: Get the current maximum Y of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetRect(Handle:TWindowHandle):TConsoleRect; inline;
Description: Get the rectangle X1,Y1,X2,Y2 of the window viewport for an existing console window


[Expand]
function GraphicsWindowSetRect(Handle:TWindowHandle; const ARect:TConsoleRect):LongWord; inline;
Description: Set the rectangle X1,Y1,X2,Y2 of the window viewport for an existing console window


[Expand]
function GraphicsWindowResetRect(Handle:TWindowHandle):LongWord; inline;
Description: Reset the window viewport for an existing console window to the maximum size


[Expand]
function GraphicsWindowGetViewport(Handle:TWindowHandle; var X1,Y1,X2,Y2:LongWord):LongWord;
Description: Get the X1,Y1,X2,Y2 of the window viewport for an existing console window


[Expand]
function GraphicsWindowSetViewport(Handle:TWindowHandle; X1,Y1,X2,Y2:LongWord):LongWord;
Description: Set the X1,Y1,X2,Y2 of the window viewport for an existing console window


[Expand]
function GraphicsWindowResetViewport(Handle:TWindowHandle):LongWord;
Description: Reset the window viewport for an existing console window to the maximum size


[Expand]
function GraphicsWindowGetCols(Handle:TWindowHandle):LongWord;
Description: Get the current columns of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetRows(Handle:TWindowHandle):LongWord;
Description: Get the current rows of the window viewport for an existing console window


[Expand]
function GraphicsWindowGetWidth(Handle:TWindowHandle):LongWord;
Description: Get the absolute width of an existing console window


[Expand]
function GraphicsWindowGetHeight(Handle:TWindowHandle):LongWord;
Description: Get the absolute height of an existing console window


[Expand]
function GraphicsWindowGetFormat(Handle:TWindowHandle):LongWord;
Description: Get the color format of an existing console window


[Expand]
function GraphicsWindowGetForecolor(Handle:TWindowHandle):LongWord;
Description: Get the current foreground color of an existing console window


[Expand]
function GraphicsWindowSetForecolor(Handle:TWindowHandle; Color:LongWord):LongWord;
Description: Set the current foreground color of an existing console window


[Expand]
function GraphicsWindowGetBackcolor(Handle:TWindowHandle):LongWord;
Description: Get the current background color of an existing console window


[Expand]
function GraphicsWindowSetBackcolor(Handle:TWindowHandle; Color:LongWord):LongWord;
Description: Set the current background color of an existing console window


[Expand]
function GraphicsWindowGetFont(Handle:TWindowHandle):TFontHandle;
Description: Get the default font of an existing console window


[Expand]
function GraphicsWindowSetFont(Handle:TWindowHandle; Font:TFontHandle):LongWord;
Description: Set the default font of an existing console window


[Expand]
function GraphicsWindowGetCursorXY(Handle:TWindowHandle; var X,Y:LongWord):LongWord; inline;
Description: Get the current cursor X and Y positions of an existing console window


[Expand]
function GraphicsWindowSetCursorXY(Handle:TWindowHandle; X,Y:LongWord):LongWord;
Description: Set the current cursor X and Y positions of an existing console window


[Expand]
function GraphicsWindowGetCursorMode(Handle:TWindowHandle):TCursorMode; inline;
Description: Get the current cursor mode of an existing console window


[Expand]
function GraphicsWindowSetCursorMode(Handle:TWindowHandle; CursorMode:TCursorMode):LongWord; inline;
Description: Set the current cursor mode of an existing console window


[Expand]
function GraphicsWindowGetCursorBlink(Handle:TWindowHandle):Boolean; inline;
Description: Get the current cursor blink state of an existing console window


[Expand]
function GraphicsWindowSetCursorBlink(Handle:TWindowHandle; CursorBlink:Boolean):LongWord; inline;
Description: Set the current cursor blink state of an existing console window


[Expand]
function GraphicsWindowGetCursorState(Handle:TWindowHandle):TCursorState; inline;
Description: Get the current cursor state of an existing console window


[Expand]
function GraphicsWindowSetCursorState(Handle:TWindowHandle; CursorState:TCursorState):LongWord; inline;
Description: Set the current cursor state of an existing console window


[Expand]
function GraphicsWindowGetCursorShape(Handle:TWindowHandle):TCursorShape; inline;
Description: Get the current cursor shape of an existing console window


[Expand]
function GraphicsWindowSetCursorShape(Handle:TWindowHandle; CursorShape:TCursorShape):LongWord; inline;
Description: Set the current cursor shape of an existing console window


[Expand]
function GraphicsWindowCursorOn(Handle:TWindowHandle):LongWord; inline;
Description: Enable the cursor on an existing console window


[Expand]
function GraphicsWindowCursorOff(Handle:TWindowHandle):LongWord; inline;
Description: Disable the cursor on an existing console window


[Expand]
function GraphicsWindowCursorLine(Handle:TWindowHandle):LongWord; inline;
Description: Change the cursor to a vertical line on an existing console window


[Expand]
function GraphicsWindowCursorBar(Handle:TWindowHandle):LongWord; inline;
Description: Change the cursor to a horizontal bar on an existing console window


[Expand]
function GraphicsWindowCursorBlock(Handle:TWindowHandle):LongWord; inline;
Description: Change the cursor to a solid block on an existing console window


[Expand]
function GraphicsWindowCursorMove(Handle:TWindowHandle; X,Y:LongWord):LongWord;
Description: Move the cursor on an existing console window


[Expand]
function GraphicsWindowCursorBlink(Handle:TWindowHandle; Enabled:Boolean):LongWord; inline;
Description: Set the blink state of the cursor on an existing console window


[Expand]
function GraphicsWindowClear(Handle:TWindowHandle):LongWord;
Description: Clear the current viewport of an existing console window


[Expand]
function GraphicsWindowClearEx(Handle:TWindowHandle; X1,Y1,X2,Y2,Color:LongWord):LongWord;
Description: Clear part of the the current viewport of an existing console window


[Expand]
function GraphicsWindowDrawBox(Handle:TWindowHandle; X1,Y1,X2,Y2,Color,Width:LongWord):LongWord;
Description: Draw a rectangular box outline on an existing console window


[Expand]
function GraphicsWindowDrawLine(Handle:TWindowHandle; X1,Y1,X2,Y2,Color,Width:LongWord):LongWord;
Description: Draw a line on an existing console window


[Expand]
function GraphicsWindowDrawBlock(Handle:TWindowHandle; X1,Y1,X2,Y2,Color:LongWord):LongWord;
Description: Draw a rectangular filled block on an existing console window


[Expand]
function GraphicsWindowDrawCircle(Handle:TWindowHandle; X,Y,Color,Width,Radius:LongWord):LongWord;
Description: Draw a circle on an existing console window


[Expand]
function GraphicsWindowDrawChar(Handle:TWindowHandle; Ch:Char; X,Y:LongWord):LongWord;
Description: Draw a character on an existing console window


[Expand]
function GraphicsWindowDrawCharEx(Handle:TWindowHandle; Font:TFontHandle; Ch:Char; X,Y,Forecolor,Backcolor:LongWord):LongWord;
Description: Draw a character on an existing console window


[Expand]
function GraphicsWindowDrawText(Handle:TWindowHandle; const Text:String; X,Y:LongWord):LongWord;
Description: Draw a text string on an existing console window


[Expand]
function GraphicsWindowDrawTextEx(Handle:TWindowHandle; Font:TFontHandle; const Text:String; X,Y,Forecolor,Backcolor:LongWord):LongWord;
Description: Draw a text string on an existing console window


[Expand]
function GraphicsWindowDrawPixel(Handle:TWindowHandle; X,Y,Color:LongWord):LongWord;
Description: Draw a single pixel on an existing console window


[Expand]
function GraphicsWindowDrawImage(Handle:TWindowHandle; X,Y:LongWord; Image:Pointer; Width,Height,Format:LongWord):LongWord;
Description: Draw an image on an existing console window


[Expand]
function GraphicsWindowGetPixel(Handle:TWindowHandle; X,Y:LongWord):LongWord;
Description: Get a single pixel from an existing console window


[Expand]
function GraphicsWindowGetImage(Handle:TWindowHandle; X,Y:LongWord; Image:Pointer; Width,Height,Format:LongWord):LongWord;
Description: Get an image from an existing console window


[Expand]
function GraphicsWindowCopyImage(Handle:TWindowHandle; const Source,Dest:TConsolePoint; Width,Height:LongWord):LongWord; inline;
Description: Copy an image from one place to another in an existing console window


[Expand]
function GraphicsWindowMoveImage(Handle:TWindowHandle; const Source,Dest:TConsolePoint; Width,Height,Fillcolor:LongWord):LongWord;
Description: Move an image from one place to another in an existing console window


[Expand]
function GraphicsWindowImageSize(Handle:TWindowHandle; Width,Height,Format,Stride:LongWord):LongWord;
Description: Calculate the size in bytes of an image that is Width by Height in the color format specified


[Expand]
function GraphicsWindowImageFromStream(Handle:TWindowHandle; X,Y:LongWord; Stream:TStream; Width,Height,Format,Stride:LongWord; Invert:Boolean):LongWord;
Description: Draw an image to an existing console window from a supplied stream


[Expand]
function GraphicsWindowImageToStream(Handle:TWindowHandle; X,Y:LongWord; Stream:TStream; Width,Height,Format,Stride:LongWord; Invert:Boolean):LongWord;
Description: Get an image from an existing console window to a supplied stream


Graphics console helper functions

[Expand]
function GraphicsWindowGetCount(Console:PConsoleDevice):LongWord; inline;
Description: Get the current console window count


[Expand]
function GraphicsWindowGetActive(Console:PConsoleDevice):TWindowHandle; inline;
Description: Get the current console active window


[Expand]
function GraphicsWindowCheck(Console:PConsoleDevice; Window:PGraphicsWindow):PGraphicsWindow; inline;
Description: Check if a console window entry is valid


Return to Unit Reference