OldSchool Library
|
Functions | |
void | oslInitGfx (int pixelFormat, int bDoubleBuffer) |
void | oslStartDrawing () |
Initializes the drawing process with OSLib. Call this function before performing any drawing operations. | |
void | oslEndDrawing () |
void | oslSyncDrawing () |
void | oslSwapBuffers () |
void | oslEndGfx () |
void | oslSetSysDisplayListSize (int newSize) |
Core functions and configuration routines for drawing in OSLib.
|
extern |
Initializes the graphical system for OSLib.
This function sets up the rendering environment, including screen resolution, double buffering, and various graphical settings. It can be called multiple times, but note that all images stored in video memory (OSL_IN_VRAM) will be invalidated after calling this function, so ensure you delete all such images beforehand to avoid unexpected behavior.
pixelFormat | The pixel format for the screen. Options include:
|
bDoubleBuffer | Set to TRUE (1) to enable double buffering, which is recommended for games to prevent flickering. Refer to oslSwapBuffers for more information on double buffering. |
|
extern |
Initializes the drawing process with OSLib. Call this function before performing any drawing operations.
This function sets up the necessary GPU state and ensures that drawing operations are properly initialized. It also resets the current texture and palette to null and starts a new command list for rendering.
|
extern |
Ends drawing. Call this function once you've finished rendering. This command waits for the GPU to finish rendering, which can be slow. OSLib may use this remaining time to process and output sound.
|
extern |
Waits for the GPU (Graphics Processing Unit) to complete its current rendering tasks. Since rendering occurs in parallel with CPU operations, there is a risk of modifying an image that the GPU is still processing, leading to incorrect render output.
Calling oslSyncDrawing
ensures that the GPU has finished its operations, allowing you to safely modify graphical data afterward. However, be aware that synchronizing with the GPU can be very slow, as it waits for the GPU to complete all pending tasks. Use this function only when absolutely necessary and when you fully understand its performance implications.
Note: The number of drawing commands you can issue between oslStartDrawing
and oslEndDrawing
is limited by the size of the display list, where these commands are stored before being sent to the GPU. If the display list overflows, your program may crash or exhibit erratic behavior.
oslSyncDrawing
resets the display list after waiting for the GPU to complete rendering, similar to what oslStartDrawing
and oslEndDrawing
do. It is a faster alternative for syncing without initiating the end and start of a frame. If you encounter crashes due to extensive drawing commands, consider inserting a call to oslSyncDrawing
to mitigate the issue.
|
extern |
Swaps the buffers.
In double buffering mode, this function should be called once per frame. Double buffering prevents flickering by maintaining two buffers: one that is displayed on the screen and one that is used for drawing. Once drawing is complete, the buffers are swapped, displaying the newly rendered frame and hiding the previous one for the next drawing operation.
|
extern |
Ends the graphical context, releasing memory used for the display list.
After calling this function, all images placed in video memory (OSL_IN_VRAM) become invalid. Ensure that you release ALL such images before calling this function, as they will need to be reloaded after initializing graphics again with oslInitGfx.
|
extern |
Sets the display list size.
newSize | The new size of the display list in bytes. |