-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSDL.cpp
116 lines (64 loc) · 1.82 KB
/
SDL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SDL.cpp : Este archivo contiene la función "main". La ejecución del programa comienza y termina ahí.
//
#include "SDL.h"
#include "SDL_image.h"
#include "utils.h"
#include <stdio.h>
#include <string>
#include "CRotozoom.h"
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_PixelFormat *fmt;
SDL_Window * window = SDL_CreateWindow("",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_RESIZABLE);
SDL_Surface * screen = SDL_GetWindowSurface(window);
fmt = screen->format;
const char* surfacePixelFormatName = SDL_GetPixelFormatName(screen->format->format);
int width = screen->w;
int height = screen->h;
SDL_Surface *buffer = SDL_CreateRGBSurface(0, width, height, 32,
0, 0, 0, 0);
SDL_Surface *texture = SDL_CreateRGBSurface(0, 64, 64, 32,
0, 0, 0, 0);
int imgFlags = IMG_INIT_PNG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
const char *s = IMG_GetError();
printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
}
texture = loadSurface("textura.png", texture);
CRotozoom rotozoom;
rotozoom.Init(texture);
float t = 0;
while (1)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT) exit(0);
if (event.type == SDL_WINDOWEVENT)
{
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{
screen = SDL_GetWindowSurface(window);
//pixels = (unsigned int *)screen->pixels;
width = screen->w;
height = screen->h;
buffer = SDL_CreateRGBSurface(0, width, height, 32,
0, 0, 0, 0);
}
}
if (event.type == SDL_MOUSEMOTION)
{
}
}
// SDL_BlitSurface(buffer, NULL, bufferLens, NULL);
rotozoom.Update(0, buffer);
SDL_BlitSurface(buffer, NULL, screen, NULL);
SDL_UpdateWindowSurface(window);
t = t + 1;
}
}