SDL
2.0
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "SDL.h"
#include "SDL_test_common.h"
Go to the source code of this file.
Data Structures | |
struct | UnifontGlyph |
Macros | |
#define | DEFAULT_PTSIZE 30 |
#define | DEFAULT_FONT "unifont-9.0.02.hex" |
#define | MAX_TEXT_LENGTH 256 |
#define | UNIFONT_MAX_CODEPOINT 0x1ffff |
#define | UNIFONT_NUM_GLYPHS 0x20000 |
#define | UNIFONT_TEXTURE_WIDTH 512 |
#define | UNIFONT_GLYPHS_IN_ROW (UNIFONT_TEXTURE_WIDTH / 16) |
#define | UNIFONT_GLYPHS_IN_TEXTURE (UNIFONT_GLYPHS_IN_ROW * UNIFONT_GLYPHS_IN_ROW) |
#define | UNIFONT_NUM_TEXTURES ((UNIFONT_NUM_GLYPHS + UNIFONT_GLYPHS_IN_TEXTURE - 1) / UNIFONT_GLYPHS_IN_TEXTURE) |
#define | UNIFONT_TEXTURE_SIZE (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4) |
#define | UNIFONT_TEXTURE_PITCH (UNIFONT_TEXTURE_WIDTH * 4) |
#define | UNIFONT_DRAW_SCALE 2 |
Functions | |
static Uint8 | dehex (char c) |
static Uint8 | dehex2 (char c1, char c2) |
static Uint8 | validate_hex (const char *cp, size_t len, Uint32 *np) |
static int | unifont_init (const char *fontname) |
static void | unifont_make_rgba (Uint8 *src, Uint8 *dst, Uint8 width) |
static int | unifont_load_texture (Uint32 textureID) |
static Sint32 | unifont_draw_glyph (Uint32 codepoint, int rendererID, SDL_Rect *dstrect) |
static void | unifont_cleanup () |
size_t | utf8_length (unsigned char c) |
char * | utf8_next (char *p) |
char * | utf8_advance (char *p, size_t distance) |
Uint32 | utf8_decode (char *p, size_t len) |
void | usage () |
void | InitInput () |
void | CleanupVideo () |
void | _Redraw (int rendererID) |
void | Redraw () |
int | main (int argc, char *argv[]) |
Variables | |
static SDLTest_CommonState * | state |
static SDL_Rect | textRect |
static SDL_Rect | markedRect |
static SDL_Color | lineColor = {0,0,0,255} |
static SDL_Color | backColor = {255,255,255,255} |
static SDL_Color | textColor = {0,0,0,255} |
static char | text [MAX_TEXT_LENGTH] |
static char | markedText [SDL_TEXTEDITINGEVENT_TEXT_SIZE] |
static int | cursor = 0 |
struct UnifontGlyph * | unifontGlyph |
static SDL_Texture ** | unifontTexture |
static Uint8 | unifontTextureLoaded [UNIFONT_NUM_TEXTURES] = {0} |
#define DEFAULT_FONT "unifont-9.0.02.hex" |
#define UNIFONT_GLYPHS_IN_ROW (UNIFONT_TEXTURE_WIDTH / 16) |
Definition at line 56 of file testime.c.
Referenced by unifont_draw_glyph(), and unifont_load_texture().
#define UNIFONT_GLYPHS_IN_TEXTURE (UNIFONT_GLYPHS_IN_ROW * UNIFONT_GLYPHS_IN_ROW) |
Definition at line 57 of file testime.c.
Referenced by unifont_draw_glyph(), and unifont_load_texture().
#define UNIFONT_MAX_CODEPOINT 0x1ffff |
Definition at line 52 of file testime.c.
Referenced by unifont_draw_glyph(), and unifont_init().
#define UNIFONT_NUM_GLYPHS 0x20000 |
Definition at line 53 of file testime.c.
Referenced by unifont_init().
#define UNIFONT_NUM_TEXTURES ((UNIFONT_NUM_GLYPHS + UNIFONT_GLYPHS_IN_TEXTURE - 1) / UNIFONT_GLYPHS_IN_TEXTURE) |
Definition at line 58 of file testime.c.
Referenced by unifont_cleanup(), unifont_draw_glyph(), unifont_init(), and unifont_load_texture().
#define UNIFONT_TEXTURE_PITCH (UNIFONT_TEXTURE_WIDTH * 4) |
Definition at line 60 of file testime.c.
Referenced by unifont_load_texture(), and unifont_make_rgba().
#define UNIFONT_TEXTURE_SIZE (UNIFONT_TEXTURE_WIDTH * UNIFONT_TEXTURE_WIDTH * 4) |
Definition at line 59 of file testime.c.
Referenced by unifont_load_texture().
#define UNIFONT_TEXTURE_WIDTH 512 |
Definition at line 55 of file testime.c.
Referenced by unifont_load_texture().
void _Redraw | ( | int | rendererID | ) |
Definition at line 466 of file testime.c.
References SDL_Color::a, SDL_Color::b, cursor, SDL_Color::g, SDL_Rect::h, SDL_Surface::h, i, markedRect, markedText, NULL, SDL_Color::r, renderer, SDLTest_CommonState::renderers, SDL_CreateTextureFromSurface, SDL_DestroyTexture, SDL_FreeSurface, SDL_RenderCopy, SDL_RenderFillRect, SDL_SetRenderDrawColor, SDL_SetTextInputRect, SDL_StartTextInput, SDL_StopTextInput, SDL_strlen, text, textRect, unifont_draw_glyph(), UNIFONT_DRAW_SCALE, utf8_advance(), utf8_decode(), utf8_length(), SDL_Rect::w, SDL_Surface::w, SDL_Rect::x, and SDL_Rect::y.
Referenced by Redraw().
void CleanupVideo | ( | ) |
Definition at line 455 of file testime.c.
References SDL_StopTextInput, and unifont_cleanup().
Referenced by main().
|
static |
Definition at line 71 of file testime.c.
Referenced by dehex2(), and validate_hex().
|
static |
void InitInput | ( | ) |
Definition at line 441 of file testime.c.
References DEFAULT_WINDOW_WIDTH, SDL_Rect::h, markedText, SDL_StartTextInput, text, textRect, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 632 of file testime.c.
References CleanupVideo(), cursor, DEFAULT_FONT, DEFAULT_PTSIZE, done, SDL_Event::edit, i, InitInput(), SDL_Event::key, SDL_KeyboardEvent::keysym, SDL_TextEditingEvent::length, markedText, SDLTest_CommonState::num_windows, Redraw(), renderer, SDLTest_CommonState::renderers, SDL_Keysym::scancode, SDL_BLENDMODE_NONE, SDL_GetKeyName, SDL_GetScancodeName, SDL_INIT_VIDEO, SDL_KEYDOWN, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogError, SDL_LogSetPriority, SDL_PollEvent, SDL_RenderClear, SDL_SetRenderDrawBlendMode, SDL_SetRenderDrawColor, SDL_strlcat, SDL_strlcpy, SDL_strlen, SDL_TEXTEDITING, SDL_TEXTEDITINGEVENT_TEXT_SIZE, SDL_TEXTINPUT, SDLK_BACKSPACE, SDLK_RETURN, SDLTest_CommonArg(), SDLTest_CommonCreateState(), SDLTest_CommonEvent(), SDLTest_CommonInit(), SDLTest_CommonQuit(), SDL_TextEditingEvent::start, SDL_Keysym::sym, text, SDL_TextEditingEvent::text, SDL_TextInputEvent::text, SDL_Event::text, SDL_Event::type, unifont_init(), usage(), and SDL_Rect::w.
void Redraw | ( | ) |
Definition at line 615 of file testime.c.
References _Redraw(), i, NULL, SDLTest_CommonState::num_windows, renderer, SDLTest_CommonState::renderers, SDL_RenderClear, SDL_RenderPresent, SDL_SetRenderDrawColor, and SDLTest_CommonState::windows.
Referenced by main().
|
static |
Definition at line 345 of file testime.c.
References i, j, NULL, SDLTest_CommonState::num_windows, renderer, SDLTest_CommonState::renderers, SDL_DestroyTexture, SDL_free, UNIFONT_NUM_TEXTURES, unifontGlyph, unifontTextureLoaded, and SDLTest_CommonState::windows.
Referenced by CleanupVideo().
Definition at line 320 of file testime.c.
References SDL_Rect::h, NULL, SDLTest_CommonState::renderers, SDL_RenderCopy, UNIFONT_GLYPHS_IN_ROW, UNIFONT_GLYPHS_IN_TEXTURE, unifont_load_texture(), UNIFONT_MAX_CODEPOINT, UNIFONT_NUM_TEXTURES, unifontGlyph, unifontTextureLoaded, SDL_Rect::w, UnifontGlyph::width, SDL_Rect::x, and SDL_Rect::y.
Referenced by _Redraw().
|
static |
Definition at line 102 of file testime.c.
References dehex2(), i, NULL, SDLTest_CommonState::num_windows, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LogError, SDL_LogWarn, SDL_malloc, SDL_memmove, SDL_memset, SDL_RWclose, SDL_RWFromFile, SDL_RWread, UNIFONT_MAX_CODEPOINT, UNIFONT_NUM_GLYPHS, UNIFONT_NUM_TEXTURES, unifontGlyph, validate_hex(), and UnifontGlyph::width.
Referenced by main().
|
static |
Definition at line 263 of file testime.c.
References i, NULL, SDLTest_CommonState::num_windows, renderer, SDLTest_CommonState::renderers, SDL_BLENDMODE_BLEND, SDL_CreateTexture, SDL_free, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LogError, SDL_malloc, SDL_memset, SDL_PIXELFORMAT_ARGB8888, SDL_SetTextureBlendMode, SDL_TEXTUREACCESS_STATIC, SDL_UpdateTexture, UNIFONT_GLYPHS_IN_ROW, UNIFONT_GLYPHS_IN_TEXTURE, unifont_make_rgba(), UNIFONT_NUM_TEXTURES, UNIFONT_TEXTURE_PITCH, UNIFONT_TEXTURE_SIZE, UNIFONT_TEXTURE_WIDTH, unifontGlyph, unifontTextureLoaded, and SDLTest_CommonState::windows.
Referenced by unifont_draw_glyph().
Definition at line 227 of file testime.c.
References SDL_Color::a, SDL_Color::b, SDL_Color::g, i, j, SDL_Color::r, and UNIFONT_TEXTURE_PITCH.
Referenced by unifont_load_texture().
char* utf8_advance | ( | char * | p, |
size_t | distance | ||
) |
Definition at line 402 of file testime.c.
References i, and utf8_next().
Referenced by _Redraw().
Definition at line 412 of file testime.c.
References i.
Referenced by _Redraw().
size_t utf8_length | ( | unsigned char | c | ) |
char* utf8_next | ( | char * | p | ) |
Definition at line 386 of file testime.c.
References i, and utf8_length().
Referenced by utf8_advance().
|
static |
Definition at line 47 of file testime.c.
Referenced by _Redraw(), InitInput(), and main().
|
static |
|
static |
Definition at line 47 of file testime.c.
Referenced by SDL_BApp::_HandleKey(), _Redraw(), clipboard_testClipboardTextFunctions(), clipboard_testSetClipboardText(), InitInput(), main(), SDL_GetClipboardText(), SDL_LogOutput(), SDL_memset4(), SDL_PrintFloat(), SDL_ScanFloat(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_sscanf(), SDL_vsnprintf(), SDL_vsscanf(), SDLTest_CommonEvent(), SDLTest_CommonInit(), SDLTest_PrintRenderer(), stdlib_getsetenv(), stdlib_snprintf(), and stdlib_strlcpy().
|
static |
Definition at line 43 of file testime.c.
Referenced by _Redraw(), and InitInput().
struct UnifontGlyph * unifontGlyph |
Referenced by unifont_cleanup(), unifont_draw_glyph(), unifont_init(), and unifont_load_texture().
|
static |
|
static |
Definition at line 67 of file testime.c.
Referenced by unifont_cleanup(), unifont_draw_glyph(), and unifont_load_texture().