Discussion:
have to use task manager to abort program
(too old to reply)
speartip
2017-03-15 13:46:09 UTC
Permalink
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;

}
Mason Wheeler
2017-03-15 15:23:57 UTC
Permalink
The code looks pretty straightforward.  There are three reasons why it might not be quitting for you.
1) Most likely: you're never getting the SDL_QUIT event.2) SDL_DestroyRenderer is never returning for some reason.
3) SDL_DestroyWindow is never returning for some reason.
Probably #1 though.  Have you tried running it under a debugger to check on what's happening?
Mason

From: speartip <***@fastmail.com>
To: ***@lists.libsdl.org
Sent: Wednesday, March 15, 2017 9:46 AM
Subject: [SDL] have to use task manager to abort program

<!--#yiv7895684575 #yiv7895684575 #yiv7895684575 body {font-size:11;}#yiv7895684575 #yiv7895684575 font, #yiv7895684575 th, #yiv7895684575 td, #yiv7895684575 p {}#yiv7895684575 p, #yiv7895684575 td {font-size:11;}#yiv7895684575 a:link, #yiv7895684575 a:active, #yiv7895684575 a:visited {}#yiv7895684575 a:hover {text-decoration:underline;}#yiv7895684575 hr {height:0px;border:solid 0px;border-top-width:1px;}#yiv7895684575 h1, #yiv7895684575 h2 {font-family:"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;font-size:22px;font-weight:bold;text-decoration:none;line-height:120%;color:#000000;}#yiv7895684575 #yiv7895684575 .yiv7895684575bodyline {border:1px solid;}#yiv7895684575 #yiv7895684575 .yiv7895684575gen {font-size:12px;}#yiv7895684575 .yiv7895684575genmed {font-size:11px;}#yiv7895684575 .yiv7895684575gensmall {font-size:10px;line-height:12px;}#yiv7895684575 .yiv7895684575gen, #yiv7895684575 .yiv7895684575genmed, #yiv7895684575 .yiv7895684575gensmall {}#yiv7895684575 a.yiv7895684575gen, #yiv7895684575 a.yiv7895684575genmed, #yiv7895684575 a.yiv7895684575gensmall {text-decoration:none;}#yiv7895684575 a.yiv7895684575gen:hover, #yiv7895684575 a.yiv7895684575genmed:hover, #yiv7895684575 a.yiv7895684575gensmall:hover {text-decoration:underline;}#yiv7895684575 #yiv7895684575 .yiv7895684575forumlink {font-weight:bold;font-size:12px;}#yiv7895684575 a.yiv7895684575forumlink {text-decoration:none;}#yiv7895684575 a.yiv7895684575forumlink:hover{text-decoration:underline;}#yiv7895684575 #yiv7895684575 .yiv7895684575postbody {font-size:12px;line-height:18px;}#yiv7895684575 a.yiv7895684575postlink:link {text-decoration:none;}#yiv7895684575 a.yiv7895684575postlink:visited {text-decoration:none;}#yiv7895684575 a.yiv7895684575postlink:hover {text-decoration:underline;}#yiv7895684575 #yiv7895684575 .yiv7895684575code {font-size:11px;color:#3FB753;border-style:solid;border-left-width:1px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;}#yiv7895684575 .yiv7895684575quote {font-size:11px;color:#444444;line-height:125%;border-style:solid;border-left-width:1px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;}--> 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
#include
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;

} |

_______________________________________________
SDL mailing list
***@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Clangray
2017-03-15 16:44:21 UTC
Permalink
I made done= SDL_True put in a delay and it worked well, thanks. Also,
there is no border which is great. I think its because of my chosen
resolution. Is there any was to actually turn it off? Murphy's Law.


--

Gray Family
The code looks pretty straightforward. There are three reasons why it
might not be quitting for you.
1) Most likely: you're never getting the SDL_QUIT event.
2) SDL_DestroyRenderer is never returning for some reason.
3) SDL_DestroyWindow is never returning for some reason.
Probably #1 though. Have you tried running it under a debugger to
check on what's happening?
Mason
**Subject:** [SDL] have to use task manager to abort program
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
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.
#include
#include
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;
}
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_________________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
capehill
2017-03-16 18:26:55 UTC
Permalink
Run it with a debugger or add some prints inside the loops.

Continue reading on narkive:
Loading...