#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
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.
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.
@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?).
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 ;)
@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
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
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?
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.
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