|
CDM
v0.9
Console Draw Motor, C librarly for quickly developing Windows console applications with advanced graphics. https://github.com/komo97/CDM
|
This file contains every definition, structure and function needed to use CDM. More...
Data Structures | |
| struct | CDMTiles |
| A structure that contains raw data for the console to process, most structures used in CDM require this component. More... | |
| struct | CDMEvent |
| A structure containing the events required to check input inside CDM. More... | |
| struct | CDMContext |
| A context in which CDM will run. It contains the handle for the console window, color information buffers, character buffers, the size of the window inside it's rect and an event structure to get key events. More... | |
| struct | CDMPixelData |
| The data of a single pixel. More... | |
| struct | CDMPalette |
| A palette for a CDMSurface. It contains the four types of pixel that the surface is able to be used. More... | |
| struct | CDMSurface |
| A representation of an image that is able to be interpreted by CDM. More... | |
| struct | CDMText |
| A representation of a text object able to be interpreted by CDM. More... | |
| struct | CDMColorScheme |
| This structure serves the purpose of a color palette. You can select which palette is active and displaying at any time using CDMSetActiveScheme. The default values for colors are this, in binary. 0x00362b00 Black 0x00423607 Gray 0x00756e58 Green 0x00837b65 Yellow 0x00969483 Blue 0x00a1a193 Aqua 0x00d5e8ee White 0x00e3f6fd BrightWhite 0x000089b5 BrightYellow 0x00164bcb Red 0x002f32dc LightRed 0x008236d3 LightPurple 0x00c4716c Purple 0x00d28b26 LightBlue 0x0098a12a LightAqua 0x00009985 LightGreen . More... | |
Macros | |
| #define | _IN_ |
| Describes a parameter that will only be used for data input and is required. More... | |
| #define | _OUT_ |
| Describes a parameter that will only be used for data output and is required. More... | |
| #define | _INOUT_ |
| Describes a parameter that will be used for data input and output and is required. More... | |
| #define | _INOPT_ |
| Describes a parameter that will only be used for data input and is not required. More... | |
| #define | _OUTOPT_ |
| Describes a parameter that will only be used for data output and is not required. More... | |
| #define | _INOUTOPT_ |
| Describes a parameter that will be used for data input and output and is not required. More... | |
Typedefs | |
| typedef SMALL_RECT | CDMRect |
| Defines an alias representing the CDM rectangle, contains a left, right, top and bottom properties. More... | |
| typedef COORD | CDMCoord |
| Defines an alias representing the CDM coordinate, contains an X and a Y property. More... | |
| typedef char | CDMEnum |
| Defines an alias representing the CDM enum, this type is completely symbolic and describes a parameter that requires to be filled with an enumeration. More... | |
| typedef unsigned char | CDMErrno |
| Defines an alias representing the CDM error number, a simple type for checking errors inside the API. More... | |
Enumerations | |
| enum | CDMLetterColor { CLEAR = -1, BLACK = 0, DARKBLUE = FOREGROUND_BLUE, DARKGREEN = FOREGROUND_GREEN, DARKCYAN = FOREGROUND_GREEN | FOREGROUND_BLUE, DARKRED = FOREGROUND_RED, DARKMAGENTA = FOREGROUND_RED | FOREGROUND_BLUE, DARKYELLOW = FOREGROUND_RED | FOREGROUND_GREEN, DARKGRAY = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, GRAY = FOREGROUND_INTENSITY, BLUE = FOREGROUND_INTENSITY | FOREGROUND_BLUE, GREEN = FOREGROUND_INTENSITY | FOREGROUND_GREEN, CYAN = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, RED = FOREGROUND_INTENSITY | FOREGROUND_RED, MAGENTA = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, YELLOW = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN, WHITE = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, LCOLOR1 = BLACK, LCOLOR2 = DARKBLUE, LCOLOR3 = DARKGREEN, LCOLOR4 = DARKCYAN, LCOLOR5 = DARKRED, LCOLOR6 = DARKMAGENTA, LCOLOR7 = DARKYELLOW, LCOLOR8 = DARKGRAY, LCOLOR9 = GRAY, LCOLOR10 = GREEN, LCOLOR11 = CYAN, LCOLOR12 = RED, LCOLOR13 = MAGENTA, LCOLOR14 = YELLOW, LCOLOR15 = WHITE } |
| Describes a parameter that will be used for data input and output and it maps all the possible colors for the letters that can be used inside CDM. More... | |
| enum | CDMBackgroundColor { BCLEAR = -1, BBLACK = 0, BDARKBLUE = BACKGROUND_BLUE, BDARKGREEN = BACKGROUND_GREEN, BDARKCYAN = BACKGROUND_GREEN | BACKGROUND_BLUE, BDARKRED = BACKGROUND_RED, BDARKMAGENTA = BACKGROUND_RED | BACKGROUND_BLUE, BDARKYELLOW = BACKGROUND_RED | BACKGROUND_GREEN, BDARKGRAY = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, BGRAY = BACKGROUND_INTENSITY, BBLUE = BACKGROUND_INTENSITY | BACKGROUND_BLUE, BGREEN = BACKGROUND_INTENSITY | BACKGROUND_GREEN, BCYAN = BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE, BRED = BACKGROUND_INTENSITY | BACKGROUND_RED, BMAGENTA = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE, BYELLOW = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN, BWHITE = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, BCOLOR1 = BBLACK, BCOLOR2 = BDARKBLUE, BCOLOR3 = BDARKGREEN, BCOLOR4 = BDARKCYAN, BCOLOR5 = BDARKRED, BCOLOR6 = BDARKMAGENTA, BCOLOR7 = BDARKYELLOW, BCOLOR8 = BDARKGRAY, BCOLOR9 = BGRAY, BCOLOR10 = BGREEN, BCOLOR11 = BCYAN, BCOLOR12 = BRED, BCOLOR13 = BMAGENTA, BCOLOR14 = BYELLOW, BCOLOR15 = BWHITE } |
| Describes a parameter that will be used for data input and output and it maps all the possible colors for the letters that can be used inside CDM. More... | |
| enum | CDMExtraOptions { reverseColors = COMMON_LVB_REVERSE_VIDEO, underscore = COMMON_LVB_UNDERSCORE, Alpha = 100 } |
| Values that represent extra options for coloring letters and backgrounds. Exclusive for advanced usage. More... | |
| enum | CDMColorSets { Set1 = 0x0001, Set2 = 0x0002, Set3 = 0x0004, Set4 = 0x0008, SetAlpha = 0x0010 } |
| Values that represent the color sets to be used inside CDMSetPixel. Each one represents one combination of a background color, a letter color and a character. More... | |
| enum | CDMBool { CDMFalse = 0, CDMTrue = 1 } |
| Boolean implementation. More... | |
| enum | CDMKey { mbleft = VK_LBUTTON, mbright = VK_RBUTTON, backspace = VK_BACK, tab = VK_TAB, clear = VK_CLEAR, returnK = VK_RETURN, shift = VK_SHIFT, ctrl = VK_CONTROL, alt = VK_MENU, pause = VK_PAUSE, caps = VK_CAPITAL, esc = VK_ESCAPE, space = VK_SPACE, pgup = VK_PRIOR, pgdown = VK_NEXT, end = VK_END, left = VK_LEFT, right = VK_RIGHT, up = VK_UP, down = VK_DOWN, print = VK_PRINT, insert = VK_INSERT, del = VK_DELETE, zero = 0x30, one = 0x31, two = 0x32, three = 0x33, four = 0x34, five = 0x35, six = 0x36, seven = 0x37, eight = 0x38, nine = 0x39, A = 0x41, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, add = 0x6B, separator, substract, decimal, divide, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, lshift = 0xA0, rshift, lctrl, rctrl, lalt, ralt, KeysEnd } |
| Values that represent all possible inputs inside CDM. More... | |
| enum | CDMMode { mode3d, mode2d } |
| Values that represent the rendering mode of CDM, not to be used right now. More... | |
Functions | |
| CDMContext * | CDMCreateContext (const _IN_ short width, const _IN_ short height) |
| The setup function of CDM. Must be called before anything else. CDM requires a context to work, most of the functions here require a context to be used. Status: Working. More... | |
| void | CDMChangeWindowSize (_INOUT_ CDMContext **ctx, const _IN_ short width, const _IN_ short height) |
| Changes the window size of a context. May be called at any time, however it will clear the screen once its done. Status: Working. More... | |
| void | CDMToggleFullscreen (CDMContext **_INOUT_ ctx, const _IN_ CDMBool val) |
| Toggles full screen mode. Status: May be working on older platforms. More... | |
| void | CDMSetWindowTitle (const _IN_ wchar_t *title) |
| Sets the title of the console. Just a wrapper for a WINAPI functionality. Status: Working. More... | |
| void | CDMSetFontAndSize (_INOUT_ CDMContext **ctx, const _IN_ wchar_t *fontName, const _IN_ short width, const _IN_ short height) |
| Sets the font and font size of the console. The recommended font name is L"Terminal" for its unique characteristic of allowing square pixels, however most fonts can be used. It's important to include L at the start of your string, since this function requires a wchar_t* instead of a regular char. Status: Working. More... | |
| void | CDMSetCursorVisibility (_INOUT_ CDMContext **ctx, const _IN_ CDMBool status) |
| Sets the visibility of the console's cursor. Status: Working. More... | |
| void | CDMActivateMouseInput (_INOUT_ CDMContext **ctx) |
| Activates mouse input recognition for the console. Status: Working. More... | |
| CDMSurface * | CDMCreateSurface (const _IN_ short posX, const _IN_ short posY, const _IN_ short sizeX, const _IN_ short sizeY) |
| Creates a surface. A surface is the base representation of an image in CDM Most every object used in CDM will most likely be a surface. Status: Working. More... | |
| CDMSurface * | CDMReadImg (const _IN_ char *fileName, _OUTOPT_ CDMColorScheme *scheme) |
| Reads a .cdi image file into a CDMSurface. The file must be generated exactly the same as CDMExportSrfcToImg, for it to work using this function. The usage of the structure may be imperative. Status: Working. More... | |
| void | CDMExportSrfcToImg (const _IN_ CDMContext *ctx, const _IN_ CDMSurface *srfc, const _IN_ char *fileName, const _IN_ size_t nameSize) |
| Exports a surface to a .cdi image. Status: Working. More... | |
| CDMText * | CDMTextWrapper (_IN_ wchar_t *text, const _IN_ CDMLetterColor color, const _IN_ CDMBackgroundColor background) |
| Since CDM basically hijacks the console, functions like printf are not enabled. No output will be shown using them, instead you must use the text as an object, this means you have much more control of the position and design of your text, at the expense of making a little bit harder to use. Moreover, repeated uses of the same text box will not require you to create a new object or call anything else other than adding this object to the context, or drawing it directly. All text begins in the ( 0 , 0 ) coordinate. Status: Working. More... | |
| CDMText * | CDMTextWrapper_s (_IN_ wchar_t *text, const _IN_ size_t textSize, const _IN_ CDMLetterColor color, const _IN_ CDMBackgroundColor background) |
| Since CDM basically hijacks the console, functions like printf are disabled. No output will be shown using them, instead you must use the text as an object, this means you have much more control of the position and design of your text, at the expense of making a little bit harder to use. Moreover, repeated uses of the same text box will not require you to create a new object or call anything else other than adding this object to the context, or drawing it directly. All text begins in the ( 0 , 0 ) coordinate. Status: Working. More... | |
| void | CDMChangeText (CDMText **txt, const _IN_ wchar_t *text) |
| Changes the text content of a CDMText. Status: Working. More... | |
| void | CDMSetForegroundColor (_INOUT_ CDMSurface **surface, const _IN_ CDMLetterColor c1, const _IN_ CDMLetterColor c2, const _IN_ CDMLetterColor c3, const _IN_ CDMLetterColor c4) |
| A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four foreground colors that the Surface will use from the color palette. Status: Working. More... | |
| void | CDMSetBackgroundColor (_INOUT_ CDMSurface **surface, const _IN_ CDMBackgroundColor c1, const _IN_ CDMBackgroundColor c2, const _IN_ CDMBackgroundColor c3, const _IN_ CDMBackgroundColor c4) |
| A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four background colors that the Surface will use from the color palette. Status: Working. More... | |
| void | CDMSetCharacters (_INOUT_ CDMSurface **surface, const _IN_ wchar_t c1, const _IN_ wchar_t c2, const _IN_ wchar_t c3, const _IN_ wchar_t c4) |
| A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four characters that the Surface will use. Status: Working. More... | |
| void | CDMFreeSurface (_INOUT_ CDMSurface **surface) |
| Simple dynamic memory allocation free method. Status: Working. More... | |
| void | CDMFreeText (_INOUT_ CDMText **txt) |
| Simple dynamic memory allocation free method. Status: Working. More... | |
| void | CDMFreeContext (_INOUT_ CDMContext **ctx) |
| Simple dynamic memory allocation free method. Status: Working. More... | |
| void | CDMPrepareSurface (_INOUT_ CDMSurface **surface) |
| This should only be called each time the surface's contents were modified before calling a draw or add function. Internally this function converts the image's values to raw data that the console understands. Status: Working. More... | |
| void | CDMPrepareText (_INOUT_ CDMText **txt) |
| This should only be called each time the text's contents were modified before calling a draw or add function. Internally this function converts the text's values to raw data that the console understands. Status: Working. More... | |
| void | CDMDrawSurface (_INOUT_ CDMContext **ctx, _IN_ CDMSurface *surface) |
| Draws directly a surface in the context, instead of batching it with other draws. I highly recommend using the batch function (Add, then CDMDraw) over this one, to make the program run faster. Status: Partially works. More... | |
| void | CDMAddSurfaceToContext (_INOUT_ CDMContext **ctx, _IN_ CDMSurface *surface) |
| Adds a surface to the context, and thus batching its draw with every other added object, the batch will be completely flushed once CDMDraw is called. Status: Working. More... | |
| void | CDMDrawText (_INOUT_ CDMContext **ctx, _IN_ CDMText *txt) |
| Draws directly a text in the context, instead of batching it with other draws. I highly recommend using the batch function (Add, then CDMDraw) over this one, to make the program run faster. Status: Partially Works. More... | |
| void | CDMAddTextToContext (_INOUT_ CDMContext **ctx, _IN_ CDMText *txt) |
| Adds a text to the context, and thus batching its draw with every other added object, the batch will be completely flushed once CDMDraw is called. Status: Working. More... | |
| void | CDMSetColorRGB (_INOUT_ CDMColorScheme *data, _IN_ short position, _IN_ short r, _IN_ short g, _IN_ short b) |
| Sets an RGB color inside a ColorScheme. Every color goes from 0 to 255, however every value passes through a modulo operation to assure no weird behavior will happen. Status: Working. More... | |
| void | CDMSetColorBin (_INOUT_ CDMColorScheme *data, _IN_ short position, const _IN_ DWORD color) |
| Sets an RGB color inside a ColorScheme. This function accepts an already converted to binary RGB color. You may use Windows.h macro RGB(r,g,b) to get the data. Status: Working. More... | |
| void | CDMClearScreen (_INOUT_ CDMContext **ctx) |
| Clears the current buffer. It does not make the whole screen black. For that you may use CDMFillScreen.This function is implemented like this to reduce overhead on the program by reducing assignations and comparisons. Status: Working. More... | |
| void | CDMFillScreen (_INOUT_ CDMContext **ctx, const _IN_ wchar_t character, const _IN_ CDMLetterColor frontColor, const _IN_ CDMBackgroundColor backColor) |
| Fills the context with a single color. Ignores drawn flags completely. Status: Working. More... | |
| void | CDMPoke (_INOUT_ CDMContext **ctx, const _IN_ CDMCoord coord, const _IN_ wchar_t character, const _IN_ CDMLetterColor frontColor, const _IN_ CDMBackgroundColor backColor) |
| Pokes a pixel in the screen to a certain color. Ignores drawn flags. Status: Working. More... | |
| void | CDMDraw (_IN_ CDMContext **ctx) |
| Draws the whole screen. Does a batch draw if things have been added to the context. Status: Working. More... | |
| int | CDMGetR (_IN_ CDMColorScheme *data, const _IN_ short position) |
| Gets the red color of a certain color inside a ColorScheme. Status: Working. More... | |
| int | CDMGetG (_IN_ CDMColorScheme *data, const _IN_ short position) |
| Gets the green color of a certain color inside a ColorScheme. Status: Working. More... | |
| int | CDMGetB (_IN_ CDMColorScheme *data, const _IN_ short position) |
| Gets the blue color of a certain color inside a ColorScheme. Status: Working. More... | |
| void | CDMSetActiveScheme (_IN_ CDMColorScheme data, _INOUT_ CDMContext **ctx) |
| Sets a color scheme inside a context, and thus changing every display color of it. This instruction does not require you to draw again for results to be shown, as such its extremely fast. Status: Working. More... | |
| void | CDMSetPixel (_INOUT_ CDMSurface **surface, _IN_ short x, _IN_ short y, _IN_ CDMColorSets pixelSet) |
| Sets a pixel inside a surface. You must select from one of the five possible colors inside the surface. Status: Working. More... | |
| CDMBool | CDMCompareCHARINFO (_IN_ CHAR_INFO rhs, _IN_ CHAR_INFO lhs) |
| Compares two CHAR_INFO structures, it's mainly used inside the API for certain operations. May not prove useful to the graphics programmer. Status: Working. More... | |
| void | CDMPollEvents (_IN_ CDMContext *ctx, _INOUT_ CDMEvent *event) |
| Polls the console events, this function must be used in order to get key and mouse presses, as such it must be called at the beginning of every frame and before every function that requires a CDMEvent. Status: Working. More... | |
| CDMBool | CDMGetKeyPressed (_IN_ CDMEvent *event, const _IN_ CDMKey key) |
| Checks if the key selected in the parameter was pressed. This is the only function that checks for mouse input too. Status: Working. More... | |
| CDMBool | CDMGetKeyDown (_IN_ CDMEvent *event, const _IN_ CDMKey key) |
| Checks if the key selected in the parameter was pressed this frame. Status: Working. More... | |
| CDMBool | CDMGetKeyUp (_IN_ CDMEvent *event, const _IN_ CDMKey key) |
| Checks if the key selected in the parameter stopped being pressed this frame. Status: Working. More... | |
| CDMCoord | CDMGetMousePos (_IN_ CDMEvent *event) |
| Gets the mouse position inside the console window. Status: Working. More... | |
| void | CDMKeepScreenSize (_INOUT_ CDMContext **ctx, _IN_ CDMEvent *event) |
| Keeps the screen size of the program. Might be useful if you want to limit screen resizing. Status: Working. More... | |
| void | CDMPrintf (_INOUT_ CDMContext **ctx, const _IN_ int startingLetter, _IN_ CDMRect initialPos, const _IN_ CDMLetterColor frontColor, const _IN_ CDMBackgroundColor backColor, const _IN_ wchar_t *txt,...) |
| A printf implementation for CDM, made it as a replacement or alternative to the text object. It should be easier to manage, but a more expensive call, so use this for dynamic text only, and use Text objects for static text. More... | |
| void | CDMSetErrno (const _IN_ CDMErrno code) |
| Sets an specific errno to a value. Status: Working. More... | |
| CDMErrno | CDMGetErrno () |
| Gets the value of errno and sets it to zero. Status: Working. More... | |
| char * | CDMGetErrorMessage () |
| Translates an error code to an error message, for a brief description. Status: Working. More... | |
| void | CDMClearErrno () |
| Sets errno back to 0. More... | |
This file contains every definition, structure and function needed to use CDM.
| #define _IN_ |
Describes a parameter that will only be used for data input and is required.
< .
| #define _INOPT_ |
Describes a parameter that will only be used for data input and is not required.
| #define _INOUT_ |
Describes a parameter that will be used for data input and output and is required.
| #define _INOUTOPT_ |
Describes a parameter that will be used for data input and output and is not required.
| #define _OUT_ |
Describes a parameter that will only be used for data output and is required.
| #define _OUTOPT_ |
Describes a parameter that will only be used for data output and is not required.
| COORD CDMCoord |
Defines an alias representing the CDM coordinate, contains an X and a Y property.
| char CDMEnum |
Defines an alias representing the CDM enum, this type is completely symbolic and describes a parameter that requires to be filled with an enumeration.
| unsigned char CDMErrno |
Defines an alias representing the CDM error number, a simple type for checking errors inside the API.
| SMALL_RECT CDMRect |
Defines an alias representing the CDM rectangle, contains a left, right, top and bottom properties.
| enum CDMBackgroundColor |
Describes a parameter that will be used for data input and output and it maps all the possible colors for the letters that can be used inside CDM.
| enum CDMBool |
| enum CDMColorSets |
| enum CDMExtraOptions |
| enum CDMKey |
Values that represent all possible inputs inside CDM.
| enum CDMLetterColor |
Describes a parameter that will be used for data input and output and it maps all the possible colors for the letters that can be used inside CDM.
| enum CDMMode |
| void CDMActivateMouseInput | ( | _INOUT_ CDMContext ** | ctx | ) |
Activates mouse input recognition for the console. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| void CDMAddSurfaceToContext | ( | _INOUT_ CDMContext ** | ctx, |
| _IN_ CDMSurface * | surface | ||
| ) |
Adds a surface to the context, and thus batching its draw with every other added object, the batch will be completely flushed once CDMDraw is called. Status: Working.
| [in,out] | ctx | The context in which the surface will be painted, must not be null. |
| [in,out] | surface | The surface to be printed, must not be null. |
| void CDMAddTextToContext | ( | _INOUT_ CDMContext ** | ctx, |
| _IN_ CDMText * | txt | ||
| ) |
Adds a text to the context, and thus batching its draw with every other added object, the batch will be completely flushed once CDMDraw is called. Status: Working.
| [in,out] | ctx | The context in which the text will be painted, must not be null. |
| [in,out] | txt | The text that will be printed, must not be null. |
Changes the text content of a CDMText. Status: Working.
| [in,out] | txt | The text object, must not be null. |
| [in] | text | The text, null terminated. |
| void CDMChangeWindowSize | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ short | width, | ||
| const _IN_ short | height | ||
| ) |
Changes the window size of a context. May be called at any time, however it will clear the screen once its done. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in] | width | The expected width in CDM pixels. |
| [in] | height | The expected height in CDM pixels. |
| void CDMClearErrno | ( | ) |
Sets errno back to 0.
| void CDMClearScreen | ( | _INOUT_ CDMContext ** | ctx | ) |
Clears the current buffer. It does not make the whole screen black. For that you may use CDMFillScreen.This function is implemented like this to reduce overhead on the program by reducing assignations and comparisons. Status: Working.
| [in,out] | ctx | The context, must not be null. |
Compares two CHAR_INFO structures, it's mainly used inside the API for certain operations. May not prove useful to the graphics programmer. Status: Working.
| [in] | rhs | The right hand side. |
| [in] | lhs | The left hand side. |
| CDMContext * CDMCreateContext | ( | const _IN_ short | width, |
| const _IN_ short | height | ||
| ) |
The setup function of CDM. Must be called before anything else. CDM requires a context to work, most of the functions here require a context to be used. Status: Working.
| [in] | width | The expected width in CDM pixels. |
| [in] | height | The expected height in CDM pixels. |
| CDMSurface * CDMCreateSurface | ( | const _IN_ short | posX, |
| const _IN_ short | posY, | ||
| const _IN_ short | sizeX, | ||
| const _IN_ short | sizeY | ||
| ) |
Creates a surface. A surface is the base representation of an image in CDM Most every object used in CDM will most likely be a surface. Status: Working.
| [in] | posX | The position x coordinate of the surface, using screen coordinates. |
| [in] | posY | The position y coordinate of the surface, using screen coordinates. |
| [in] | sizeX | The width of the surface. |
| [in] | sizeY | The height of the surface. |
| void CDMDraw | ( | _IN_ CDMContext ** | ctx | ) |
Draws the whole screen. Does a batch draw if things have been added to the context. Status: Working.
| [in] | ctx | context, must not be null. |
| void CDMDrawSurface | ( | _INOUT_ CDMContext ** | ctx, |
| _IN_ CDMSurface * | surface | ||
| ) |
Draws directly a surface in the context, instead of batching it with other draws. I highly recommend using the batch function (Add, then CDMDraw) over this one, to make the program run faster. Status: Partially works.
| [in,out] | ctx | The context in which the surface will be painted, must not be null. |
| [in,out] | surface | The surface to be printed, must not be null. |
| void CDMDrawText | ( | _INOUT_ CDMContext ** | ctx, |
| _IN_ CDMText * | txt | ||
| ) |
Draws directly a text in the context, instead of batching it with other draws. I highly recommend using the batch function (Add, then CDMDraw) over this one, to make the program run faster. Status: Partially Works.
| [in,out] | ctx | The context in which the text will be painted, must not be null. |
| [in,out] | txt | The text that will be printed, must not be null. |
| void CDMExportSrfcToImg | ( | const _IN_ CDMContext * | ctx, |
| const _IN_ CDMSurface * | srfc, | ||
| const _IN_ char * | fileName, | ||
| const _IN_ size_t | nameSize | ||
| ) |
Exports a surface to a .cdi image. Status: Working.
| [in] | ctx | The current context, must not be null. |
| [in] | srfc | The surface intended to export, must not be null. |
| [in] | fileName | Filename of the file. |
| [in] | nameSize | Size of the name. |
| void CDMFillScreen | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ wchar_t | character, | ||
| const _IN_ CDMLetterColor | frontColor, | ||
| const _IN_ CDMBackgroundColor | backColor | ||
| ) |
Fills the context with a single color. Ignores drawn flags completely. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in] | character | The character to be printed. |
| [in] | frontColor | The front color. |
| [in] | backColor | The background color. |
| void CDMFreeContext | ( | _INOUT_ CDMContext ** | ctx | ) |
Simple dynamic memory allocation free method. Status: Working.
| [in,out] | ctx | The context, must not be null. Upon finishing, this function makes this parameter's value null. |
| void CDMFreeSurface | ( | _INOUT_ CDMSurface ** | surface | ) |
Simple dynamic memory allocation free method. Status: Working.
| [in,out] | surface | The surface, must not be null. Upon finishing this function makes this parameter's value null. |
Simple dynamic memory allocation free method. Status: Working.
| [in,out] | txt | The text, must not be null. Upon finishing, this function makes this parameter's value null. |
| int CDMGetB | ( | _IN_ CDMColorScheme * | data, |
| const _IN_ short | position | ||
| ) |
Gets the blue color of a certain color inside a ColorScheme. Status: Working.
| [in] | data | The color scheme to check from. |
| [in] | position | The position of the color wanted. |
| CDMErrno CDMGetErrno | ( | ) |
Gets the value of errno and sets it to zero. Status: Working.
| char * CDMGetErrorMessage | ( | ) |
Translates an error code to an error message, for a brief description. Status: Working.
| int CDMGetG | ( | _IN_ CDMColorScheme * | data, |
| const _IN_ short | position | ||
| ) |
Gets the green color of a certain color inside a ColorScheme. Status: Working.
| [in] | data | The color scheme to check from. |
| [in] | position | The position of the color wanted. |
Checks if the key selected in the parameter was pressed this frame. Status: Working.
| [in,out] | event | An event structure, must not be null. |
| [in] | key | The key to be checked. |
Checks if the key selected in the parameter was pressed. This is the only function that checks for mouse input too. Status: Working.
| [in,out] | event | An event structure, must not be null. |
| [in] | key | The key to be checked. |
Checks if the key selected in the parameter stopped being pressed this frame. Status: Working.
| [in,out] | event | An event structure, must not be null. |
| [in] | key | The key to be checked. |
Gets the mouse position inside the console window. Status: Working.
| [in,out] | event | An event structure, must not be null. |
| int CDMGetR | ( | _IN_ CDMColorScheme * | data, |
| const _IN_ short | position | ||
| ) |
Gets the red color of a certain color inside a ColorScheme. Status: Working.
| [in] | data | The color scheme to check from. |
| [in] | position | The position of the color wanted. |
| void CDMKeepScreenSize | ( | _INOUT_ CDMContext ** | ctx, |
| _IN_ CDMEvent * | event | ||
| ) |
Keeps the screen size of the program. Might be useful if you want to limit screen resizing. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in,out] | event | An event structure to check for resize events, must not be null. |
| void CDMPoke | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ CDMCoord | coord, | ||
| const _IN_ wchar_t | character, | ||
| const _IN_ CDMLetterColor | frontColor, | ||
| const _IN_ CDMBackgroundColor | backColor | ||
| ) |
Pokes a pixel in the screen to a certain color. Ignores drawn flags. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in] | coord | The coordinate of the pixel. |
| [in] | character | The character to be printed. |
| [in] | frontColor | The front color. |
| [in] | backColor | The background color. |
| void CDMPollEvents | ( | _IN_ CDMContext * | ctx, |
| _INOUT_ CDMEvent * | event | ||
| ) |
Polls the console events, this function must be used in order to get key and mouse presses, as such it must be called at the beginning of every frame and before every function that requires a CDMEvent. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in,out] | event | An event structure, must not be null. |
| void CDMPrepareSurface | ( | _INOUT_ CDMSurface ** | surface | ) |
This should only be called each time the surface's contents were modified before calling a draw or add function. Internally this function converts the image's values to raw data that the console understands. Status: Working.
| [in,out] | surface | The surface, must not be null. |
This should only be called each time the text's contents were modified before calling a draw or add function. Internally this function converts the text's values to raw data that the console understands. Status: Working.
| [in,out] | txt | The text, must not be null. |
| void CDMPrintf | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ int | startingLetter, | ||
| _IN_ CDMRect | initialPos, | ||
| const _IN_ CDMLetterColor | frontColor, | ||
| const _IN_ CDMBackgroundColor | backColor, | ||
| const _IN_ wchar_t * | txt, | ||
| ... | |||
| ) |
A printf implementation for CDM, made it as a replacement or alternative to the text object. It should be easier to manage, but a more expensive call, so use this for dynamic text only, and use Text objects for static text.
| [in,out] | ctx | The context, must not be null. |
| startingLetter | The letter index to start printing from. | |
| [in] | initialPos | The initial position of the text, it wraps around the initialPos parameter's right and bottom elements. |
| [in] | frontColor | The front color of the text. |
| [in] | backColor | The back color of the text. |
| [in] | txt | The text, modes "%d,%i,%u,%f,%g,%x,%o,%c,%s" are working, the new line character is \n. |
| [in] | ... | Variable arguments providing additional information. |
| CDMSurface * CDMReadImg | ( | const _IN_ char * | fileName, |
| _OUTOPT_ CDMColorScheme * | scheme | ||
| ) |
Reads a .cdi image file into a CDMSurface. The file must be generated exactly the same as CDMExportSrfcToImg, for it to work using this function. The usage of the structure may be imperative. Status: Working.
| [in] | fileName | Filename of the file. |
| [in,out] | scheme | If non-null, the scheme that will obtain the real scheme used in the image. |
| void CDMSetActiveScheme | ( | _IN_ CDMColorScheme | data, |
| _INOUT_ CDMContext ** | ctx | ||
| ) |
Sets a color scheme inside a context, and thus changing every display color of it. This instruction does not require you to draw again for results to be shown, as such its extremely fast. Status: Working.
| [in] | data | The color scheme to be set. |
| [in,out] | ctx | The context to modify, must not be null. |
| void CDMSetBackgroundColor | ( | _INOUT_ CDMSurface ** | surface, |
| const _IN_ CDMBackgroundColor | c1, | ||
| const _IN_ CDMBackgroundColor | c2, | ||
| const _IN_ CDMBackgroundColor | c3, | ||
| const _IN_ CDMBackgroundColor | c4 | ||
| ) |
A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four background colors that the Surface will use from the color palette. Status: Working.
| [in,out] | surface | The surface, must not be null. |
| [in] | c1 | The first CDMEnum using color macros. |
| [in] | c2 | The second CDMEnum using color macros. |
| [in] | c3 | The third CDMEnum using color macros. |
| [in] | c4 | The fourth CDMEnum using color macros. |
| void CDMSetCharacters | ( | _INOUT_ CDMSurface ** | surface, |
| const _IN_ wchar_t | c1, | ||
| const _IN_ wchar_t | c2, | ||
| const _IN_ wchar_t | c3, | ||
| const _IN_ wchar_t | c4 | ||
| ) |
A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four characters that the Surface will use. Status: Working.
| [in,out] | surface | The surface, must not be null. |
| [in] | c1 | The first character to be used. |
| [in] | c2 | The second character to be used. |
| [in] | c3 | The third character to be used. |
| [in] | c4 | The fourth character to be used. |
| void CDMSetColorBin | ( | _INOUT_ CDMColorScheme * | data, |
| _IN_ short | position, | ||
| const _IN_ DWORD | color | ||
| ) |
Sets an RGB color inside a ColorScheme. This function accepts an already converted to binary RGB color. You may use Windows.h macro RGB(r,g,b) to get the data. Status: Working.
| [in,out] | data | The color scheme, must not be null. |
| [in] | position | The position of the color inside the ColorScheme. |
| [in] | color | The binary RGB color. |
| void CDMSetColorRGB | ( | _INOUT_ CDMColorScheme * | data, |
| _IN_ short | position, | ||
| _IN_ short | r, | ||
| _IN_ short | g, | ||
| _IN_ short | b | ||
| ) |
Sets an RGB color inside a ColorScheme. Every color goes from 0 to 255, however every value passes through a modulo operation to assure no weird behavior will happen. Status: Working.
| [in,out] | data | The color scheme, must not be null. |
| [in] | position | The position of the color inside the ColorScheme. |
| [in] | r | Red value. |
| [in] | g | Green value. |
| [in] | b | Blue value. |
| void CDMSetCursorVisibility | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ CDMBool | status | ||
| ) |
Sets the visibility of the console's cursor. Status: Working.
| [in,out] | ctx | If non-null, the context. |
| [in] | status | Boolean value to set the status of the cursor. |
Sets an specific errno to a value. Status: Working.
| code | The code to be set. |
| void CDMSetFontAndSize | ( | _INOUT_ CDMContext ** | ctx, |
| const _IN_ wchar_t * | fontName, | ||
| const _IN_ short | width, | ||
| const _IN_ short | height | ||
| ) |
Sets the font and font size of the console. The recommended font name is L"Terminal" for its unique characteristic of allowing square pixels, however most fonts can be used. It's important to include L at the start of your string, since this function requires a wchar_t* instead of a regular char. Status: Working.
| [in,out] | ctx | The context, must not be null. |
| [in] | fontName | Name of the font. |
| [in] | width | The width in regular pixels of the font. |
| [in] | height | The height in regular pixels of the font. |
| void CDMSetForegroundColor | ( | _INOUT_ CDMSurface ** | surface, |
| const _IN_ CDMLetterColor | c1, | ||
| const _IN_ CDMLetterColor | c2, | ||
| const _IN_ CDMLetterColor | c3, | ||
| const _IN_ CDMLetterColor | c4 | ||
| ) |
A CDMSurface may only have 4 color sets at a time. Including background, foreground and character. Each combination of 3 of those elements makes a set. This function sets directly the four foreground colors that the Surface will use from the color palette. Status: Working.
| [in,out] | surface | The surface, must not be null. |
| [in] | c1 | The first CDMEnum using color macros. |
| [in] | c2 | The second CDMEnum using color macros. |
| [in] | c3 | The third CDMEnum using color macros. |
| [in] | c4 | The fourth CDMEnum using color macros. |
| void CDMSetPixel | ( | _INOUT_ CDMSurface ** | surface, |
| _IN_ short | x, | ||
| _IN_ short | y, | ||
| _IN_ CDMColorSets | pixelSet | ||
| ) |
Sets a pixel inside a surface. You must select from one of the five possible colors inside the surface. Status: Working.
| [in,out] | surface | The surface to be modified, must not be null. |
| [in] | x | The x coordinate of the pixel. |
| [in] | y | The y coordinate of the pixel. |
| [in] | pixelSet | The enumeration value of the data. |
| void CDMSetWindowTitle | ( | const _IN_ wchar_t * | title | ) |
Sets the title of the console. Just a wrapper for a WINAPI functionality. Status: Working.
| [in] | title | The title of the console. |
| CDMText * CDMTextWrapper | ( | _IN_ wchar_t * | text, |
| const _IN_ CDMLetterColor | color, | ||
| const _IN_ CDMBackgroundColor | background | ||
| ) |
Since CDM basically hijacks the console, functions like printf are not enabled. No output will be shown using them, instead you must use the text as an object, this means you have much more control of the position and design of your text, at the expense of making a little bit harder to use. Moreover, repeated uses of the same text box will not require you to create a new object or call anything else other than adding this object to the context, or drawing it directly. All text begins in the ( 0 , 0 ) coordinate. Status: Working.
| [in,out] | text | The text string, must not be null, must be zero terminated. |
| [in] | color | The color of the text. |
| [in] | background | The background color of the text. |
| CDMText * CDMTextWrapper_s | ( | _IN_ wchar_t * | text, |
| const _IN_ size_t | textSize, | ||
| const _IN_ CDMLetterColor | color, | ||
| const _IN_ CDMBackgroundColor | background | ||
| ) |
Since CDM basically hijacks the console, functions like printf are disabled. No output will be shown using them, instead you must use the text as an object, this means you have much more control of the position and design of your text, at the expense of making a little bit harder to use. Moreover, repeated uses of the same text box will not require you to create a new object or call anything else other than adding this object to the context, or drawing it directly. All text begins in the ( 0 , 0 ) coordinate. Status: Working.
| [in,out] | text | The text string, must not be null. |
| [in] | textSize | Size of the text. |
| [in] | color | The color of the text. |
| [in] | background | The background color of the text. |
| void CDMToggleFullscreen | ( | CDMContext **_INOUT_ | ctx, |
| const _IN_ CDMBool | val | ||
| ) |
Toggles full screen mode. Status: May be working on older platforms.
| [in,out] | ctx | If non-null, the context. |
| [in] | val | Boolean value for the toggle. |