From 329ff7c06cb4bc9bcc439d5d4ff0c0b532fda97b Mon Sep 17 00:00:00 2001 From: unodgs Date: Sun, 3 Jul 2011 19:32:27 +0000 Subject: [PATCH] Rainbow: WinGL.. git-svn-id: svn://ultimatepp.org/upp/trunk@3603 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/WinGl/After.h | 28 ++-------------------------- rainbow/WinGl/Win.cpp | 26 +++++++++++++++++++++++++- rainbow/WinGl/WinGl.h | 1 + rainbow/WinGl/Wnd.cpp | 11 +++-------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/rainbow/WinGl/After.h b/rainbow/WinGl/After.h index ce764d682..fbf5fc967 100644 --- a/rainbow/WinGl/After.h +++ b/rainbow/WinGl/After.h @@ -3,8 +3,6 @@ class ViewDraw : public SystemDraw { ImageBuffer ib; - - Vector dummy_invalid; public: ViewDraw(Ctrl *ctrl) {} @@ -13,36 +11,14 @@ public: class DHCtrl : Ctrl {}; -void InitGl(); - -Vector& coreCmdLine__(); -Vector SplitCmdLine__(const char *cmd); - -int GlInit(HINSTANCE hInstance); +int AppMain(HINSTANCE hInstance, LPSTR lpCmdLine); #define GUI_APP_MAIN \ -void GuiMainFn_();\ -\ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) \ -{ \ - UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); \ - UPP::AppInitEnvironment__(); \ - int r = UPP::GlInit(hInstance); \ - if(r > 0) { \ - GuiMainFn_(); \ - UPP::Ctrl::CloseTopCtrls(); \ - UPP::UsrLog("---------- About to delete this log of WinGL..."); \ - UPP::DeleteUsrLog(); \ - return UPP::GetExitCode(); \ - } else { \ - Exclamation(Format("OpenGL window could not be initialized: %d", r)); \ - return r; \ - }\ -} \ +{ return UPP::AppMain(hInstance, lpCmdLine); } \ \ void GuiMainFn_() - void SetDesktop(Ctrl& desktop); Ctrl *GetDesktop(); diff --git a/rainbow/WinGl/Win.cpp b/rainbow/WinGl/Win.cpp index 3a0959f7c..01c06c2ab 100644 --- a/rainbow/WinGl/Win.cpp +++ b/rainbow/WinGl/Win.cpp @@ -1,6 +1,8 @@ #include #ifdef GUI_WINGL +extern void GuiMainFn_(); + NAMESPACE_UPP @@ -131,13 +133,35 @@ int GlInit(HINSTANCE hInstance) } //InitializeShaders(); - //wglSwapIntervalEXT(0); + wglSwapIntervalEXT(0); //SetTimeCallback(-10, THISBACK(Repaint), 1); SetTimer(glHWND, 1, 10, NULL); return 1; } +Vector& coreCmdLine__(); +Vector SplitCmdLine__(const char *cmd); + +int AppMain(HINSTANCE hInstance, LPSTR lpCmdLine) +{ + UPP::coreCmdLine__() = UPP::SplitCmdLine__(UPP::FromSystemCharset(lpCmdLine)); + UPP::AppInitEnvironment__(); + int r = UPP::GlInit(hInstance); + if(r > 0) + { + GuiMainFn_(); + UPP::Ctrl::CloseTopCtrls(); + UPP::UsrLog("---------- About to delete this log of WinGL..."); + UPP::DeleteUsrLog(); + UPP::DestroyGL(); + return UPP::GetExitCode(); + } else { + ::MessageBox(NULL, Format("OpenGL window could not be initialized: %d", r), NULL, MB_ICONEXCLAMATION | MB_OK); + return r; + } +} + END_UPP_NAMESPACE #endif \ No newline at end of file diff --git a/rainbow/WinGl/WinGl.h b/rainbow/WinGl/WinGl.h index 6a12b1713..4d6d05f84 100644 --- a/rainbow/WinGl/WinGl.h +++ b/rainbow/WinGl/WinGl.h @@ -20,6 +20,7 @@ extern HDC hDC; extern HGLRC hRC; void ActivateGLContext(); +void DestroyGL(); LRESULT CALLBACK glWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); #define GUI_FB diff --git a/rainbow/WinGl/Wnd.cpp b/rainbow/WinGl/Wnd.cpp index ada64ffc3..7c04524bd 100644 --- a/rainbow/WinGl/Wnd.cpp +++ b/rainbow/WinGl/Wnd.cpp @@ -28,9 +28,9 @@ void Ctrl::SetDesktop(Ctrl& q) void Ctrl::SetWindowSize(Size sz) { - //if(desktop) - // desktop->SetRect(sz); screenRect = sz; + if(desktop) + desktop->SetRect(screenRect); } void Ctrl::InitGl() @@ -163,6 +163,7 @@ bool Ctrl::ProcessEvents(bool *quit) //ApplyTransform(TS_AFTER_PAINT); SwapBuffers(hDC); painting = false; + LOGF("Fps %.2f\n", GetFps()); } CursorSync(); return false; @@ -214,12 +215,6 @@ void Ctrl::GuiSleep0(int ms) EnterGMutex(level); } -Rect Ctrl::GetWndUpdateRect() const -{ - GuiLock __; - return screenRect; -} - Rect Ctrl::GetWndScreenRect() const { GuiLock __;