SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
Data Structures | Enumerations
Debugging, Logging, and Error Handling

Data Structures

struct  GPU_ErrorObject
 

Enumerations

enum  GPU_ErrorEnum {
  GPU_ERROR_NONE = 0, GPU_ERROR_BACKEND_ERROR = 1, GPU_ERROR_DATA_ERROR = 2, GPU_ERROR_USER_ERROR = 3,
  GPU_ERROR_UNSUPPORTED_FUNCTION = 4, GPU_ERROR_NULL_ARGUMENT = 5, GPU_ERROR_FILE_NOT_FOUND = 6
}
 
enum  GPU_DebugLevelEnum {
  GPU_DEBUG_LEVEL_0 = 0, GPU_DEBUG_LEVEL_1 = 1, GPU_DEBUG_LEVEL_2 = 2, GPU_DEBUG_LEVEL_3 = 3,
  GPU_DEBUG_LEVEL_MAX = 3
}
 
enum  GPU_LogLevelEnum { GPU_LOG_INFO = 0, GPU_LOG_WARNING, GPU_LOG_ERROR }
 
DECLSPEC void SDLCALL GPU_SetDebugLevel (GPU_DebugLevelEnum level)
 
DECLSPEC GPU_DebugLevelEnum SDLCALL GPU_GetDebugLevel (void)
 
DECLSPEC void SDLCALL GPU_LogInfo (const char *format,...)
 
DECLSPEC void SDLCALL GPU_LogWarning (const char *format,...)
 
DECLSPEC void SDLCALL GPU_LogError (const char *format,...)
 
DECLSPEC void SDLCALL GPU_SetLogCallback (int(*callback)(GPU_LogLevelEnum log_level, const char *format, va_list args))
 
DECLSPEC void SDLCALL GPU_PushErrorCode (const char *function, GPU_ErrorEnum error, const char *details,...)
 
DECLSPEC GPU_ErrorObject SDLCALL GPU_PopErrorCode (void)
 
DECLSPEC const char *SDLCALL GPU_GetErrorString (GPU_ErrorEnum error)
 
DECLSPEC void SDLCALL GPU_SetErrorQueueMax (unsigned int max)
 

Detailed Description

Use GPU_Log() for normal logging output (e.g. to replace printf). Other logging priorities are handled by GPU_LogWarning() and GPU_LogError().

SDL_gpu stores an error queue that you can read and manipulate using GPU_PopErrorCode() and GPU_PushErrorCode(). If you set the debug level using GPU_SetDebugLevel(), you can have any errors automatically logged as they are generated.

Enumeration Type Documentation

◆ GPU_DebugLevelEnum

Type enumeration for debug levels.

See also
GPU_SetDebugLevel()
GPU_GetDebugLevel()
Enumerator
GPU_DEBUG_LEVEL_0 
GPU_DEBUG_LEVEL_1 
GPU_DEBUG_LEVEL_2 
GPU_DEBUG_LEVEL_3 
GPU_DEBUG_LEVEL_MAX 

Definition at line 629 of file SDL_gpu.h.

◆ GPU_ErrorEnum

Type enumeration for error codes.

See also
GPU_PushErrorCode()
GPU_PopErrorCode()
Enumerator
GPU_ERROR_NONE 
GPU_ERROR_BACKEND_ERROR 
GPU_ERROR_DATA_ERROR 
GPU_ERROR_USER_ERROR 
GPU_ERROR_UNSUPPORTED_FUNCTION 
GPU_ERROR_NULL_ARGUMENT 
GPU_ERROR_FILE_NOT_FOUND 

Definition at line 605 of file SDL_gpu.h.

◆ GPU_LogLevelEnum

Type enumeration for logging levels.

See also
GPU_SetLogCallback()
Enumerator
GPU_LOG_INFO 
GPU_LOG_WARNING 
GPU_LOG_ERROR 

Definition at line 642 of file SDL_gpu.h.

Function Documentation

◆ GPU_GetDebugLevel()

DECLSPEC GPU_DebugLevelEnum SDLCALL GPU_GetDebugLevel ( void  )

Returns the current global debug level.

Definition at line 687 of file SDL_gpu.c.

◆ GPU_GetErrorString()

DECLSPEC const char* SDLCALL GPU_GetErrorString ( GPU_ErrorEnum  error)

Gets the string representation of an error code.

Definition at line 765 of file SDL_gpu.c.

◆ GPU_LogError()

DECLSPEC void SDLCALL GPU_LogError ( const char *  format,
  ... 
)

Prints an error log message.

Definition at line 175 of file SDL_gpu.c.

◆ GPU_LogInfo()

DECLSPEC void SDLCALL GPU_LogInfo ( const char *  format,
  ... 
)

Prints an informational log message.

Definition at line 159 of file SDL_gpu.c.

◆ GPU_LogWarning()

DECLSPEC void SDLCALL GPU_LogWarning ( const char *  format,
  ... 
)

Prints a warning log message.

Definition at line 167 of file SDL_gpu.c.

◆ GPU_PopErrorCode()

DECLSPEC GPU_ErrorObject SDLCALL GPU_PopErrorCode ( void  )

Pops an error object from the error queue and returns it. If the error queue is empty, it returns an error object with NULL function, GPU_ERROR_NONE error, and NULL details.

Definition at line 736 of file SDL_gpu.c.

◆ GPU_PushErrorCode()

DECLSPEC void SDLCALL GPU_PushErrorCode ( const char *  function,
GPU_ErrorEnum  error,
const char *  details,
  ... 
)

Pushes a new error code into the error queue. If the queue is full, the queue is not modified.

Parameters
functionThe name of the function that pushed the error
errorThe error code to push on the error queue
detailsAdditional information string, can be NULL.

Definition at line 692 of file SDL_gpu.c.

◆ GPU_SetDebugLevel()

DECLSPEC void SDLCALL GPU_SetDebugLevel ( GPU_DebugLevelEnum  level)

Sets the global debug level. GPU_DEBUG_LEVEL_0: Normal GPU_DEBUG_LEVEL_1: Prints messages when errors are pushed via GPU_PushErrorCode() GPU_DEBUG_LEVEL_2: Elevates warning logs to error priority GPU_DEBUG_LEVEL_3: Elevates info logs to error priority

Definition at line 680 of file SDL_gpu.c.

◆ GPU_SetErrorQueueMax()

DECLSPEC void SDLCALL GPU_SetErrorQueueMax ( unsigned int  max)

Changes the maximum number of error objects that SDL_gpu will store. This deletes all currently stored errors.

Definition at line 624 of file SDL_gpu.c.

◆ GPU_SetLogCallback()

DECLSPEC void SDLCALL GPU_SetLogCallback ( int(*)(GPU_LogLevelEnum log_level, const char *format, va_list args)  callback)

Sets a custom callback for handling logging. Use stdio's vsnprintf() to process the va_list into a string. Passing NULL as the callback will reset to the default internal logging.

Definition at line 151 of file SDL_gpu.c.