Switch to renderer
This commit is contained in:
parent
b0030425a4
commit
868922c68e
18
main.cpp
18
main.cpp
@ -42,14 +42,15 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
SDL_Renderer* renderer =
|
||||
SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
SDL_SetRenderDrawColor(renderer, 130, 163, 255, 1);
|
||||
|
||||
|
||||
SDL_Surface* imageSurface = IMG_Load("font.png");
|
||||
if (imageSurface == NULL) {
|
||||
SDL_Surface* fontSurface = IMG_Load("font.png");
|
||||
if (fontSurface == NULL) {
|
||||
cout << "Could not find spritesheet" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Texture* fontTexture = SDL_CreateTextureFromSurface(renderer, fontSurface);
|
||||
// SDL_Surface* screenSurface = NULL;
|
||||
// //Get window surface
|
||||
// screenSurface = SDL_GetWindowSurface( window );
|
||||
@ -96,24 +97,27 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
dstrect.x = SCREEN_WIDTH/2 - 40;
|
||||
dstrect.y = SCREEN_HEIGHT/2 - 40;
|
||||
dstrect.w = 10;
|
||||
dstrect.h = 10;
|
||||
dstrect.w = 100;
|
||||
dstrect.h = 100;
|
||||
|
||||
// SDL_BlitSurface(imageSurface, &srcrect, screenSurface, &dstrect);
|
||||
|
||||
//Update the surface
|
||||
// SDL_UpdateWindowSurface( window );
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 130, 163, 255, 1);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
SDL_RenderCopy(renderer, fontTexture, &srcrect, &dstrect);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
|
||||
//Hack to get window to stay up
|
||||
// SDL_FreeSurface(screenSurface);
|
||||
SDL_FreeSurface(imageSurface);
|
||||
SDL_FreeSurface(fontSurface);
|
||||
SDL_DestroyTexture(fontTexture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow( window );
|
||||
|
||||
//Quit SDL subsystems
|
||||
|
Loading…
x
Reference in New Issue
Block a user