what my loop stops working??

Pages: 12
when i hold and dragged the window for some purpose my loop stops. here is an example output:

40
40
40
40
40
40
40
40
40
1316
40
40
40


output 1316 is the part i hold and dragged my window
and here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <iostream>

//***declaration of our event***
SDL_Event       Event;
//***quit value if the user wants to quit the
//value will be true and our loop will end***
bool            quit        = false;
//***here we declare our window***
SDL_Window*     Window      = NULL;
//***declaring the datas that will store the
//mouse x and y position***
int             mousePosX= 0, mousePosY = 0;
//***here we store time data***
Uint32          timePassed = NULL, prevTime = NULL, nextTime = NULL;
//***declaration of a second we need to
//store it for our loop***
int             aSec        = 1000;
int             fps         = 25;


//***main function
int main ( int argc, char** argv )
{
    //***here we create our window and it properties
    Window = SDL_CreateWindow("Test G_Engine",
                                          SDL_WINDOWPOS_UNDEFINED,
                                          SDL_WINDOWPOS_UNDEFINED,
                                          640, 480,
                                          SDL_WINDOW_SHOWN
                                          );

    //***here begins the menu loop***
    //***but before we begin we have to get
    //the time to use it when needed***

    prevTime = SDL_GetTicks();
    while(quit == false)
    {
        //***here we have event loop***
        while(SDL_PollEvent(&Event))
        {
            //***our event inquiry***
            switch(Event.type){
                //***if user clicks on windows exit button***
                case SDL_QUIT:
                    quit = true;
                //***if user presses any key***
                case SDL_KEYDOWN:
                    switch(Event.key.keysym.sym)
                    {
                        case SDLK_ESCAPE:
                            quit = true;
                            break;
                    }
                //***if we want to take pos of mouse when clicked***
                case SDL_MOUSEBUTTONDOWN:
                    mousePosX = Event.button.x;
                    mousePosY = Event.button.y;
            }
        }
        //updateGame();
        //***we r checking if enough time has passed***
        nextTime = SDL_GetTicks();
        timePassed = nextTime - prevTime;
        if(timePassed >= aSec / fps)
        {
            //***if passed we should update the screen according to values***
            //***also we should update storedTime before updateScreen
            //because updateScreen is a anti computer source function***
            prevTime = SDL_GetTicks();
            std::cout << timePassed << std::endl;
            //updateScreen();
        }
    }


    SDL_DestroyWindow(Window);
    SDL_Quit();

    return 0;
}


NOT: i googled it but couldnt found (maybe used wrong key words dont know)
dont say first google pls :D
Last edited on
This is a Windows thing, you can't control it without drawing your own window rather than drawing inside of the window that Windows gives you. When you click and hold on the title bar to start dragging, it pauses the redraw. This is not related to the pause when resizing the window, which can be disabled.
thx for the reply. i will search for it
Not even production quality games like Portal 2 get around it, I think it's an issue you cannot resolve.
Source engine is quite old.
Also, I've seen games actually being able to do it.
Or, also see Steam's interface: It's automatically updated when you drag a window.
well maybe i should go for it and find a way but it is much for me for now i will just use SDL_WINDOW_BORDERLESS
EssGeEich wrote:
Or, also see Steam's interface: It's automatically updated when you drag a window.
Steam draws its own window and controls its own dragging. The issue in question is when WIndows draws the window and controls dragging.

Also, @Caset, don't do that - it will annoy people. It is really such a severe problem??
@LB: Steam uses SDL (SDL.dll v2 in the Steam's install dir)
Also on Windows 7 with aero peek enabled, you can see the window without the shadow, which means it may be windows to draw them, as it's windows who knows what is shadow and what is not.
Also chrome does the same thing (Probably firefox too, and IExplorer?).
EssGeEich never at any one time did I say this had anything to do with SDL.
Oh well you didn't in an explicit way, but when you said "Steam draws its own window" I thought by drawing you meant "drawing to the desktop" as a layered window.
I meant that it doesn't use the Windows window border and instead inside its client area draws its own title bar and minimize/maximize/close buttons and controls its own dragging ;)
Does Windows still draw the dropped shadow on its own?
No, the shadow is a different length than the one Windows draws.
@L B
i would like not to use SDL_WINDOW_BORDERLESS. but since i m new i should have more practice and move step by step. hey just a month before i was watching bucky's tutorial videos. and if i make my own (noob)window which has its own close minimize and such buttons and hold&drag ability it will still work right.

also i dont think i will be able to create a good one. but i m just doing it for experience. so no problem
I want to know why you so desperately want to prevent the pause when they click on the window border? This is something you should not worry about ;)
well i want to learn better programming so i was trying to make a game loop example. which uses frames. and if my loop stops also game will stop which means my game sucks doesnt it. so i decided to fix it. thats all

srry if i m wrong about "means my game sucks"
Last edited on
Well, in fact I think a software is suckyish if it doesn't update while I resize its window.
But keep in mind it's a Game.
I don't really mind for Games. If it's a software planned to be used daily, then that's good.
But for game, that's just an optional.
I suggest you to keep your game in a fixed-resolution-ish way (Like, you can only change resolution from the Options screen).

This was my Videogame-player nutshell.
About the programmer nutshell...
I'd be going with a 32bit layered window (by the looks of it, that's how Steam does it?), but this is going to break all portability ideas.
But the Raspberry PI isn't going to be running this game, is it?
Ceset wrote:
well i want to learn better programming so i was trying to make a game loop example. which uses frames. and if my loop stops also game will stop which means my game sucks doesnt it. so i decided to fix it. thats all

srry if i m wrong about "means my game sucks"
Yes, you are wrong about "your game sucks" if the only problem is a bug in the operating system that doesn't have much of an effect if any on gameplay.
@EssGeEich thx for infos

@L B well i got a question then.

what happens if your game is multi and one of the players loop stops when he dragged his window and this might cause some unwanted situations right??

so shouldnt i disable windows thingy (dont know its english name) and make it like @EssGeEich said, all changes in an option menu.

EDIT: it shouldnt be a problem but i dont think gamers would like it.

example: i was playing CS source with my brother. and when i was detonating the bomb, which is an important thing in game, my game lagged and caused the detonate time to delay, even though the game time didnt.
note: it could cause me losing the round
Last edited on
@Ceset: Well, if you wanted to resize the game, it means you wasn't actively playing but was idle/waiting for the round to restart (as happens on CS)

Also what LB meant, isn't to force window to be resizeable, but it is to still KEEP its border while disallowing resizing.

( Remove SDL_WINDOW_RESIZABLE and you're ok with the solution we're talking about, basically the CS-ish solution )
Pages: 12