Created
July 24, 2018 19:06
-
-
Save hayleyxyz/0e57e586415899afc1c58cbd861cf7ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <SDL.h> | |
void draw(SDL_Window * window, SDL_Renderer * renderer) { | |
int w, h; | |
SDL_GetWindowSize(window, &w, &h); | |
for (int y = 0; y < h; ++y) { | |
for (int x = 0; x < w; ++x) { | |
//srand(x * y); | |
auto clr = rand(); | |
SDL_SetRenderDrawColor(renderer, (clr >> 16) & 0xff, (clr >> 8) & 0xff, (clr >> 0) & 0xff, 255); | |
SDL_Rect rect; | |
rect.x = x; | |
rect.y = y; | |
rect.w = 1; | |
rect.h = 1; | |
//SDL_RenderDrawRect(renderer, &rect); | |
SDL_RenderFillRect(renderer, &rect); | |
} | |
} | |
SDL_RenderPresent(renderer); | |
} | |
int main() { | |
std::cout << "Hello, World!" << std::endl; | |
SDL_Init(SDL_INIT_EVERYTHING); | |
auto window = ::SDL_CreateWindow("yuigame", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, ::SDL_WINDOW_ALLOW_HIGHDPI); | |
auto renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); | |
float ddpi, hdpi, vdpi; | |
auto num = SDL_GetNumVideoDisplays(); | |
auto result = SDL_GetDisplayDPI(0, &ddpi, &hdpi, &vdpi); | |
//SDL_RenderDrawRect(renderer, &rect); | |
//asm("int $3"); | |
while(true) { | |
SDL_Event event; | |
SDL_PollEvent(&event); | |
if(event.type == SDL_QUIT) { | |
break; | |
} | |
draw(window, renderer); | |
} | |
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment