SDL Forum Index
SDL
Simple DirectMedia Layer Forums
Reply to topic
have to use task manager to abort program
speartip


Joined: 06 Feb 2017
Posts: 27
Reply with quote
What am I doing wrong here? This is lifted code. When the program runs it produces a black screen with a geometric pattern which is fine. But it sticks, it can only abort with task manager:
Second, it has no border (which is what I want) but I would like to be able to toggle that rather than just watch it disappear b/c I use use 1920 x 1080 res.


Code:
#include<iostream>
#include<SDL.h>
using namespace std;

int main(int argc, char* argv[])
{
   if (SDL_Init(SDL_INIT_VIDEO) == 0) {
           SDL_Window* window = NULL;
           SDL_Renderer* renderer = NULL;

           if (SDL_CreateWindowAndRenderer(1920, 1080, 0, &window, &renderer) == 0) {
               SDL_bool done = SDL_FALSE;

               while (!done) {
                   SDL_Event event;

                   SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
                   SDL_RenderClear(renderer);

                   SDL_SetRenderDrawColor(renderer, 0, 0, 255, SDL_ALPHA_OPAQUE);
                   SDL_RenderDrawLine(renderer, 320, 200, 300, 240);
                   SDL_RenderDrawLine(renderer, 300, 240, 340, 240);
                   SDL_RenderDrawLine(renderer, 340, 240, 320, 200);
                   SDL_RenderPresent(renderer);

                   while (SDL_PollEvent(&event)) {
                       if (event.type == SDL_QUIT) {
                           done = SDL_TRUE;
                       }
                   }
               }
           }

           if (renderer) {
               SDL_DestroyRenderer(renderer);
           }
           if (window) {
               SDL_DestroyWindow(window);
           }
       }
       SDL_Quit();
        return 0;

}
View user's profileSend private message
capehill


Joined: 13 Feb 2016
Posts: 15
Reply with quote
Run it with a debugger or add some prints inside the loops.
View user's profileSend private message
have to use task manager to abort program
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic