- Main Page
- Classes
- Files

- File List
- File Members

# flGraphics.c File Reference

`#include "flGlobal.h"`
`#include <pspdisplay.h>`
`#include <pspdebug.h>`
`#include <pspgu.h>`
`#include <pspgum.h>`
`#include <stdio.h>`

Go to the source code of this file.

## Functions
void * | graphicsDispListCur ()
| Returns the address of the current display list, to be written to.
void * | graphicsDispListLast ()
| Returns the address of the last display list, to be drawn onto the screen.
void | graphicsInit ()
| Initializes the graphics system, this is called internally by flInitialize().
void | graphicsSetProjection ()
| Sets up the projection matrix for 3d.
void | graphicsTerm ()
| Terminates the graphics system, this is called internally by flTerminate().
void | graphicsSwapBuffers ()
| Swaps the buffers and display lists around to show what you drew last frame, this function is used as a launching off point for the notify functions and other functions that need to be called each frame.
void | graphicsBeginOrtho ()
| Begins orthographic drawing mode.
void | graphicsEndOrtho ()
| Ends orthographic drawing mode.
void | graphicsSetLinesAntiAlias (bool inValue)
| This is basically a wrapper for sceGuEnable/Disable(GU_LINE_SMOOTH).
void | graphicsRenderToFramebuffer ()
| This restores the render target to being the draw buffer again.
bool | graphicsRenderToVmem (void *inPtr, int inStride, u8 inPixelFormat)
| This sets the render target to an area in vmem.
u8 | graphicsPixelFormatBPP (u8 inPixelFormat)
| Gets the bits per pixel (BPP) of a pixel type.
u8 * | graphicsSwizzleData (u8 *inData, u32 inWidth, u32 inHeight, u8 inPixelFormat)
| Swizzles data so it is optimized for the PSP GPU.
u8 * | graphicsUnswizzleData (u8 *inData, u32 inWidth, u32 inHeight, u8 inPixelFormat)
| Unswizzles data so it is back in it's natural state ready for saving/modifying.
## Variables
bool | graphicsVSync = FL_GRAPHICS_VSYNC_DEFAULT
| This boolean stores whether VSync is currently activated or not, it defaults to GRAPHICS_VSYNC_DEFAULT and can only be overridden if FL_GRAPHICS_VSYNC_AUTO is enabled.
void * | graphicsDisplayList = NULL
| Display list memory, used as the main 2 display lists.
void * | graphicsDisplayListCache = NULL
| A small display list, used for graphics using GU_DIRECT .
u8 | graphicsDisplayListCurrent = 0
| The current display list to be used.
void * | graphicsDrawBuffer = NULL
| Address of the draw buffer.
void * | graphicsDispBuffer = NULL
| Address of the display buffer.
void * | graphicsDepthBuffer = NULL
| Address of the Depth/Z buffer.
bool | graphicsLinesAntiAlias = FL_GRAPHICS_LINES_ANTIALIAS_DEFAULT
| Whether line antialiasing is currently enabled or not.
bool | graphicsWireframe = false
| Whether wireframe mode is enabled or not, this currently only effects the drawing of 3d primatives and models.
Timer * | graphicsFPSTimer
float | graphicsFPS = 0
| The current fps, this is recalculated every frame so modifying it has almost no effect.
bool | graphicsFPSShow = FL_GRAPHICS_FPS_SHOW_DEFAULT
| This variable stores whether the FPS display is enabled or not, it defaults to FL_GRAPHICS_FPS_SHOW_DEFAULT.
bool | graphicsFrame = false
| This stores whether the graphics system is currently mid-frame or not.
bool | graphicsOrtho = false
void * | graphicsRenderTarget = NULL
| The current render target address.
int | graphicsRenderTargetStride = 0
| The current render target buffer width.
u8 | graphicsRenderTargetPixelFormat = 0
| The current render target pixel format.

## Function Documentation

void graphicsBeginOrtho | ( |  | ) |

Begins orthographic drawing mode.

Warning:
  This isn't working at the minute, but all 2d on the PSP uses GU_TRANSFORM_2D anyway.

Definition at line 324 of file flGraphics.c.

void* graphicsDispListCur | ( |  | ) |

Returns the address of the current display list, to be written to.

Returns:
  The address of the current display list.

Definition at line 51 of file flGraphics.c.

Referenced by graphicsInit(), and graphicsSwapBuffers().

void* graphicsDispListLast | ( |  | ) |

Returns the address of the last display list, to be drawn onto the screen.

Returns:
  The address of the last display list.

Definition at line 59 of file flGraphics.c.

void graphicsEndOrtho | ( |  | ) |

Ends orthographic drawing mode.

Warning:
  This isn't working at the minute, but all 2d on the PSP uses GU_TRANSFORM_2D anyway.

Definition at line 339 of file flGraphics.c.

void graphicsInit | ( |  | ) |

Initializes the graphics system, this is called internally by flInitialize().

See also:
  flInitialize(), graphicsTerm()

Definition at line 67 of file flGraphics.c.

References debugError, FL_GRAPHICS_DISP_BUFFER_FORMAT, FL_GRAPHICS_DRAW_BUFFER_FORMAT, graphicsDispListCur(), graphicsFPSTimer, graphicsPixelFormatBPP(), GU_SYNC_WAIT, memAlign, memClear, SCREEN_HEIGHT, SCREEN_PITCH, SCREEN_STRIDE, SCREEN_WIDTH, timerCreate(), vmemAllocBuffer(), and vmemInit().

Referenced by flInitialize().

u8 graphicsPixelFormatBPP | ( | u8 | inPixelFormat | ) |

Gets the bits per pixel (BPP) of a pixel type.

Parameters:

  | inPixelFormat | The format to get the BPP from, using gu defines (e.g GU_PSM_8888).

Returns:
  The BPP of the pixel format.

Definition at line 382 of file flGraphics.c.

Referenced by graphicsInit(), graphicsSwizzleData(), graphicsUnswizzleData(), and palBPP().

void graphicsRenderToFramebuffer | ( |  | ) |

This restores the render target to being the draw buffer again.

Definition at line 361 of file flGraphics.c.

References FL_GRAPHICS_DRAW_BUFFER_FORMAT, and SCREEN_STRIDE.

bool graphicsRenderToVmem | ( | void * | inPtr,
|  | int | inStride,
|  | u8 | inPixelFormat |
| ) |  |  |

This sets the render target to an area in vmem.

Parameters:

  | inPtr | Pointer to the start of the render target.
  | inStride | The total width of the buffer including stride.
  | inPixelFormat | The format of the render target using gu defines (e.g GU_PSM_8888).

Returns:
  Whether the target switch was successful or not.

Definition at line 368 of file flGraphics.c.

References debugError.

void graphicsSetLinesAntiAlias | ( | bool | inValue | ) |

This is basically a wrapper for sceGuEnable/Disable(GU_LINE_SMOOTH).

Parameters:

  | inValue | Whether to enable/disable line anti-aliasing.

Definition at line 351 of file flGraphics.c.

void graphicsSetProjection | ( |  | ) |

Sets up the projection matrix for 3d.

Note:
  This is currently called by flInitialize() although this may change in the future.

See also:
  flInitialize()

Definition at line 190 of file flGraphics.c.

References SCREEN_HEIGHT, and SCREEN_WIDTH.

Referenced by flInitialize().

void graphicsSwapBuffers | ( |  | ) |

Swaps the buffers and display lists around to show what you drew last frame, this function is used as a launching off point for the notify functions and other functions that need to be called each frame.

See also:
  ntfyTick()

Definition at line 219 of file flGraphics.c.

References FL_GRAPHICS_DISP_BUFFER_FORMAT, FL_GRAPHICS_DRAW_BUFFER_FORMAT, FL_GRAPHICS_FPS_DAMPRATIO, FL_GRAPHICS_FPS_SHOW_COLOR, FL_GRAPHICS_VSYNC_AUTO_CUTOFF, fontDefault, fontDraw2dString(), graphicsDispListCur(), graphicsFPSTimer, graphicsVSync, GU_SYNC_WAIT, ntfyTick(), NULL, SCREEN_HEIGHT, SCREEN_STRIDE, SCREEN_WIDTH, texBound, timerGetDeltaTime(), vertTsVs::vertU, vertTsVs::vertV, vertTsVs::vertX, vertTsVs::vertY, and vertTsVs::vertZ.

Referenced by debugCriticalErrorFrom().

u8* graphicsSwizzleData | ( | u8 * | inData,
|  | u32 | inWidth,
|  | u32 | inHeight,
|  | u8 | inPixelFormat |
| ) |  |  |

Swizzles data so it is optimized for the PSP GPU.

Parameters:

  | inData | A pointer to the data that is to be swizzled.
  | inWidth | The width of the data in pixels.
  | inHeight | The height of the data in pixels.
  | inPixelFormat | The pixel format of the data, using gu defines (e.g GU_PSM_8888).

Returns:
  The pointer to the swizzled data or NULL on failure.

Note:
  This doesn't keep the original data, it simply swizzles the pointer you pass in.

Definition at line 403 of file flGraphics.c.

References debugError, debugWarning, graphicsPixelFormatBPP(), memCopy, memFree, memIsCachedPointer, memQalloc, and NULL.

Referenced by fontCreateDebugTex(), and texSwizzle().

void graphicsTerm | ( |  | ) |

Terminates the graphics system, this is called internally by flTerminate().

See also:
  flTerminate(), graphicsInit()

Definition at line 205 of file flGraphics.c.

References GU_SYNC_WAIT, memFree, and vmemTerm().

u8* graphicsUnswizzleData | ( | u8 * | inData,
|  | u32 | inWidth,
|  | u32 | inHeight,
|  | u8 | inPixelFormat |
| ) |  |  |

Unswizzles data so it is back in it's natural state ready for saving/modifying.

Parameters:

  | inData | A pointer to the data that is to be unswizzled.
  | inWidth | The width of the data in pixels.
  | inHeight | The height of the data in pixels.
  | inPixelFormat | The pixel format of the data, using gu defines (e.g GU_PSM_8888).

Returns:
  The pointer to the unswizzled data or NULL on failure.

Note:
  This doesn't keep the original data, it simply swizzles the pointer you pass in.

Definition at line 476 of file flGraphics.c.

References debugError, debugWarning, graphicsPixelFormatBPP(), memCopy, memFree, memIsCachedPointer, memQalloc, and NULL.

Referenced by texUnswizzle().

## Variable Documentation

void* graphicsDepthBuffer = NULL

Address of the Depth/Z buffer.

Definition at line 34 of file flGraphics.c.

Referenced by graphicsEffectFsDepthFog().

void* graphicsDispBuffer = NULL

Address of the display buffer.

Definition at line 33 of file flGraphics.c.

Referenced by debugCriticalErrorFrom(), debugDevWarningFrom(), debugErrorFrom(), debugWarningFrom(), and texScreenshot().

void* graphicsDisplayList = NULL

Display list memory, used as the main 2 display lists.

Definition at line 27 of file flGraphics.c.

Referenced by palMoveVMem(), and texMoveVMem().

void* graphicsDisplayListCache = NULL

A small display list, used for graphics using GU_DIRECT .

Definition at line 28 of file flGraphics.c.

u8 graphicsDisplayListCurrent = 0

The current display list to be used.

Definition at line 30 of file flGraphics.c.

void* graphicsDrawBuffer = NULL

Address of the draw buffer.

Definition at line 32 of file flGraphics.c.

Referenced by debugCriticalErrorFrom(), debugDevWarningFrom(), debugErrorFrom(), debugWarningFrom(), graphics2dDrawTexture(), graphics2dDrawTextureSection(), graphicsEffectFsColorEnhance(), graphicsEffectFsDichrome(), graphicsEffectFsGlow(), graphicsEffectFsGrayscale(), graphicsEffectFsGrayscaleSW(), graphicsEffectFsInvert(), graphicsEffectFsLightEnhance(), graphicsEffectFsMonochrome(), graphicsEffectFsNightVision(), graphicsEffectFsNightVisionSW(), and graphicsEffectFsThermalVision().

float graphicsFPS = 0

The current fps, this is recalculated every frame so modifying it has almost no effect.

Definition at line 41 of file flGraphics.c.

bool graphicsFPSShow = FL_GRAPHICS_FPS_SHOW_DEFAULT

This variable stores whether the FPS display is enabled or not, it defaults to FL_GRAPHICS_FPS_SHOW_DEFAULT.

Definition at line 42 of file flGraphics.c.

Timer* graphicsFPSTimer

Definition at line 40 of file flGraphics.c.

Referenced by graphicsInit(), and graphicsSwapBuffers().

bool graphicsFrame = false

This stores whether the graphics system is currently mid-frame or not.

Note:
  At the minute this is unused, but it was used in older versions and is planned to be used in the future.

Definition at line 45 of file flGraphics.c.

Referenced by palMoveVMem(), and texMoveVMem().

bool graphicsLinesAntiAlias = FL_GRAPHICS_LINES_ANTIALIAS_DEFAULT

Whether line antialiasing is currently enabled or not.

Definition at line 36 of file flGraphics.c.

bool graphicsOrtho = false

Definition at line 46 of file flGraphics.c.

void* graphicsRenderTarget = NULL

The current render target address.

Definition at line 47 of file flGraphics.c.

u8 graphicsRenderTargetPixelFormat = 0

The current render target pixel format.

Definition at line 49 of file flGraphics.c.

int graphicsRenderTargetStride = 0

The current render target buffer width.

Definition at line 48 of file flGraphics.c.

bool graphicsVSync = FL_GRAPHICS_VSYNC_DEFAULT

This boolean stores whether VSync is currently activated or not, it defaults to GRAPHICS_VSYNC_DEFAULT and can only be overridden if FL_GRAPHICS_VSYNC_AUTO is enabled.

Definition at line 22 of file flGraphics.c.

Referenced by graphicsSwapBuffers().

bool graphicsWireframe = false

Whether wireframe mode is enabled or not, this currently only effects the drawing of 3d primatives and models.

Warning:
  This is not implemented completely yet (even within the 3d drawing routines) so use it sparingly.

Definition at line 37 of file flGraphics.c.

Referenced by graphics3dDrawCube(), graphics3dDrawCubeColoreda(), mdl3dStatDraw(), and mdl3dStatDrawTextured().