mirror of https://github.com/encounter/SDL.git
iOS: Restored older version of rectangles demo.
The demo did not draw rectangles like described in the demo README.
This commit is contained in:
parent
16c479f332
commit
5fa0cbc4ba
|
@ -37,45 +37,50 @@ render(SDL_Renderer *renderer)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (SDL_Init(SDL_INIT_VIDEO/* | SDL_INIT_AUDIO */) < 0)
|
|
||||||
{
|
SDL_Window *window;
|
||||||
printf("Unable to initialize SDL");
|
SDL_Renderer *renderer;
|
||||||
|
int done;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
/* initialize SDL */
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
fatalError("Could not initialize SDL");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
|
/* seed random number generator */
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
srand(time(NULL));
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
||||||
|
/* create window and renderer */
|
||||||
int landscape = 1;
|
window =
|
||||||
int modes = SDL_GetNumDisplayModes(0);
|
SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||||
int sx = 0, sy = 0;
|
SDL_WINDOW_SHOWN);
|
||||||
for (int i = 0; i < modes; i++)
|
if (window == 0) {
|
||||||
{
|
fatalError("Could not initialize Window");
|
||||||
SDL_DisplayMode mode;
|
}
|
||||||
SDL_GetDisplayMode(0, i, &mode);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
if (landscape ? mode.w > sx : mode.h > sy)
|
if (!renderer) {
|
||||||
{
|
fatalError("Could not create renderer");
|
||||||
sx = mode.w;
|
}
|
||||||
sy = mode.h;
|
|
||||||
|
/* Fill screen with black */
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
/* Enter render loop, waiting for user to quit */
|
||||||
|
done = 0;
|
||||||
|
while (!done) {
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
if (event.type == SDL_QUIT) {
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
render(renderer);
|
||||||
|
SDL_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("picked: %d %d\n", sx, sy);
|
/* shutdown SDL */
|
||||||
|
SDL_Quit();
|
||||||
SDL_Window *_sdl_window = NULL;
|
|
||||||
SDL_GLContext _sdl_context = NULL;
|
|
||||||
|
|
||||||
_sdl_window = SDL_CreateWindow("fred",
|
|
||||||
0, 0,
|
|
||||||
sx, sy,
|
|
||||||
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
|
|
||||||
|
|
||||||
SDL_SetHint("SDL_HINT_ORIENTATIONS", "LandscapeLeft LandscapeRight");
|
|
||||||
|
|
||||||
int ax = 0, ay = 0;
|
|
||||||
SDL_GetWindowSize(_sdl_window, &ax, &ay);
|
|
||||||
|
|
||||||
printf("given: %d %d\n", ax, ay);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue