examples/renderer/19-affine-textures: Whole source file was indented one space.
This commit is contained in:
@@ -1,29 +1,29 @@
|
|||||||
/* affine-textures.c ... */
|
/* affine-textures.c ... */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This example creates an SDL window and renderer, and then draws a cube
|
* This example creates an SDL window and renderer, and then draws a cube
|
||||||
* using affine-transformed textures every frame.
|
* using affine-transformed textures every frame.
|
||||||
*
|
*
|
||||||
* This code is public domain. Feel free to use it for any purpose!
|
* This code is public domain. Feel free to use it for any purpose!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
|
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <SDL3/SDL_main.h>
|
#include <SDL3/SDL_main.h>
|
||||||
|
|
||||||
/* We will use this renderer to draw into this window every frame. */
|
/* We will use this renderer to draw into this window every frame. */
|
||||||
static SDL_Window *window = NULL;
|
static SDL_Window *window = NULL;
|
||||||
static SDL_Renderer *renderer = NULL;
|
static SDL_Renderer *renderer = NULL;
|
||||||
static SDL_Texture *texture = NULL;
|
static SDL_Texture *texture = NULL;
|
||||||
static int texture_width = 0;
|
static int texture_width = 0;
|
||||||
static int texture_height = 0;
|
static int texture_height = 0;
|
||||||
|
|
||||||
#define WINDOW_WIDTH 640
|
#define WINDOW_WIDTH 640
|
||||||
#define WINDOW_HEIGHT 480
|
#define WINDOW_HEIGHT 480
|
||||||
|
|
||||||
/* This function runs once at startup. */
|
/* This function runs once at startup. */
|
||||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = NULL;
|
SDL_Surface *surface = NULL;
|
||||||
char *bmp_path = NULL;
|
char *bmp_path = NULL;
|
||||||
|
|
||||||
@@ -66,19 +66,20 @@
|
|||||||
SDL_DestroySurface(surface); /* done with this, the texture has a copy of the pixels now. */
|
SDL_DestroySurface(surface); /* done with this, the texture has a copy of the pixels now. */
|
||||||
|
|
||||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
|
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
|
||||||
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||||
{
|
{
|
||||||
if (event->type == SDL_EVENT_QUIT) {
|
if (event->type == SDL_EVENT_QUIT) {
|
||||||
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
|
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
|
||||||
}
|
}
|
||||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function runs once per frame, and is the heart of the program. */
|
/* This function runs once per frame, and is the heart of the program. */
|
||||||
SDL_AppResult SDL_AppIterate(void *appstate) {
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||||
|
{
|
||||||
const float x0 = 0.5f * WINDOW_WIDTH;
|
const float x0 = 0.5f * WINDOW_WIDTH;
|
||||||
const float y0 = 0.5f * WINDOW_HEIGHT;
|
const float y0 = 0.5f * WINDOW_HEIGHT;
|
||||||
const float px = SDL_min(WINDOW_WIDTH, WINDOW_HEIGHT) / SDL_sqrtf(3.0f);
|
const float px = SDL_min(WINDOW_WIDTH, WINDOW_HEIGHT) / SDL_sqrtf(3.0f);
|
||||||
@@ -131,12 +132,12 @@
|
|||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
return SDL_APP_CONTINUE;
|
return SDL_APP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function runs once at shutdown. */
|
/* This function runs once at shutdown. */
|
||||||
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
/* SDL will clean up the window/renderer for us. */
|
/* SDL will clean up the window/renderer for us. */
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user