3D Viewport resizing added. (Resizes very smooth!)
This commit is contained in:
37
main.cpp
37
main.cpp
@@ -96,6 +96,7 @@ class Demo : public GApp {
|
||||
SkyRef sky;
|
||||
bool quit;
|
||||
void main();
|
||||
|
||||
};
|
||||
|
||||
class App : public GApp {
|
||||
@@ -1453,7 +1454,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
app->QuitApp();
|
||||
break;
|
||||
case WM_SIZE:
|
||||
|
||||
{
|
||||
int winWidth = LOWORD(lParam);
|
||||
int winHeight = HIWORD(lParam);
|
||||
app->renderDevice->notifyResize(winWidth,winHeight);
|
||||
Rect2D viewportRect = Rect2D::xywh(0,0,winWidth,winHeight);
|
||||
app->renderDevice->setViewport(viewportRect);
|
||||
app->onGraphics(app->renderDevice);
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
|
||||
@@ -1466,7 +1474,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Demo::main() {
|
||||
setDebugMode(true);
|
||||
debugController.setActive(false);
|
||||
@@ -1475,8 +1482,6 @@ void Demo::main() {
|
||||
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
||||
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
||||
//run();
|
||||
|
||||
|
||||
RealTime now, lastTime;
|
||||
double simTimeRate = 1.0f;
|
||||
@@ -1485,13 +1490,18 @@ void Demo::main() {
|
||||
RealTime desiredFrameDuration=1.0/fps;
|
||||
onInit();
|
||||
RealTime lastWaitTime;
|
||||
//GWindow* wind = window();
|
||||
|
||||
//wind->
|
||||
MSG messages; /* Here messages to the application are saved */
|
||||
MSG messages;
|
||||
RECT cRect;
|
||||
GetClientRect(hWndMain,&cRect);
|
||||
|
||||
renderDevice->notifyResize(cRect.right,cRect.bottom);
|
||||
Rect2D viewportRect = Rect2D::xywh(0,0,cRect.right,cRect.bottom);
|
||||
renderDevice->setViewport(viewportRect);
|
||||
|
||||
while (!quit)
|
||||
{
|
||||
|
||||
lastTime = now;
|
||||
now = System::getTick();
|
||||
RealTime timeStep = now - lastTime;
|
||||
@@ -1513,12 +1523,12 @@ void Demo::main() {
|
||||
|
||||
onSimulation(rdt,sdt,idt);
|
||||
m_simulationWatch.tock();
|
||||
|
||||
m_waitWatch.tick();
|
||||
{
|
||||
RealTime now = System::time();
|
||||
// Compute accumulated time
|
||||
System::sleep(max(0.0, desiredFrameDuration - (now - lastWaitTime)));
|
||||
//onWait(now - lastWaitTime, desiredFrameDuration);
|
||||
lastWaitTime = System::time();
|
||||
}
|
||||
m_waitWatch.tock();
|
||||
@@ -1535,18 +1545,13 @@ void Demo::main() {
|
||||
|
||||
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE))
|
||||
{
|
||||
|
||||
if (IsDialogMessage(hWndMain, &messages) == 0)
|
||||
{
|
||||
/* Translate virtual-key messages into character messages */
|
||||
TranslateMessage(&messages);
|
||||
/* Send message to WindowProcedure */
|
||||
DispatchMessage(&messages);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Demo::QuitApp()
|
||||
@@ -1569,10 +1574,6 @@ int main(int argc, char** argv) {
|
||||
settings.writeLicenseFile = false;
|
||||
settings.logFilename = tempPath + "/g3dlog.txt";
|
||||
settings.window.center = true;
|
||||
//G3D::SDLWindow* wnd = new SDLWindow(settings.window);
|
||||
//wnd->setMouseVisible(false);
|
||||
|
||||
|
||||
|
||||
WNDCLASSEX wc;
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
@@ -1617,6 +1618,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
Win32Window* win32Window = Win32Window::create(settings.window,hwndMain);
|
||||
Demo demo = Demo(settings,win32Window);
|
||||
|
||||
SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo);
|
||||
demo.run();
|
||||
}
|
||||
catch(...)
|
||||
|
||||
Reference in New Issue
Block a user