From 6c27fa17a6072baefec9462354a2f6152c02d015 Mon Sep 17 00:00:00 2001 From: VB Date: Sat, 11 Feb 2017 22:52:20 +0100 Subject: [PATCH] glfw --- Camera.cpp | 26 +- Console.cpp | 14 +- EU07.cpp | 750 +++++++------------------------------ Globals.cpp | 191 ++++------ Globals.h | 5 +- Ground.cpp | 25 +- Ground.h | 2 +- Texture.cpp | 2 +- Train.cpp | 122 +++--- World.cpp | 228 +++++------ World.h | 5 +- maszyna.sln | 13 +- maszyna.vcxproj | 80 +++- maszyna.vcxproj.filters | 9 - maszyna.vcxproj.user | 9 + opengl/ARB_Multisample.cpp | 120 ------ opengl/ARB_Multisample.h | 25 -- stdafx.h | 6 + 18 files changed, 516 insertions(+), 1116 deletions(-) delete mode 100644 opengl/ARB_Multisample.cpp delete mode 100644 opengl/ARB_Multisample.h diff --git a/Camera.cpp b/Camera.cpp index 4c20b7e5..1c57d303 100644 --- a/Camera.cpp +++ b/Camera.cpp @@ -61,8 +61,8 @@ void TCamera::OnCursorMove(double x, double y) void TCamera::Update() { // ABu: zmiana i uniezaleznienie predkosci od FPS - double a = (Console::Pressed(VK_SHIFT) ? 5.00 : 1.00); - if (Console::Pressed(VK_CONTROL)) + double a = (Global::shiftState ? 5.00 : 1.00); + if (Global::ctrlState) a = a * 100; // OldVelocity=Velocity; if (FreeFlyModeFlag == true) @@ -86,27 +86,27 @@ void TCamera::Update() if (Console::Pressed(VkKeyScan('s'))) Velocity.z+= a*Timer::GetDeltaTime(); - if (Console::Pressed(VK_NUMPAD4) || Console::Pressed(VK_NUMPAD7) || - Console::Pressed(VK_NUMPAD1)) + if (Console::Pressed(GLFW_KEY_KP_4) || Console::Pressed(GLFW_KEY_KP_7) || + Console::Pressed(GLFW_KEY_KP_1)) Yaw+= +1*M_PI*Timer::GetDeltaTime(); - if (Console::Pressed(VK_NUMPAD6) || Console::Pressed(VK_NUMPAD9) || - Console::Pressed(VK_NUMPAD3)) + if (Console::Pressed(GLFW_KEY_KP_6) || Console::Pressed(GLFW_KEY_KP_9) || + Console::Pressed(GLFW_KEY_KP_3)) Yaw+= -1*M_PI*Timer::GetDeltaTime(); - if (Pressed(VK_NUMPAD2) || Console::Pressed(VK_NUMPAD1) || - Console::Pressed(VK_NUMPAD3)) + if (Pressed(GLFW_KEY_KP_2) || Console::Pressed(GLFW_KEY_KP_1) || + Console::Pressed(GLFW_KEY_KP_3)) Pitch+= -1*M_PI*Timer::GetDeltaTime(); - if (Console::Pressed(VK_NUMPAD8) || Console::Pressed(VK_NUMPAD7) || - Console::Pressed(VK_NUMPAD9)) + if (Console::Pressed(GLFW_KEY_KP_8) || Console::Pressed(GLFW_KEY_KP_7) || + Console::Pressed(GLFW_KEY_KP_9)) Pitch+= +1*M_PI*Timer::GetDeltaTime(); if (Console::Pressed(VkKeyScan('.'))) Roll+= -1*M_PI*Timer::GetDeltaTime(); if (Console::Pressed(VkKeyScan(','))) Roll+= +1*M_PI*Timer::GetDeltaTime(); - if (Console::Pressed(VK_NUMPAD5)) + if (Console::Pressed(GLFW_KEY_KP_5)) Pitch=Roll= 0.0f; */ @@ -120,8 +120,8 @@ void TCamera::Update() if (Console::Pressed(Global::Keys[k_MechBackward])) Velocity.z += a; // gora-dol - // if (Console::Pressed(VK_NUMPAD9)) Pos.y+=0.1; - // if (Console::Pressed(VK_NUMPAD3)) Pos.y-=0.1; + // if (Console::Pressed(GLFW_KEY_KP_9)) Pos.y+=0.1; + // if (Console::Pressed(GLFW_KEY_KP_3)) Pos.y-=0.1; // McZapkie: zeby nie hustalo przy malym FPS: // Velocity= (Velocity+OldVelocity)/2; diff --git a/Console.cpp b/Console.cpp index 9943c924..4ae7272d 100644 --- a/Console.cpp +++ b/Console.cpp @@ -252,8 +252,8 @@ void Console::BitsUpdate(int mask) SetLedState(VK_CAPITAL, iBits & 2); if (mask & 1) // gdy SHP { // Scroll Lock ma jakoś dziwnie... zmiana stanu na przeciwny - SetLedState(VK_SCROLL, true); // przyciśnięty - SetLedState(VK_SCROLL, false); // zwolniony + SetLedState(VK_CAPITAL, true); // przyciśnięty + SetLedState(VK_CAPITAL, false); // zwolniony ++iConfig; // licznik użycia Scroll Lock } break; @@ -398,7 +398,13 @@ void Console::BitsUpdate(int mask) bool Console::Pressed(int x) { // na razie tak - czyta się tylko klawiatura - return Global::bActive && (GetKeyState(x) < 0); + if (!Global::bActive) + return false; + + if (glfwGetKey(Global::window, x) == GLFW_TRUE) + return true; + else + return false; }; void Console::ValueSet(int x, double y) @@ -499,7 +505,7 @@ void Console::Update() else { // błąd komunikacji - zapauzować symulację? if (!(Global::iPause & 8)) // jeśli jeszcze nie oflagowana - Global::iTextMode = VK_F1; // pokazanie czasu/pauzy + Global::iTextMode = GLFW_KEY_F1; // pokazanie czasu/pauzy Global::iPause |= 8; // tak??? PoKeys55[0]->Connect(); // próba ponownego podłączenia } diff --git a/EU07.cpp b/EU07.cpp index 367afaa8..fc980675 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -19,12 +19,6 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others #include "stdafx.h" -#include //_clear87() itp. - -#include "opengl/glew.h" -#include "opengl/wglew.h" -#include "opengl/ARB_Multisample.h" - #include "Globals.h" #include "Logs.h" #include "Console.h" @@ -32,542 +26,20 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others #include "World.h" #include "Mover.h" -#pragma comment( lib, "glew32.lib" ) -#pragma comment( lib, "glu32.lib" ) -#pragma comment( lib, "opengl32.lib" ) -#pragma comment( lib, "dsound.lib" ) -#pragma comment( lib, "winmm.lib" ) -#pragma comment( lib, "setupapi.lib" ) -#pragma comment( lib, "python27.lib" ) +#pragma comment (lib, "glew32.lib") +#pragma comment (lib, "glu32.lib") +#pragma comment (lib, "opengl32.lib") +#pragma comment (lib, "dsound.lib") +#pragma comment (lib, "winmm.lib") +#pragma comment (lib, "setupapi.lib") +#pragma comment (lib, "python27.lib") #pragma comment (lib, "dbghelp.lib") +#pragma comment (lib, "glfw3.lib") //static -HDC hDC = NULL; // Private GDI Device Context -HGLRC hRC = NULL; // Permanent Rendering Context -HWND hWnd = NULL; // Holds Our Window Handle +#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") TWorld World; -// bool active=TRUE; //window active flag set to TRUE by default -bool fullscreen = TRUE; // fullscreen flag set to fullscreen mode by default -int WindowWidth = 800; -int WindowHeight = 600; -int Bpp = 32; - -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc - -//#include "dbgForm.h" -//--------------------------------------------------------------------------- - -int InitGL(GLvoid) // All Setup For OpenGL Goes Here -{ -// _clear87(); -// _control87(MCW_EM, MCW_EM); - glewInit(); - // hunter-271211: przeniesione - // AllocConsole(); - // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN); - - // ShaXbee-121209: Wlaczenie obslugi tablic wierzcholkow - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów - return World.Init(hWnd, hDC); // true jeśli wszystko pójdzie dobrze -} -//--------------------------------------------------------------------------- - -GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // resize and initialize the GL Window -{ - WindowWidth = width; - WindowHeight = height; - if (height == 0) // prevent a divide by zero by - height = 1; // making height equal one - glViewport(0, 0, width, height); // Reset The Current Viewport - glMatrixMode(GL_PROJECTION); // select the Projection Matrix - glLoadIdentity(); // reset the Projection Matrix - // calculate the aspect ratio of the window - gluPerspective(45.0f, (GLdouble)width / (GLdouble)height, 0.2f, 2500.0f); - glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix - glLoadIdentity(); // reset the Modelview Matrix -} - -//--------------------------------------------------------------------------- -GLvoid KillGLWindow(GLvoid) // properly kill the window -{ - if (hRC) // Do We Have A Rendering Context? - { - if (!wglMakeCurrent(NULL, NULL)) // are we able to release the DC and RC contexts? - { - ErrorLog("Fail: window releasing"); - MessageBox(NULL, "Release of DC and RC failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - } - - if (!wglDeleteContext(hRC)) // are we able to delete the RC? - { - ErrorLog("Fail: rendering context releasing"); - MessageBox(NULL, "Release rendering context failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - } - hRC = NULL; // set RC to NULL - } - - if (hDC && !ReleaseDC(hWnd, hDC)) // are we able to release the DC? - { - ErrorLog("Fail: device context releasing"); - MessageBox(NULL, "Release device context failed.", "SHUTDOWN ERROR", - MB_OK | MB_ICONINFORMATION); - hDC = NULL; // set DC to NULL - } - - if (hWnd && !DestroyWindow(hWnd)) // are we able to destroy the window? - { - ErrorLog("Fail: window destroying"); - MessageBox(NULL, "Could not release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION); - hWnd = NULL; // set hWnd to NULL - } - - if (fullscreen) // Are We In Fullscreen Mode? - { - ChangeDisplaySettings(NULL, 0); // if so switch back to the desktop - ShowCursor(TRUE); // show mouse pointer - } - // KillFont(); -} - -/* This code creates our OpenGL Window. Parameters are: * - * title - title to appear at the top of the window * - * width - width of the GL Window or fullscreen mode * - * height - height of the GL Window or fullscreen mode * - * bits - number of bits to use for color (8/16/24/32) * - * fullscreenflag - use fullscreen mode (TRUE) or windowed mode (FALSE) */ - -BOOL CreateGLWindow(char *title, int width, int height, int bits, bool fullscreenflag) -{ - GLuint PixelFormat; // holds the results after searching for a match - HINSTANCE hInstance; // holds the instance of the application - WNDCLASS wc; // windows class structure - DWORD dwExStyle; // window extended style - DWORD dwStyle; // window style - RECT WindowRect; // grabs rectangle upper left / lower right values - WindowRect.left = (long)0; // set left value to 0 - WindowRect.right = (long)width; // set right value to requested width - WindowRect.top = (long)0; // set top value to 0 - WindowRect.bottom = (long)height; // set bottom value to requested height - - fullscreen = fullscreenflag; // set the global fullscreen flag - - hInstance = GetModuleHandle(NULL); // grab an instance for our window - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // redraw on size, and own DC for window. - wc.lpfnWndProc = (WNDPROC)WndProc; // wndproc handles messages - wc.cbClsExtra = 0; // no extra window data - wc.cbWndExtra = 0; // no extra window data - wc.hInstance = hInstance; // set the instance - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon - wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load the arrow pointer - wc.hbrBackground = NULL; // no background required for GL - wc.lpszMenuName = NULL; // we don't want a menu - wc.lpszClassName = "EU07"; // nazwa okna do komunikacji zdalnej - // // Set The Class Name - - if (!arbMultisampleSupported) // tylko dla pierwszego okna - if (!RegisterClass(&wc)) // Attempt To Register The Window Class - { - ErrorLog("Fail: window class registeration"); - MessageBox(NULL, "Failed to register the window class.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (fullscreen) // Attempt Fullscreen Mode? - { - DEVMODE dmScreenSettings; // device mode - memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // makes sure memory's cleared - dmScreenSettings.dmSize = sizeof(dmScreenSettings); // size of the devmode structure - - // tolaris-240403: poprawka na odswiezanie monitora - // locate primary monitor... - if (Global::bAdjustScreenFreq) - { - POINT point; - point.x = 0; - point.y = 0; - MONITORINFOEX monitorinfo; - monitorinfo.cbSize = sizeof(MONITORINFOEX); - ::GetMonitorInfo(::MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY), &monitorinfo); - // ..and query for highest supported refresh rate - unsigned int refreshrate = 0; - int i = 0; - while (::EnumDisplaySettings(monitorinfo.szDevice, i, &dmScreenSettings)) - { - if (i > 0) - if (dmScreenSettings.dmPelsWidth == (unsigned int)width) - if (dmScreenSettings.dmPelsHeight == (unsigned int)height) - if (dmScreenSettings.dmBitsPerPel == (unsigned int)bits) - if (dmScreenSettings.dmDisplayFrequency > refreshrate) - refreshrate = dmScreenSettings.dmDisplayFrequency; - ++i; - } - // fill refresh rate info for screen mode change - dmScreenSettings.dmDisplayFrequency = refreshrate; - dmScreenSettings.dmFields = DM_DISPLAYFREQUENCY; - } - dmScreenSettings.dmPelsWidth = width; // selected screen width - dmScreenSettings.dmPelsHeight = height; // selected screen height - dmScreenSettings.dmBitsPerPel = bits; // selected bits per pixel - dmScreenSettings.dmFields = - dmScreenSettings.dmFields | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - - // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar. - if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - { - // If the mode fails, offer two options. Quit or use windowed mode. - ErrorLog("Fail: full screen"); - if (MessageBox(NULL, "The requested fullscreen mode is not supported by\nyour video " - "card. Use windowed mode instead?", - "EU07", MB_YESNO | MB_ICONEXCLAMATION) == IDYES) - { - fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE - } - else - { - // Pop Up A Message Box Letting User Know The Program Is Closing. - Error("Program will now close."); - return FALSE; // Return FALSE - } - } - } - - if (fullscreen) // Are We Still In Fullscreen Mode? - { - dwExStyle = WS_EX_APPWINDOW; // Window Extended Style - dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style - ShowCursor(FALSE); // Hide Mouse Pointer - } - else - { - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style - dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Windows Style - } - - AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, - dwExStyle); // Adjust Window To True Requested Size - - // Create The Window - if (NULL == - (hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window - "EU07", // Class Name - title, // Window Title - dwStyle | // Defined Window Style - WS_CLIPSIBLINGS | // Required Window Style - WS_CLIPCHILDREN, // Required Window Style - 0, - 0, // Window Position - WindowRect.right - WindowRect.left, // Calculate Window Width - WindowRect.bottom - WindowRect.top, // Calculate Window Height - NULL, // No Parent Window - NULL, // No Menu - hInstance, // Instance - NULL))) // Dont Pass Anything To WM_CREATE - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: window creation"); - MessageBox(NULL, "Window creation error.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be - { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, // Must Support Double Buffering - PFD_TYPE_RGBA, // Request An RGBA Format - bits, // Select Our Color Depth - 0, - 0, 0, 0, 0, 0, // Color Bits Ignored - 0, // No Alpha Buffer - 0, // Shift Bit Ignored - 0, // No Accumulation Buffer - 0, 0, 0, 0, // Accumulation Bits Ignored - 24, // 32Bit Z-Buffer (Depth Buffer) - 0, // No Stencil Buffer - 0, // No Auxiliary Buffer - PFD_MAIN_PLANE, // Main Drawing Layer - 0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - - if (NULL == (hDC = GetDC(hWnd))) // Did We Get A Device Context? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: device context"); - MessageBox(NULL, "Can't create a GL device context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - /* - Our first pass, Multisampling hasn't been created yet, so we create a window normally - If it is supported, then we're on our second pass - that means we want to use our pixel format for sampling - so set PixelFormat to arbMultiSampleformat instead - */ - if (!arbMultisampleSupported) - { - if (NULL == (PixelFormat = - ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: pixelformat"); - MessageBox(NULL, "Can't find a suitable pixelformat.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - } - else - PixelFormat = arbMultisampleFormat; - - if (!SetPixelFormat(hDC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: pixelformat"); - MessageBox(NULL, "Can't set the pixelformat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (NULL == (hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: OpenGL rendering context creation"); - MessageBox(NULL, "Can't create a GL rendering context.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context - { - KillGLWindow(); // Reset The Display - ErrorLog("Fail: OpenGL rendering context activation"); - MessageBox(NULL, "Can't activate the GL rendering context.", "ERROR", - MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - - /* - Now that our window is created, we want to queary what samples are available - we call our InitMultiSample window - if we return a valid context, we want to destroy our current window - and create a new one using the multisample interface. - */ - if (Global::iMultisampling) - if (!arbMultisampleSupported) - if ((Global::iMultisampling = - InitMultisample(hInstance, hWnd, pfd, 1 << Global::iMultisampling)) != 0) - { - // WriteConsoleOnly("Opening second window for multisampling of - // "+AnsiString(Global::iMultisampling)+" samples."); - KillGLWindow(); // reset the display - return CreateGLWindow(title, width, height, bits, fullscreenflag); // rekurencja - } - - ShowWindow(hWnd, SW_SHOW); // show the window - SetForegroundWindow(hWnd); // slightly higher priority - SetFocus(hWnd); // sets keyboard focus to the window - ReSizeGLScene(width, height); // set up our perspective GL screen - - if (!InitGL()) // initialize our newly created GL Window - { - KillGLWindow(); // reset the display - ErrorLog("Fail: OpenGL initialization"); - MessageBox(NULL, "Initialization Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // return FALSE - } - return TRUE; // success -} - -static int mx = 0, my = 0; -static POINT mouse; - -static int test = 0; -/**/ -// ************ Globals ************ -// -#define MYDISPLAY 1 - -PCOPYDATASTRUCT pDane; - -LRESULT CALLBACK WndProc(HWND hWnd, // handle for this window - UINT uMsg, // message for this window - WPARAM wParam, // additional message information - LPARAM lParam) // additional message information -{ - RECT rect; - switch (uMsg) // check for windows messages - { - case WM_PASTE: //[Ctrl]+[V] potrzebujemy do innych celów - return 0; - case WM_COPYDATA: // obsługa danych przesłanych przez program sterujący - pDane = (PCOPYDATASTRUCT)lParam; - if (pDane->dwData == 'EU07') // sygnatura danych - World.OnCommandGet((DaneRozkaz *)(pDane->lpData)); - break; - case WM_ACTIVATE: // watch for window activate message - // case WM_ACTIVATEAPP: - { // Ra: uzależnienie aktywności od bycia na wierzchu - Global::bActive = (LOWORD(wParam) != WA_INACTIVE); - if (Global::bInactivePause) // jeśli ma być pauzowanie okna w tle - if (Global::bActive) - Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie - else - Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy - if (Global::bActive) - SetCursorPos(mx, my); - ShowCursor(!Global::bActive); - /* - if (!HIWORD(wParam)) //check minimization state - active=TRUE; //program is active - else - active=FALSE; //program is no longer active - */ - return 0; // return to the message loop - } - case WM_SYSCOMMAND: // intercept system commands - { - switch (wParam) // check system calls - { - case 61696: // F10 - World.OnKeyDown(VK_F10); - return 0; - case SC_SCREENSAVE: // screensaver trying to start? - case SC_MONITORPOWER: // monitor trying to enter powersave? - return 0; // prevent from happening - } - break; // exit - } - case WM_CLOSE: // did we receive a close message? - { - PostQuitMessage(0); // send a quit message [Alt]+[F4] - return 0; // jump back - } - case WM_MOUSEMOVE: - { - // mx= 100;//Global::iWindowWidth/2; - // my= 100;//Global::iWindowHeight/2; - // SetCursorPos(Global::iWindowWidth/2,Global::iWindowHeight/2); - // m_x= LOWORD(lParam); - // m_y= HIWORD(lParam); - GetCursorPos(&mouse); - if (Global::bActive && ((mouse.x != mx) || (mouse.y != my))) - { - World.OnMouseMove(double(mouse.x - mx) * 0.005, double(mouse.y - my) * 0.01); - SetCursorPos(mx, my); - } - return 0; // jump back - } - case WM_KEYUP: - if (Global::bActive) - { - World.OnKeyUp(wParam); - return 0; - } - case WM_KEYDOWN: - if (Global::bActive) - { - if (wParam != 17) // bo naciśnięcia [Ctrl] nie ma po co przekazywać - if (wParam != 145) //[Scroll Lock] też nie - World.OnKeyDown(wParam); - switch (wParam) - { - case VK_ESCAPE: //[Esc] pauzuje tylko bez Debugmode - if (DebugModeFlag) - break; - case 19: //[Pause] - if (Global::iPause & 1) // jeśli pauza startowa - Global::iPause &= ~1; // odpauzowanie, gdy po wczytaniu miało nie startować - else if (!(Global::iMultiplayer & 2)) // w multiplayerze pauza nie ma sensu - if (!Console::Pressed(VK_CONTROL)) // z [Ctrl] to radiostop jest - // Ra: poniższe nie ma sensu, bo brak komunikacji natychmiast zapauzuje - // ponownie - // if (Global::iPause&8) //jeśli pauza związana z brakiem komunikacji z - // PoKeys - // Global::iPause&=~10; //odpauzowanie pauzy PoKeys (chyba nic nie da) i - // ewentualnie klawiszowej również - // else - Global::iPause ^= 2; // zmiana stanu zapauzowania - if (Global::iPause) // jak pauza - Global::iTextMode = VK_F1; // to wyświetlić zegar i informację - break; - case VK_F7: - if (DebugModeFlag) - { // siatki wyświetlane tyko w trybie testowym - Global::bWireFrame = !Global::bWireFrame; - ++Global::iReCompile; // odświeżyć siatki - // Ra: jeszcze usunąć siatki ze skompilowanych obiektów! - } - break; - } - } - return 0; // jump back - case WM_CHAR: - { - /* - switch ((TCHAR) wParam) - { - // case 'q': - // done= true; - // KillGLWindow(); - // PostQuitMessage(0); - // DestroyWindow( hWnd ); - // break; - }; - */ - return 0; - } - case WM_SIZE: // resize the OpenGL window - { - ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width, HiWord=Height - if (GetWindowRect(hWnd, &rect)) - { // Ra: zmiana rozmiaru okna bez przesuwania myszy - // mx=WindowWidth/2+rect.left; // horizontal position - // my=WindowHeight/2+rect.top; // vertical position - // SetCursorPos(mx,my); - } - return 0; // jump back - } - case WM_MOVE: // przesuwanie okna? - { - mx = WindowWidth / 2 + LOWORD(lParam); // horizontal position - my = WindowHeight / 2 + HIWORD(lParam); // vertical position - // SetCursorPos(mx,my); - break; - } - case WM_PAINT: - { // odrysowanie okna - break; - } - // case WM_ERASEBKGND: //Process this message to keep Windows from erasing background. - case MM_JOY1BUTTONDOWN: - { - // WriteLog("Joystick button "+AnsiString(wParam)); - break; - } - case WM_CREATE: - /* Capture the joystick. If this fails, beep and display - * error, then quit. - */ - if (joySetCapture(hWnd, JOYSTICKID1, 0, FALSE)) - { - // MessageBeep(MB_ICONEXCLAMATION); - // MessageBox(hWnd,"Couldn't capture the joystick",NULL,MB_OK|MB_ICONEXCLAMATION); - // return -1; - } - break; - } - // pass all unhandled messages to DefWindowProc - return DefWindowProc(hWnd, uMsg, wParam, lParam); -}; - #ifdef _WINDOWS void make_minidump( ::EXCEPTION_POINTERS* e ) { @@ -617,27 +89,80 @@ LONG CALLBACK unhandled_handler( ::EXCEPTION_POINTERS* e ) { } #endif -int WINAPI WinMain(HINSTANCE hInstance, // instance - HINSTANCE hPrevInstance, // previous instance - LPSTR lpCmdLine, // command line parameters - int nCmdShow) // window show state +void window_resize_callback(GLFWwindow *window, int w, int h) +{ + glViewport(0, 0, w, h); // Reset The Current Viewport + glMatrixMode(GL_PROJECTION); // select the Projection Matrix + glLoadIdentity(); // reset the Projection Matrix + // calculate the aspect ratio of the window + gluPerspective(45.0f, (GLdouble)w / (GLdouble)h, 0.2f, 2500.0f); + glMatrixMode(GL_MODELVIEW); // select the Modelview Matrix + glLoadIdentity(); // reset the Modelview Matrix +} + +void cursor_pos_callback(GLFWwindow *window, double x, double y) +{ + if (Global::bActive) + World.OnMouseMove(x * 0.005, y * 0.01); + glfwSetCursorPos(window, 0.0, 0.0); +} + +void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) +{ + //m7todo: bActive teraz pewnie nie potrzebne + if (!Global::bActive) + return; + + Global::shiftState = (mods & GLFW_MOD_SHIFT) ? true : false; + Global::ctrlState = (mods & GLFW_MOD_CONTROL) ? true : false; + + if (action == GLFW_PRESS) + { + World.OnKeyDown(key); + + switch (key) + { + case GLFW_KEY_PAUSE: + if (Global::iPause & 1) + Global::iPause &= ~1; + else if (!(Global::iMultiplayer & 2) && + (mods & GLFW_MOD_CONTROL)) + Global::iPause ^= 2; + if (Global::iPause) + Global::iTextMode = GLFW_KEY_F1; + break; + + case GLFW_KEY_F7: + Global::bWireFrame = !Global::bWireFrame; + ++Global::iReCompile; + break; + } + } + else if (action == GLFW_RELEASE) + { + World.OnKeyUp(key); + } +} + +void focus_callback(GLFWwindow *window, int focus) +{ + Global::bActive = (focus == GLFW_TRUE ? 1 : 0); + if (Global::bInactivePause) // jeśli ma być pauzowanie okna w tle + if (Global::bActive) + Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie + else + Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy +} + +int main(int argc, char argv[]) { -#if defined(_MSC_VER) && defined (_DEBUG) - // memory leaks - _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF ); - // floating point operation errors - auto state = _clearfp(); - state = _control87( 0, 0 ); - // this will turn on FPE for #IND and zerodiv - state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM ); -#endif #ifdef _WINDOWS - ::SetUnhandledExceptionFilter( unhandled_handler ); + ::SetUnhandledExceptionFilter(unhandled_handler); #endif - MSG msg; // windows message structure - BOOL done = FALSE; // bool variable to exit loop - fullscreen = true; + if (!glfwInit()) + return -1; + DeleteFile("errors.txt"); // usunięcie starego Global::LoadIniFile("eu07.ini"); // teraz dopiero można przejrzeć plik z ustawieniami Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na stałe @@ -648,31 +173,33 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance AllocConsole(); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); } - std::string commandline( lpCmdLine ); // parametry uruchomienia - if( false == commandline.empty() ) - { // analizowanie parametrďż˝w - cParser parser( commandline ); + + std::string commandline(argv); + if (!commandline.empty()) + { + cParser parser(commandline); std::string token; - do { + do + { parser.getTokens(); token.clear(); parser >> token; - if( token == "-s" ) + if (token == "-s") { // nazwa scenerii parser.getTokens(); parser >> Global::SceneryFile; } - else if( token == "-v") + else if (token == "-v") { // nazwa wybranego pojazdu parser.getTokens(); parser >> Global::asHumanCtrlVehicle; } - else if( token == "-modifytga" ) + else if (token == "-modifytga") { // wykonanie modyfikacji wszystkich plików TGA Global::iModifyTGA = -1; // specjalny tryb wykonania totalnej modyfikacji } - else if( token == "-e3d" ) + else if (token == "-e3d") { // wygenerowanie wszystkich plików E3D if (Global::iConvertModels > 0) Global::iConvertModels = -Global::iConvertModels; // specjalny tryb @@ -684,34 +211,40 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance "Program usage: EU07 [-s sceneryfilepath] [-v vehiclename] [-modifytga] [-e3d]", !Global::iWriteLogEnabled); } - while( false == token.empty() ); + while (!token.empty()); } - /* MC: usunalem tymczasowo bo sie gryzlo z nowym parserem - 8.6.2003 - AnsiString csp=AnsiString(Global::szSceneryFile); - csp=csp.Delete(csp.Pos(AnsiString(strrchr(Global::szSceneryFile,'/')))+1,csp.Length()); - Global::asCurrentSceneryPath=csp; - */ - fullscreen = Global::bFullScreen; - WindowWidth = Global::iWindowWidth; - WindowHeight = Global::iWindowHeight; - Bpp = Global::iBpp; - if (Bpp != 32) - Bpp = 16; - // create our OpenGL window - if (!CreateGLWindow(const_cast(Global::asHumanCtrlVehicle.c_str()), WindowWidth, WindowHeight, Bpp, - fullscreen)) - return 0; // quit if window was not created - SetForegroundWindow(hWnd); - // McZapkie: proba przeplukania klawiatury + bool fullscreen = Global::bFullScreen; + int width = Global::iWindowWidth; + int height = Global::iWindowHeight; + + GLFWwindow *window = glfwCreateWindow(width, height, "EU07++", nullptr, nullptr); + if (!window) + return -1; + glfwMakeContextCurrent(window); + glfwSwapInterval(1); //vsync + glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); //capture cursor + glfwSetCursorPos(window, 0.0, 0.0); + glfwSetFramebufferSizeCallback(window, window_resize_callback); + glfwSetCursorPosCallback(window, cursor_pos_callback); + glfwSetKeyCallback(window, key_callback); + glfwSetWindowFocusCallback(window, focus_callback); + glfwGetFramebufferSize(window, &width, &height); + window_resize_callback(window, width, height); + + if (glewInit() != GLEW_OK) + return -1; + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów + if (!World.Init(window)) + return -1; + Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba - while (Console::Pressed(VK_F10)) - Error("Keyboard buffer problem - press F10"); // na Windows 98 lubi się to pojawiać - int iOldSpeed, iOldDelay; - SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &iOldSpeed, 0); - SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &iOldDelay, 0); - SystemParametersInfo(SPI_SETKEYBOARDSPEED, 20, NULL, 0); - // SystemParametersInfo(SPI_SETKEYBOARDDELAY,10,NULL,0); + if (!joyGetNumDevs()) WriteLog("No joystick"); if (Global::iModifyTGA < 0) @@ -727,43 +260,20 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance World.CreateE3D("models\\"); // rekurencyjne przeglądanie katalogów World.CreateE3D("dynamic\\", true); } // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć - // else - //{//główna pętla programu + Console::On(); // włączenie konsoli - while (!done) // loop that runs while done=FALSE + while (!glfwWindowShouldClose(window) && World.Update()) { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // is there a message waiting? - { - if (msg.message == WM_QUIT) // have we received a quit message? - done = TRUE; // if so - else // if not, deal with window messages - { - // if (msg.message==WM_CHAR) - // World.OnKeyDown(msg.wParam); - TranslateMessage(&msg); // translate the message - DispatchMessage(&msg); // dispatch the message - } - } - else // if there are no messages - { - // draw the scene, watch for quit messages - // DrawGLScene() - // if (!pause) - // if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry - if (World.Update()) // Was There A Quit Received? - SwapBuffers(hDC); // Swap Buffers (Double Buffering) - else - done = true; //[F10] or DrawGLScene signalled a quit - } + glfwSwapBuffers(window); + glfwPollEvents(); } Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej) } - SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0); - SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0); - delete pConsole; // deaktywania sterownika + + delete pConsole; TPythonInterpreter::killInstance(); - // shutdown - KillGLWindow(); // kill the window - return (msg.wParam); // exit the program + glfwDestroyWindow(window); + glfwTerminate(); + return 0; } diff --git a/Globals.cpp b/Globals.cpp index 397f0a6d..605b0452 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -48,7 +48,10 @@ bool Global::bOpenGL_1_5 = false; // czy są dostępne funkcje OpenGL 1.5 */ double Global::fLuminance = 1.0; // jasność światła do automatycznego zapalania int Global::iReCompile = 0; // zwiększany, gdy trzeba odświeżyć siatki -HWND Global::hWnd = NULL; // uchwyt okna +//HWND Global::hWnd = NULL; // uchwyt okna +GLFWwindow *Global::window; +bool Global::shiftState; +bool Global::ctrlState; int Global::iCameraLast = -1; std::string Global::asRelease = "16.0.1172.482"; std::string Global::asVersion = @@ -909,7 +912,7 @@ void Global::ConfigParse(cParser &Parser) fFpsMax = fFpsAverage + fFpsDeviation; // górna granica FPS, przy której promień scenerii będzie zwiększany if (iPause) - iTextMode = VK_F1; // jak pauza, to pokazać zegar + iTextMode = GLFW_KEY_F1; // jak pauza, to pokazać zegar /* this won't execute anymore with the old parser removed // TBD: remove, or launch depending on passed flag? if (qp) @@ -934,128 +937,90 @@ void Global::ConfigParse(cParser &Parser) void Global::InitKeys(std::string asFileName) { - // if (FileExists(asFileName)) - // { - // Error("Chwilowo plik keys.ini nie jest obsługiwany. Ładuję standardowe - // ustawienia.\nKeys.ini file is temporarily not functional, loading default keymap..."); - /* TQueryParserComp *Parser; - Parser=new TQueryParserComp(NULL); - Parser->LoadStringToParse(asFileName); + Keys[k_IncMainCtrl] = GLFW_KEY_KP_ADD; + Keys[k_IncMainCtrlFAST] = GLFW_KEY_KP_ADD; + Keys[k_DecMainCtrl] = GLFW_KEY_KP_SUBTRACT; + Keys[k_DecMainCtrlFAST] = GLFW_KEY_KP_SUBTRACT; + Keys[k_IncScndCtrl] = GLFW_KEY_KP_DIVIDE; + Keys[k_IncScndCtrlFAST] = GLFW_KEY_KP_DIVIDE; + Keys[k_DecScndCtrl] = GLFW_KEY_KP_MULTIPLY; + Keys[k_DecScndCtrlFAST] = GLFW_KEY_KP_MULTIPLY; - for (int keycount=0; keycountGetNextSymbol().ToInt(); - } + Keys[k_IncLocalBrakeLevel] = GLFW_KEY_KP_1; + Keys[k_DecLocalBrakeLevel] = GLFW_KEY_KP_7; + Keys[k_IncBrakeLevel] = GLFW_KEY_KP_3; + Keys[k_DecBrakeLevel] = GLFW_KEY_KP_9; + Keys[k_Releaser] = GLFW_KEY_KP_6; + Keys[k_EmergencyBrake] = GLFW_KEY_KP_0; + Keys[k_Brake3] = GLFW_KEY_KP_8; + Keys[k_Brake2] = GLFW_KEY_KP_5; + Keys[k_Brake1] = GLFW_KEY_KP_2; + Keys[k_Brake0] = GLFW_KEY_KP_4; + Keys[k_WaveBrake] = GLFW_KEY_KP_DECIMAL; - delete Parser; - */ - // } - // else - { - Keys[k_IncMainCtrl] = VK_ADD; - Keys[k_IncMainCtrlFAST] = VK_ADD; - Keys[k_DecMainCtrl] = VK_SUBTRACT; - Keys[k_DecMainCtrlFAST] = VK_SUBTRACT; - Keys[k_IncScndCtrl] = VK_DIVIDE; - Keys[k_IncScndCtrlFAST] = VK_DIVIDE; - Keys[k_DecScndCtrl] = VK_MULTIPLY; - Keys[k_DecScndCtrlFAST] = VK_MULTIPLY; - ///*NORMALNE - Keys[k_IncLocalBrakeLevel] = VK_NUMPAD1; // VK_NUMPAD7; - // Keys[k_IncLocalBrakeLevelFAST]=VK_END; //VK_HOME; - Keys[k_DecLocalBrakeLevel] = VK_NUMPAD7; // VK_NUMPAD1; - // Keys[k_DecLocalBrakeLevelFAST]=VK_HOME; //VK_END; - Keys[k_IncBrakeLevel] = VK_NUMPAD3; // VK_NUMPAD9; - Keys[k_DecBrakeLevel] = VK_NUMPAD9; // VK_NUMPAD3; - Keys[k_Releaser] = VK_NUMPAD6; - Keys[k_EmergencyBrake] = VK_NUMPAD0; - Keys[k_Brake3] = VK_NUMPAD8; - Keys[k_Brake2] = VK_NUMPAD5; - Keys[k_Brake1] = VK_NUMPAD2; - Keys[k_Brake0] = VK_NUMPAD4; - Keys[k_WaveBrake] = VK_DECIMAL; - //*/ - /*MOJE - Keys[k_IncLocalBrakeLevel]=VK_NUMPAD3; //VK_NUMPAD7; - Keys[k_IncLocalBrakeLevelFAST]=VK_NUMPAD3; //VK_HOME; - Keys[k_DecLocalBrakeLevel]=VK_DECIMAL; //VK_NUMPAD1; - Keys[k_DecLocalBrakeLevelFAST]=VK_DECIMAL; //VK_END; - Keys[k_IncBrakeLevel]=VK_NUMPAD6; //VK_NUMPAD9; - Keys[k_DecBrakeLevel]=VK_NUMPAD9; //VK_NUMPAD3; - Keys[k_Releaser]=VK_NUMPAD5; - Keys[k_EmergencyBrake]=VK_NUMPAD0; - Keys[k_Brake3]=VK_NUMPAD2; - Keys[k_Brake2]=VK_NUMPAD1; - Keys[k_Brake1]=VK_NUMPAD4; - Keys[k_Brake0]=VK_NUMPAD7; - Keys[k_WaveBrake]=VK_NUMPAD8; - */ - Keys[k_AntiSlipping] = VK_RETURN; - Keys[k_Sand] = VkKeyScan('s'); - Keys[k_Main] = VkKeyScan('m'); - Keys[k_Active] = VkKeyScan('w'); - Keys[k_Battery] = VkKeyScan('j'); - Keys[k_DirectionForward] = VkKeyScan('d'); - Keys[k_DirectionBackward] = VkKeyScan('r'); - Keys[k_Fuse] = VkKeyScan('n'); - Keys[k_Compressor] = VkKeyScan('c'); - Keys[k_Converter] = VkKeyScan('x'); - Keys[k_MaxCurrent] = VkKeyScan('f'); - Keys[k_CurrentAutoRelay] = VkKeyScan('g'); - Keys[k_BrakeProfile] = VkKeyScan('b'); - Keys[k_CurrentNext] = VkKeyScan('z'); + Keys[k_AntiSlipping] = GLFW_KEY_KP_ENTER; + Keys[k_Sand] = 'S'; + Keys[k_Main] = 'M'; + Keys[k_Active] = 'W'; + Keys[k_Battery] = 'J'; + Keys[k_DirectionForward] = 'D'; + Keys[k_DirectionBackward] = 'R'; + Keys[k_Fuse] = 'N'; + Keys[k_Compressor] = 'C'; + Keys[k_Converter] = 'X'; + Keys[k_MaxCurrent] = 'F'; + Keys[k_CurrentAutoRelay] = 'G'; + Keys[k_BrakeProfile] = 'B'; + Keys[k_CurrentNext] = 'Z'; - Keys[k_Czuwak] = VkKeyScan(' '); - Keys[k_Horn] = VkKeyScan('a'); - Keys[k_Horn2] = VkKeyScan('a'); + Keys[k_Czuwak] = ' '; + Keys[k_Horn] = 'A'; + Keys[k_Horn2] = 'A'; - Keys[k_FailedEngineCutOff] = VkKeyScan('e'); + Keys[k_FailedEngineCutOff] = 'E'; - Keys[k_MechUp] = VK_PRIOR; - Keys[k_MechDown] = VK_NEXT; - Keys[k_MechLeft] = VK_LEFT; - Keys[k_MechRight] = VK_RIGHT; - Keys[k_MechForward] = VK_UP; - Keys[k_MechBackward] = VK_DOWN; + Keys[k_MechUp] = GLFW_KEY_PAGE_UP; + Keys[k_MechDown] = GLFW_KEY_PAGE_DOWN; + Keys[k_MechLeft] = GLFW_KEY_LEFT; + Keys[k_MechRight] = GLFW_KEY_RIGHT; + Keys[k_MechForward] = GLFW_KEY_UP; + Keys[k_MechBackward] = GLFW_KEY_DOWN; - Keys[k_CabForward] = VK_HOME; - Keys[k_CabBackward] = VK_END; + Keys[k_CabForward] = GLFW_KEY_HOME; + Keys[k_CabBackward] = GLFW_KEY_END; - Keys[k_Couple] = VK_INSERT; - Keys[k_DeCouple] = VK_DELETE; + Keys[k_Couple] = GLFW_KEY_INSERT; + Keys[k_DeCouple] = GLFW_KEY_DELETE; - Keys[k_ProgramQuit] = VK_F10; - // Keys[k_ProgramPause]=VK_F3; - Keys[k_ProgramHelp] = VK_F1; - // Keys[k_FreeFlyMode]=VK_F4; - Keys[k_WalkMode] = VK_F5; + Keys[k_ProgramQuit] = GLFW_KEY_F10; + Keys[k_ProgramHelp] = GLFW_KEY_F1; + Keys[k_WalkMode] = GLFW_KEY_F5; - Keys[k_OpenLeft] = VkKeyScan(','); - Keys[k_OpenRight] = VkKeyScan('.'); - Keys[k_CloseLeft] = VkKeyScan(','); - Keys[k_CloseRight] = VkKeyScan('.'); - Keys[k_DepartureSignal] = VkKeyScan('/'); + Keys[k_OpenLeft] = ','; + Keys[k_OpenRight] = '.'; + Keys[k_CloseLeft] = ','; + Keys[k_CloseRight] = '.'; + Keys[k_DepartureSignal] = '/'; - // Winger 160204 - obsluga pantografow - Keys[k_PantFrontUp] = VkKeyScan('p'); // Ra: zamieniony przedni z tylnym - Keys[k_PantFrontDown] = VkKeyScan('p'); - Keys[k_PantRearUp] = VkKeyScan('o'); - Keys[k_PantRearDown] = VkKeyScan('o'); - // Winger 020304 - ogrzewanie - Keys[k_Heating] = VkKeyScan('h'); - Keys[k_LeftSign] = VkKeyScan('y'); - Keys[k_UpperSign] = VkKeyScan('u'); - Keys[k_RightSign] = VkKeyScan('i'); - Keys[k_EndSign] = VkKeyScan('t'); + // Winger 160204 - obsluga pantografow + Keys[k_PantFrontUp] = 'P'; // Ra: zamieniony przedni z tylnym + Keys[k_PantFrontDown] = 'P'; + Keys[k_PantRearUp] = 'O'; + Keys[k_PantRearDown] = 'O'; + // Winger 020304 - ogrzewanie + Keys[k_Heating] = 'H'; + Keys[k_LeftSign] = 'Y'; + Keys[k_UpperSign] = 'U'; + Keys[k_RightSign] = 'I'; + Keys[k_EndSign] = 'T'; - Keys[k_SmallCompressor] = VkKeyScan('v'); - Keys[k_StLinOff] = VkKeyScan('l'); - // ABu 090305 - przyciski uniwersalne, do roznych bajerow :) - Keys[k_Univ1] = VkKeyScan('['); - Keys[k_Univ2] = VkKeyScan(']'); - Keys[k_Univ3] = VkKeyScan(';'); - Keys[k_Univ4] = VkKeyScan('\''); - } + Keys[k_SmallCompressor] = 'V'; + Keys[k_StLinOff] = 'L'; + // ABu 090305 - przyciski uniwersalne, do roznych bajerow :) + Keys[k_Univ1] = '['; + Keys[k_Univ2] = ']'; + Keys[k_Univ3] = ';'; + Keys[k_Univ4] = '\''; } /* vector3 Global::GetCameraPosition() diff --git a/Globals.h b/Globals.h index 38f18281..e2124e10 100644 --- a/Globals.h +++ b/Globals.h @@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/. #include #include +#include #include "opengl/glew.h" #include "dumb3d.h" @@ -241,7 +242,9 @@ class Global */ static double fLuminance; // jasność światła do automatycznego zapalania static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji - static HWND hWnd; // uchwyt okna + static GLFWwindow *window; + static bool shiftState; //m7todo: brzydko + static bool ctrlState; static int iCameraLast; static std::string asRelease; // numer static std::string asVersion; // z opisem diff --git a/Ground.cpp b/Ground.cpp index f3c0af7f..c544204c 100644 --- a/Ground.cpp +++ b/Ground.cpp @@ -17,7 +17,6 @@ http://mozilla.org/MPL/2.0/. #include "Ground.h" #include "opengl/glew.h" -#include "opengl/glut.h" #include "Globals.h" #include "Logs.h" @@ -312,7 +311,7 @@ void TGroundNode::RenderVBO() if (EvLaunch->Render()) if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius)) { - if (Console::Pressed(VK_SHIFT) && EvLaunch->Event2 != NULL) + if (Global::shiftState && EvLaunch->Event2 != NULL) Global::AddToQuery(EvLaunch->Event2, NULL); else if (EvLaunch->Event1 != NULL) Global::AddToQuery(EvLaunch->Event1, NULL); @@ -537,7 +536,7 @@ void TGroundNode::RenderHidden() if ((EvLaunch->dRadius < 0) || (mgn < EvLaunch->dRadius)) { WriteLog("Eventlauncher " + asName); - if (Console::Pressed(VK_SHIFT) && (EvLaunch->Event2)) + if (Global::shiftState && (EvLaunch->Event2)) Global::AddToQuery(EvLaunch->Event2, NULL); else if (EvLaunch->Event1) Global::AddToQuery(EvLaunch->Event1, NULL); @@ -2481,7 +2480,7 @@ void TGround::FirstInit() WriteLog("FirstInit is done"); }; -bool TGround::Init(std::string asFile, HDC hDC) +bool TGround::Init(std::string asFile) { // główne wczytywanie scenerii if (ToLower(asFile).substr(0, 7) == "scenery") asFile = asFile.erase(0, 8); // Ra: usunięcie niepotrzebnych znaków - zgodność wstecz z 2003 @@ -4974,7 +4973,8 @@ void TGround::WyslijEvent(const std::string &e, const std::string &d) cData.dwData = 'EU07'; // sygnatura cData.cbData = 12 + i + j; // 8+dwa liczniki i dwa zera kończące cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" ); }; //--------------------------------------------------------------------------- @@ -4991,7 +4991,8 @@ void TGround::WyslijUszkodzenia(const std::string &t, char fl) cData.dwData = 'EU07'; // sygnatura cData.cbData = 11 + i; // 8+licznik i zero kończące cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); }; //--------------------------------------------------------------------------- @@ -5007,7 +5008,8 @@ void TGround::WyslijString(const std::string &t, int n) cData.dwData = 'EU07'; // sygnatura cData.cbData = 10 + i; // 8+licznik i zero kończące cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); }; //--------------------------------------------------------------------------- @@ -5086,7 +5088,8 @@ void TGround::WyslijNamiary(TGroundNode *t) cData.cbData = 10 + i + j; // 8+licznik i zero kończące cData.lpData = &r; // WriteLog("Ramka gotowa"); - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); // WriteLog("Ramka poszla!"); CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent"); }; @@ -5129,7 +5132,8 @@ void TGround::WyslijObsadzone() cData.cbData = 8 + 1984; // 8+licznik i zero kończące cData.lpData = &r; // WriteLog("Ramka gotowa"); - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent"); } @@ -5153,7 +5157,8 @@ void TGround::WyslijParam(int nr, int fl) cData.dwData = 'EU07'; // sygnatura cData.cbData = 12 + i; // 12+rozmiar danych cData.lpData = &r; - Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); + //m7todo + //Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData); }; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- diff --git a/Ground.h b/Ground.h index 099eff67..386503f3 100644 --- a/Ground.h +++ b/Ground.h @@ -320,7 +320,7 @@ class TGround TGround(); ~TGround(); void Free(); - bool Init(std::string asFile, HDC hDC); + bool Init(std::string asFile); void FirstInit(); void InitTracks(); void InitTraction(); diff --git a/Texture.cpp b/Texture.cpp index c07b5a79..1550e4c8 100644 --- a/Texture.cpp +++ b/Texture.cpp @@ -268,7 +268,7 @@ TTexturesManager::AlphaValue TTexturesManager::LoadBMP(std::string const &fileNa if( infoSize > sizeof( info ) ) { WriteLog( "Warning - BMP header is larger than expected, possible format difference." ); } - file.read((char *)&info, std::min(infoSize, sizeof(info))); + file.read((char *)&info, std::min((size_t)infoSize, sizeof(info))); if (file.eof()) { diff --git a/Train.cpp b/Train.cpp index 9196e232..1dec2eaf 100644 --- a/Train.cpp +++ b/Train.cpp @@ -413,7 +413,7 @@ void TTrain::OnKeyDown(int cKey) // isEztOer=(mvControlled->TrainType==dt_EZT)&&(mvControlled->Mains)&&(mvOccupied->BrakeSubsystem==ss_ESt)&&(mvControlled->ActiveDir!=0); // isEztOer=((mvControlled->TrainType==dt_EZT)&&(mvControlled->Battery==true)&&(mvControlled->EpFuse==true)&&(mvOccupied->BrakeSubsystem==Oerlikon)&&(mvControlled->ActiveDir!=0)); - if (GetAsyncKeyState(VK_SHIFT) < 0) + if (Global::shiftState) { // wciśnięty [Shift] if (cKey == Global::Keys[k_IncMainCtrlFAST]) // McZapkie-200702: szybkie // przelaczanie na poz. @@ -428,7 +428,7 @@ void TTrain::OnKeyDown(int cKey) else if (cKey == Global::Keys[k_DirectionBackward]) { if (mvOccupied->Radio == false) - if (GetAsyncKeyState(VK_CONTROL) >= 0) + if (Global::ctrlState >= 0) { dsbSwitch->SetVolume(DSBVOLUME_MAX); dsbSwitch->Play(0, 0, 0); @@ -580,7 +580,7 @@ void TTrain::OnKeyDown(int cKey) int CouplNr = -2; if (!FreeFlyModeFlag) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if (mvOccupied->BrakeDelaySwitch(bdelay_R + bdelay_M)) { dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); @@ -607,7 +607,7 @@ void TTrain::OnKeyDown(int cKey) } if (temp) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if (temp->MoverParameters->BrakeDelaySwitch(bdelay_R + bdelay_M)) { dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); @@ -677,7 +677,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || { // Ra: dźwięk, gdy razem z [Shift] if ((mvControlled->TrainType & dt_EZT) ? mvControlled == mvOccupied : !mvOccupied->ActiveCab) // tylko w maszynowym - if (Console::Pressed(VK_CONTROL)) // z [Ctrl] + if (Global::ctrlState) // z [Ctrl] mvControlled->bPantKurek3 = true; // zbiornik pantografu połączony // jest ze zbiornikiem głównym // (pompowanie nie ma sensu) @@ -779,7 +779,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || // przyciemnienia pod Univ4) else if (cKey == Global::Keys[k_Univ3]) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { if (bCabLight == false) //(ggCabLightButton.GetValue()==0) { @@ -795,7 +795,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || dsbSwitch->Play(0, 0, 0); } /* - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) {//z [Ctrl] zapalamy albo gasimy światełko w kabinie if (iCabLightFlag<2) ++iCabLightFlag; //zapalenie } @@ -807,7 +807,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || // hunter-091012: dzwiek dla przyciemnienia swiatelka w kabinie else if (cKey == Global::Keys[k_Univ4]) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { if (bCabLightDim == false) //(ggCabLightDimButton.GetValue()==0) { @@ -910,7 +910,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || { if (false == (mvOccupied->LightsPosNo > 0)) { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && + if ((Global::ctrlState) && (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu { //------------------------------ @@ -1030,7 +1030,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || SetLights(); } } - else if ((GetAsyncKeyState(VK_CONTROL) < 0) && + else if ((Global::ctrlState) && (ggRearUpperLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu { //------------------------------ @@ -1085,7 +1085,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || { if (false == (mvOccupied->LightsPosNo > 0)) { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && + if ((Global::ctrlState) && (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem zapala z tylu { //------------------------------ @@ -1264,7 +1264,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || // World.cpp if (!FreeFlyModeFlag) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) { mvOccupied->IncManualBrakeLevel(1); @@ -1282,7 +1282,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || // World.cpp if (!FreeFlyModeFlag) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if ((mvOccupied->LocalBrake == ManualBrake) || (mvOccupied->MBrake == true)) mvOccupied->DecManualBrakeLevel(1); else @@ -1376,7 +1376,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || // mvOccupied->IncBrakeLevel()); mvOccupied->BrakeLevelSet(mvOccupied->BrakeCtrlPosNo / 2 + (mvOccupied->BrakeHandle == FV4a ? 1 : 0)); - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos(bh_NP)); // yB: czy ten stos funkcji nie // powinien być jako oddzielna @@ -1395,7 +1395,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || } else if (cKey == Global::Keys[k_Brake0]) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { mvOccupied->BrakeCtrlPos2 = 0; // wyrownaj kapturek } @@ -1457,7 +1457,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || else if (cKey == Global::Keys[k_Fuse]) //--------------- { - if (GetAsyncKeyState(VK_CONTROL) < 0) // z controlem + if (Global::ctrlState) // z controlem { ggConverterFuseButton.PutValue(1); // hunter-261211 if ((mvControlled->Mains == false) && (ggConverterButton.GetValue() == 0) && @@ -1498,7 +1498,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || } else if (cKey == Global::Keys[k_DirectionBackward]) // r { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) { // wciśnięty [Ctrl] if (mvOccupied->Radio == true) { @@ -1580,7 +1580,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || int CouplNr = -2; if (!FreeFlyModeFlag) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if (mvOccupied->BrakeDelaySwitch(bdelay_R)) { dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); @@ -1607,7 +1607,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || } if (temp) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if (temp->MoverParameters->BrakeDelaySwitch(bdelay_R)) { dsbPneumaticRelay->SetVolume(DSBVOLUME_MAX); @@ -1672,7 +1672,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) || { // Ra: bez [Shift] też dać dźwięk if ((mvControlled->TrainType & dt_EZT) ? mvControlled == mvOccupied : !mvOccupied->ActiveCab) // tylko w maszynowym - if (Console::Pressed(VK_CONTROL)) // z [Ctrl] + if (Global::ctrlState) // z [Ctrl] mvControlled->bPantKurek3 = false; // zbiornik pantografu połączony jest z małą sprężarką // (pompowanie ma sens, ale potem trzeba przełączyć) @@ -2009,7 +2009,7 @@ if // przyciemnienia pod Univ4) else if (cKey == Global::Keys[k_Univ3]) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { if (bCabLight == true) //(ggCabLightButton.GetValue()!=0) { @@ -2025,7 +2025,7 @@ if dsbSwitch->Play(0, 0, 0); } /* - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) {//z [Ctrl] zapalamy albo gasimy światełko w kabinie if (iCabLightFlag) --iCabLightFlag; //gaszenie } */ @@ -2036,7 +2036,7 @@ if // hunter-091012: dzwiek dla przyciemnienia swiatelka w kabinie else if (cKey == Global::Keys[k_Univ4]) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { if (bCabLightDim == true) //(ggCabLightDimButton.GetValue()!=0) { @@ -2117,7 +2117,7 @@ if { if (false == (mvOccupied->LightsPosNo > 0)) { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && + if ((Global::ctrlState) && (ggRearLeftLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu { //------------------------------ @@ -2236,7 +2236,7 @@ if SetLights(); } } - else if ((GetAsyncKeyState(VK_CONTROL) < 0) && + else if ((Global::ctrlState) && (ggRearUpperLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu { //------------------------------ @@ -2290,7 +2290,7 @@ if { if (false == (mvOccupied->LightsPosNo > 0)) { - if ((GetAsyncKeyState(VK_CONTROL) < 0) && + if ((Global::ctrlState) && (ggRearRightLightButton.SubModel)) // hunter-230112 - z controlem gasi z tylu { //------------------------------ @@ -2427,8 +2427,8 @@ if fMechCroach = -0.5; else fMechCroach = 0.5; - // if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta - if (!Console::Pressed(VK_CONTROL)) // gdy [Ctrl] zwolniony (dodatkowe widoki) + // if (!Global::shiftState<0) // bez shifta + if (!Global::ctrlState) // gdy [Ctrl] zwolniony (dodatkowe widoki) { if (cKey == Global::Keys[k_MechLeft]) { @@ -2517,7 +2517,7 @@ if void TTrain::OnKeyUp(int cKey) { // zwolnienie klawisza - if (GetAsyncKeyState(VK_SHIFT) < 0) + if (Global::shiftState) { // wciśnięty [Shift] } else @@ -4198,7 +4198,7 @@ bool TTrain::Update( double const Deltatime ) if (Console::Pressed(Global::Keys[k_Horn])) { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { SetFlag(mvOccupied->WarningSignal, 2); mvOccupied->WarningSignal &= (255 - 1); @@ -4229,7 +4229,7 @@ bool TTrain::Update( double const Deltatime ) //---------------- // hunter-141211: wyl. szybki zalaczony i wylaczony przeniesiony z // OnKeyPress() - if (Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Main])) + if (Global::shiftState && Console::Pressed(Global::Keys[k_Main])) { fMainRelayTimer += dt; ggMainOnButton.PutValue(1); @@ -4263,7 +4263,7 @@ bool TTrain::Update( double const Deltatime ) } //--- - if (!Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Main])) + if (!Global::shiftState && Console::Pressed(Global::Keys[k_Main])) { ggMainOffButton.PutValue(1); if (mvControlled->MainSwitch(false)) @@ -4402,7 +4402,7 @@ bool TTrain::Update( double const Deltatime ) ggAntiSlipButton.UpdateValue(0); //----------------- // hunter-261211: przetwornica i sprezarka - if (Console::Pressed(VK_SHIFT) && + if (Global::shiftState && Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl { //(mvControlled->CompressorPower<2) ggConverterButton.PutValue(1); @@ -4426,16 +4426,16 @@ bool TTrain::Update( double const Deltatime ) } // if ( - // Console::Pressed(VK_SHIFT)&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) + // Global::shiftState&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) // ) //NBMX 14-09-2003: sprezarka wl - if (Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Compressor]) && + if (Global::shiftState && Console::Pressed(Global::Keys[k_Compressor]) && (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie { // hunter-110212: poprawka dla EZT ggCompressorButton.PutValue(1); mvControlled->CompressorSwitch(true); } - if (!Console::Pressed(VK_SHIFT) && + if (!Global::shiftState && Console::Pressed(Global::Keys[k_Converter])) // NBMX 14-09-2003: przetwornica wl { ggConverterButton.PutValue(0); @@ -4446,9 +4446,9 @@ bool TTrain::Update( double const Deltatime ) } // if ( - // !Console::Pressed(VK_SHIFT)&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) + // !Global::shiftState&&Console::Pressed(Global::Keys[k_Compressor])&&((mvControlled->EngineType==ElectricSeriesMotor)||(mvControlled->TrainType==dt_EZT)) // ) //NBMX 14-09-2003: sprezarka wl - if (!Console::Pressed(VK_SHIFT) && Console::Pressed(Global::Keys[k_Compressor]) && + if (!Global::shiftState && Console::Pressed(Global::Keys[k_Compressor]) && (mvControlled->CompressorPower < 2)) // hunter-091012: tak jest poprawnie { // hunter-110212: poprawka dla EZT ggCompressorButton.PutValue(0); @@ -4507,7 +4507,7 @@ bool TTrain::Update( double const Deltatime ) if (!DebugModeFlag) { if (ggUniversal1Button.SubModel) - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) ggUniversal1Button.IncValue(dt / 2); else ggUniversal1Button.DecValue(dt / 2); @@ -4523,7 +4523,7 @@ bool TTrain::Update( double const Deltatime ) if (!DebugModeFlag) { if (ggUniversal2Button.SubModel) - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) ggUniversal2Button.IncValue(dt / 2); else ggUniversal2Button.DecValue(dt / 2); @@ -4533,9 +4533,9 @@ bool TTrain::Update( double const Deltatime ) // hunter-091012: zrobione z uwzglednieniem przelacznika swiatla if (Console::Pressed(Global::Keys[k_Univ3])) { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { bCabLight = true; if (ggCabLightButton.SubModel) @@ -4558,7 +4558,7 @@ bool TTrain::Update( double const Deltatime ) } else { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { bCabLight = false; if (ggCabLightButton.SubModel) @@ -4589,10 +4589,10 @@ bool TTrain::Update( double const Deltatime ) if (ggUniversal3Button.SubModel) - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) {//z [Ctrl] zapalamy albo gasimy światełko w kabinie //tutaj jest bez sensu, trzeba reagować na wciskanie klawisza! - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) {//zapalenie if (iCabLightFlag<2) ++iCabLightFlag; } @@ -4604,7 +4604,7 @@ bool TTrain::Update( double const Deltatime ) } else {//bez [Ctrl] przełączamy cośtem - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { ggUniversal3Button.PutValue(1); //hunter-131211: z UpdateValue na PutValue - by zachowywal sie jak pozostale przelaczniki @@ -4645,7 +4645,7 @@ bool TTrain::Update( double const Deltatime ) if (Console::Pressed(Global::Keys[k_Univ4])) { if (ggUniversal4Button.SubModel) - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { ActiveUniversal4=true; //ggUniversal4Button.UpdateValue(1); @@ -4662,9 +4662,9 @@ bool TTrain::Update( double const Deltatime ) // swiatla if (Console::Pressed(Global::Keys[k_Univ4])) { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { bCabLightDim = true; if (ggCabLightDimButton.SubModel) @@ -4680,7 +4680,7 @@ bool TTrain::Update( double const Deltatime ) } else { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { bCabLightDim = false; if (ggCabLightDimButton.SubModel) @@ -4720,7 +4720,7 @@ bool TTrain::Update( double const Deltatime ) // ((mvOccupied->BrakeHandle==FV4a)&&(Console::Pressed(Global::Keys[k_IncBrakeLevel]))) if ((Console::Pressed(Global::Keys[k_IncBrakeLevel]))) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { // mvOccupied->BrakeCtrlPos2-=dt/20.0; // if (mvOccupied->BrakeCtrlPos2<-1.5) mvOccupied->BrakeCtrlPos2=-1.5; @@ -4735,7 +4735,7 @@ bool TTrain::Update( double const Deltatime ) // ((mvOccupied->BrakeHandle==FV4a)&&(Console::Pressed(Global::Keys[k_DecBrakeLevel]))) if ((Console::Pressed(Global::Keys[k_DecBrakeLevel]))) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { // mvOccupied->BrakeCtrlPos2+=(mvOccupied->BrakeCtrlPos2>2?0:dt/20.0); // if (mvOccupied->BrakeCtrlPos2<-3) mvOccupied->BrakeCtrlPos2=-3; @@ -4751,7 +4751,7 @@ bool TTrain::Update( double const Deltatime ) if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_IncBrakeLevel]))) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { mvOccupied->BrakeCtrlPos2 -= dt / 20.0; if (mvOccupied->BrakeCtrlPos2 < -1.5) @@ -4768,7 +4768,7 @@ bool TTrain::Update( double const Deltatime ) if ((mvOccupied->BrakeHandle == FV4a) && (Console::Pressed(Global::Keys[k_DecBrakeLevel]))) { - if (Console::Pressed(VK_CONTROL)) + if (Global::ctrlState) { mvOccupied->BrakeCtrlPos2 += (mvOccupied->BrakeCtrlPos2 > 2 ? 0 : dt / 20.0); if (mvOccupied->BrakeCtrlPos2 < -3) @@ -4821,7 +4821,7 @@ bool TTrain::Update( double const Deltatime ) if (Console::Pressed(Global::Keys[k_Main])) //[] { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) ggMainButton.PutValue(1); else ggMainButton.PutValue(0); @@ -4846,10 +4846,10 @@ bool TTrain::Update( double const Deltatime ) } else { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod VK_F3 + { // Ra: było pod GLFW_KEY_F3 if ((mvOccupied->EpFuseSwitch(true))) { dsbPneumaticSwitch->SetVolume(-10); @@ -4860,8 +4860,8 @@ bool TTrain::Update( double const Deltatime ) else { // if (Console::Pressed(k_CurrentNext)) - { // Ra: było pod VK_F3 - if (Console::Pressed(VK_CONTROL)) + { // Ra: było pod GLFW_KEY_F3 + if (Global::ctrlState) { if ((mvOccupied->EpFuseSwitch(false))) { @@ -4890,7 +4890,7 @@ bool TTrain::Update( double const Deltatime ) // Winger 010304 PantAllDownButton if (Console::Pressed(Global::Keys[k_PantFrontUp])) { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) ggPantFrontButton.PutValue(1); else ggPantAllDownButton.PutValue(1); @@ -4903,7 +4903,7 @@ bool TTrain::Update( double const Deltatime ) if (Console::Pressed(Global::Keys[k_PantRearUp])) { - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) ggPantRearButton.PutValue(1); else ggPantFrontButtonOff.PutValue(1); diff --git a/World.cpp b/World.cpp index 6ebe9161..451f9422 100644 --- a/World.cpp +++ b/World.cpp @@ -12,7 +12,10 @@ http://mozilla.org/MPL/2.0/. */ +#include + #include "stdafx.h" + #include "World.h" #include "opengl/glew.h" @@ -44,6 +47,11 @@ TDynamicObject *Controlled = NULL; // pojazd, który prowadzimy const double fTimeMax = 1.00; //[s] maksymalny czas aktualizacji w jednek klatce +extern "C" +{ + GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); //m7todo: potrzebne do directsound +} + TWorld::TWorld() { // randomize(); @@ -92,6 +100,8 @@ void TWorld::TrainDelete(TDynamicObject *d) GLvoid TWorld::glPrint(const char *txt) // custom GL "Print" routine { // wypisywanie tekstu 2D na ekranie + //m7todo + return; if (!txt) return; if (Global::bGlutFont) @@ -164,10 +174,12 @@ BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo) } */ -bool TWorld::Init(HWND NhWnd, HDC hDC) +bool TWorld::Init(GLFWwindow *w) { auto timestart = std::chrono::system_clock::now(); - Global::hWnd = NhWnd; // do WM_COPYDATA + + window = w; + Global::window = w; // do WM_COPYDATA Global::pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań Global::detonatoryOK = true; WriteLog("Starting MaSzyna rail vehicle simulator."); @@ -419,6 +431,8 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) /*--------------------Render Initialization End---------------------*/ + //m7todo: font + /* WriteLog("Font init"); // początek inicjacji fontów 2D if (Global::bGlutFont) // jeśli wybrano GLUT font, próbujemy zlinkować GLUT32.DLL { @@ -459,16 +473,14 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) WriteLog("Display Lists font used."); //+AnsiString(glGetError()) } WriteLog("Font init OK"); //+AnsiString(glGetError()) - + */ Timer::ResetTimers(); - hWnd = NhWnd; glColor4f(1.0f, 3.0f, 3.0f, 0.0f); // SwapBuffers(hDC); // Swap Buffers (Double Buffering) // glClear(GL_COLOR_BUFFER_BIT); // glFlush(); - SetForegroundWindow(hWnd); WriteLog("Sound Init"); glLoadIdentity(); @@ -502,11 +514,14 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.10f); glPrint("Dzwiek / Sound..."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + + glfwSwapBuffers(window); glEnable(GL_LIGHTING); /*-----------------------Sound Initialization-----------------------*/ - TSoundsManager::Init(hWnd); + + TSoundsManager::Init(glfwGetWin32Window(window)); + // TSoundsManager::LoadSounds( "" ); /*---------------------Sound Initialization End---------------------*/ WriteLog("Sound Init OK"); @@ -515,7 +530,8 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.11f); glPrint("OK."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + + glfwSwapBuffers(window); int i; @@ -526,7 +542,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.12f); glPrint("Tekstury / Textures..."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); TTexturesManager::Init(); WriteLog("Textures init OK"); @@ -535,7 +551,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.13f); glPrint("OK."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); WriteLog("Models init"); if (Global::detonatoryOK) @@ -543,7 +559,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.14f); glPrint("Modele / Models..."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); // McZapkie: dodalem sciezke zeby mozna bylo definiowac skad brac modele ale to malo eleganckie // TModelsManager::LoadModels(asModelsPatch); TModelsManager::Init(); @@ -553,7 +569,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.15f); glPrint("OK."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); WriteLog("Ground init"); if (Global::detonatoryOK) @@ -561,9 +577,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.16f); glPrint("Sceneria / Scenery (please wait)..."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); - Ground.Init(Global::SceneryFile, hDC); + Ground.Init(Global::SceneryFile); // Global::tSinceStart= 0; Clouds.Init(); WriteLog("Ground init OK"); @@ -572,7 +588,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.17f); glPrint("OK."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); // TTrack *Track=Ground.FindGroundNode("train_start",TP_TRACK)->pTrack; @@ -589,7 +605,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.18f); glPrint("Przygotowanie kabiny do sterowania..."); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); strcat(buff, Global::asHumanCtrlVehicle.c_str()); WriteLog(buff); @@ -611,7 +627,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glPrint("OK."); } FollowView(); - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); } else { @@ -622,7 +638,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) glRasterPos2f(-0.25f, -0.20f); glPrint("Blad inicjalizacji sterowanego pojazdu!"); } - SwapBuffers(hDC); // Swap Buffers (Double Buffering) + glfwSwapBuffers(window); Controlled = NULL; mvControlled = NULL; Camera.Type = tp_Free; @@ -640,7 +656,7 @@ bool TWorld::Init(HWND NhWnd, HDC hDC) } } FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie - SwapBuffers(hDC); // swap buffers (double buffering) + glfwSwapBuffers(window); Controlled = NULL; mvControlled = NULL; Camera.Type = tp_Free; @@ -685,44 +701,11 @@ void TWorld::OnKeyDown(int cKey) // na każdy kod wirtualny niech przypadają 4 bajty: 2 dla naciśnięcia i 2 dla zwolnienia // powtórzone 256 razy da 1kB na każdy stan przełączników, łącznie będzie 4kB pierwszej tabeli // przekodowania - if (!Global::iPause) - { // podczas pauzy klawisze nie działają - std::string info = "Key pressed: ["; - if (Console::Pressed(VK_SHIFT)) - info += "Shift]+["; - if (Console::Pressed(VK_CONTROL)) - info += "Ctrl]+["; - if (cKey > 192) // coś tam jeszcze ciekawego jest? - { - if (cKey < 255) // 255 to [Fn] w laptopach - WriteLog(info + (char)(cKey - 128) + "]"); - } - else if (cKey >= 186) - WriteLog(info + std::string(";=,-./~").substr(cKey - 186, 1) + "]"); - else if (cKey > 123) // coś tam jeszcze ciekawego jest? - WriteLog(info + std::to_string(cKey) + "]"); // numer klawisza - else if (cKey >= 112) // funkcyjne - WriteLog(info + "F" + std::to_string(cKey - 111) + "]"); - else if (cKey >= 96) - WriteLog(info + "Num" + std::string("0123456789*+?-./").substr(cKey - 96, 1) + "]"); - else if (((cKey >= '0') && (cKey <= '9')) || ((cKey >= 'A') && (cKey <= 'Z')) || - (cKey == ' ')) - WriteLog(info + (char)(cKey) + "]"); - else if (cKey == '-') - WriteLog(info + "Insert]"); - else if (cKey == '.') - WriteLog(info + "Delete]"); - else if (cKey == '$') - WriteLog(info + "Home]"); - else if (cKey == '#') - WriteLog(info + "End]"); - else if (cKey > 'Z') //żeby nie logować kursorów - WriteLog(info + std::to_string(cKey) + "]"); // numer klawisza - } - if ((cKey <= '9') ? (cKey >= '0') : false) // klawisze cyfrowe + //m7todo: printowanie klawiszy? + if (cKey >= '0' && cKey <= '9') { int i = cKey - '0'; // numer klawisza - if (Console::Pressed(VK_SHIFT)) + if (Global::shiftState) { // z [Shift] uruchomienie eventu if (!Global::iPause) // podczas pauzy klawisze nie działają if (KeyEvents[i]) @@ -730,8 +713,8 @@ void TWorld::OnKeyDown(int cKey) } else // zapamiętywanie kamery może działać podczas pauzy if (FreeFlyModeFlag) // w trybie latania można przeskakiwać do ustawionych kamer - if ((Global::iTextMode != VK_F12) && - (Global::iTextMode != VK_F3)) // ograniczamy użycie kamer + if ((Global::iTextMode != GLFW_KEY_F12) && + (Global::iTextMode != GLFW_KEY_F3)) // ograniczamy użycie kamer { if ((!Global::pFreeCameraInit[i].x && !Global::pFreeCameraInit[i].y && !Global::pFreeCameraInit[i].z)) @@ -763,66 +746,56 @@ void TWorld::OnKeyDown(int cKey) } // będzie jeszcze załączanie sprzęgów z [Ctrl] } - else if ((cKey >= VK_F1) ? (cKey <= VK_F12) : false) + else if (cKey >= GLFW_KEY_F1 && cKey <= GLFW_KEY_F12) { switch (cKey) { - case VK_F1: // czas i relacja - case VK_F3: - case VK_F5: // przesiadka do innego pojazdu - case VK_F8: // FPS - case VK_F9: // wersja, typ wyświetlania, błędy OpenGL - case VK_F10: + case GLFW_KEY_F1: // czas i relacja + case GLFW_KEY_F3: + case GLFW_KEY_F5: // przesiadka do innego pojazdu + case GLFW_KEY_F8: // FPS + case GLFW_KEY_F9: // wersja, typ wyświetlania, błędy OpenGL + case GLFW_KEY_F10: if (Global::iTextMode == cKey) Global::iTextMode = - (Global::iPause && (cKey != VK_F1) ? VK_F1 : + (Global::iPause && (cKey != GLFW_KEY_F1) ? GLFW_KEY_F1 : 0); // wyłączenie napisów, chyba że pauza else Global::iTextMode = cKey; break; - case VK_F2: // parametry pojazdu + case GLFW_KEY_F2: // parametry pojazdu if (Global::iTextMode == cKey) // jeśli kolejne naciśnięcie - ++Global::iScreenMode[cKey - VK_F1]; // kolejny ekran + ++Global::iScreenMode[cKey - GLFW_KEY_F1]; // kolejny ekran else { // pierwsze naciśnięcie daje pierwszy (tzn. zerowy) ekran Global::iTextMode = cKey; - Global::iScreenMode[cKey - VK_F1] = 0; + Global::iScreenMode[cKey - GLFW_KEY_F1] = 0; } break; - case VK_F12: // coś tam jeszcze - if (Console::Pressed(VK_CONTROL) && Console::Pressed(VK_SHIFT)) + case GLFW_KEY_F12: + if (Global::ctrlState && Global::shiftState) DebugModeFlag = !DebugModeFlag; // taka opcjonalna funkcja, może się czasem przydać - /* //Ra 2F1P: teraz włączanie i wyłączanie klawiszami cyfrowymi po użyciu [F12] - else if (Console::Pressed(VK_SHIFT)) - {//odpalenie logu w razie "W" - if ((Global::iWriteLogEnabled&2)==0) //nie było okienka - {//otwarcie okna - AllocConsole(); - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN); - } - Global::iWriteLogEnabled|=3; - } */ else Global::iTextMode = cKey; break; - case VK_F4: + case GLFW_KEY_F4: InOutKey(); break; - case VK_F6: + case GLFW_KEY_F6: if (DebugModeFlag) { // przyspieszenie symulacji do testowania scenerii... uwaga na FPS! - // Global::iViewMode=VK_F6; - if (Console::Pressed(VK_CONTROL)) - Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 10.0 : 5.0); + // Global::iViewMode=GLFW_KEY_F6; + if (Global::ctrlState) + Global::fTimeSpeed = (Global::shiftState ? 10.0 : 5.0); else - Global::fTimeSpeed = (Console::Pressed(VK_SHIFT) ? 2.0 : 1.0); + Global::fTimeSpeed = (Global::shiftState ? 2.0 : 1.0); } break; } - // if (cKey!=VK_F4) + // if (cKey!=GLFW_KEY_F4) return; // nie są przekazywane do pojazdu wcale } - if (Global::iTextMode == VK_F10) // wyświetlone napisy klawiszem F10 + if (Global::iTextMode == GLFW_KEY_F10) // wyświetlone napisy klawiszem F10 { // i potwierdzenie if( cKey == 'Y' ) { // flaga wyjścia z programu @@ -831,9 +804,9 @@ void TWorld::OnKeyDown(int cKey) } return; // nie przekazujemy do pociągu } - else if ((Global::iTextMode == VK_F12) ? (cKey >= '0') && (cKey <= '9') : false) + else if ((Global::iTextMode == GLFW_KEY_F12) ? (cKey >= '0') && (cKey <= '9') : false) { // tryb konfiguracji debugmode (przestawianie kamery już wyłączone - if (!Console::Pressed(VK_SHIFT)) // bez [Shift] + if (!Global::shiftState) // bez [Shift] { if (cKey == '1') Global::iWriteLogEnabled ^= 1; // włącz/wyłącz logowanie do pliku @@ -855,7 +828,7 @@ void TWorld::OnKeyDown(int cKey) if (Controlled->MoverParameters->Radio) Ground.RadioStop(Camera.Pos); } - else if (!Global::iPause) //||(cKey==VK_F4)) //podczas pauzy sterownaie nie działa, F4 tak + else if (!Global::iPause) //||(cKey==GLFW_KEY_F4)) //podczas pauzy sterownaie nie działa, F4 tak if (Train) if (Controlled) if ((Controlled->Controller == Humandriver) ? true : DebugModeFlag || (cKey == 'Q')) @@ -867,7 +840,7 @@ void TWorld::OnKeyDown(int cKey) TDynamicObject *temp = Global::DynamicNearest(); if (temp) { - if (GetAsyncKeyState(VK_CONTROL) < 0) // z ctrl odcinanie + if (Global::ctrlState) // z ctrl odcinanie { temp->MoverParameters->BrakeStatus ^= 128; } @@ -884,7 +857,7 @@ void TWorld::OnKeyDown(int cKey) TDynamicObject *temp = Global::DynamicNearest(); if (temp) { - if (Console::Pressed(VK_SHIFT) ? temp->MoverParameters->IncBrakeMult() : + if (Global::shiftState ? temp->MoverParameters->IncBrakeMult() : temp->MoverParameters->DecBrakeMult()) if (Train) { // dźwięk oczywiście jest w kabinie @@ -907,9 +880,9 @@ void TWorld::OnKeyDown(int cKey) CouplNr = 0; // z [-1,1] zrobić [0,1] int mask, set = 0; // Ra: [Shift]+[Ctrl]+[T] odpala mi jakąś idiotyczną zmianę // tapety pulpitu :/ - if (GetAsyncKeyState(VK_SHIFT) < 0) // z [Shift] zapalanie + if (Global::shiftState) // z [Shift] zapalanie set = mask = 64; // bez [Ctrl] założyć tabliczki - else if (GetAsyncKeyState(VK_CONTROL) < 0) + else if (Global::ctrlState) set = mask = 2 + 32; // z [Ctrl] zapalić światła czerwone else mask = 2 + 32 + 64; // wyłączanie ściąga wszystko @@ -929,7 +902,7 @@ void TWorld::OnKeyDown(int cKey) TDynamicObject *temp = Global::DynamicNearest(); if (temp) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if ((temp->MoverParameters->LocalBrake == ManualBrake) || (temp->MoverParameters->MBrake == true)) temp->MoverParameters->IncManualBrakeLevel(1); @@ -949,7 +922,7 @@ void TWorld::OnKeyDown(int cKey) TDynamicObject *temp = Global::DynamicNearest(); if (temp) { - if (GetAsyncKeyState(VK_CONTROL) < 0) + if (Global::ctrlState) if ((temp->MoverParameters->LocalBrake == ManualBrake) || (temp->MoverParameters->MBrake == true)) temp->MoverParameters->DecManualBrakeLevel(1); @@ -1041,7 +1014,7 @@ void TWorld::DistantView() void TWorld::FollowView(bool wycisz) { // ustawienie śledzenia pojazdu // ABu 180404 powrot mechanika na siedzenie albo w okolicę pojazdu - // if (Console::Pressed(VK_F4)) Global::iViewMode=VK_F4; + // if (Console::Pressed(GLFW_KEY_F4)) Global::iViewMode=GLFW_KEY_F4; // Ra: na zewnątrz wychodzimy w Train.cpp Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe if (Controlled) // jest pojazd do prowadzenia? @@ -1196,7 +1169,7 @@ bool TWorld::Update() Ground.UpdatePhys(fMaxDt,n); //Ra: teraz czas kroku jest (względnie) stały if (DebugModeFlag) if (Global::bActive) //nie przyspieszać, gdy jedzie w tle :) - if (GetAsyncKeyState(VK_ESCAPE)<0) + if (GetAsyncKeyState(GLFW_KEY_ESCAPE)<0) {//yB dodał przyspieszacz fizyki Ground.UpdatePhys(fMaxDt,n); Ground.UpdatePhys(fMaxDt,n); @@ -1228,7 +1201,7 @@ bool TWorld::Update() Ground.Update(dt, n); // tu zrobić tylko coklatkową aktualizację przesunięć if (DebugModeFlag) if (Global::bActive) // nie przyspieszać, gdy jedzie w tle :) - if (GetAsyncKeyState(VK_ESCAPE) < 0) + if (Console::Pressed(GLFW_KEY_ESCAPE)) { // yB dodał przyspieszacz fizyki Ground.Update(dt, n); Ground.Update(dt, n); @@ -1268,7 +1241,7 @@ TWorld::Update_Camera( double const Deltatime ) { // Console::Update(); //tu jest zależne od FPS, co nie jest korzystne if( Global::bActive ) { // obsługa ruchu kamery tylko gdy okno jest aktywne - if( Console::Pressed( VK_LBUTTON ) ) { + if( glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS ) { Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe // if (!FreeFlyModeFlag) //jeśli wewnątrz - patrzymy do tyłu // Camera.LookAt=Train->pMechPosition-Normalize(Train->GetDirection())*10; @@ -1294,7 +1267,7 @@ TWorld::Update_Camera( double const Deltatime ) { if( FreeFlyModeFlag ) Camera.RaLook(); // jednorazowe przestawienie kamery } - else if( Console::Pressed( VK_RBUTTON ) ) //||Console::Pressed(VK_F4)) + else if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS ) //||Console::Pressed(GLFW_KEY_F4)) FollowView( false ); // bez wyciszania dźwięków /* else if( Global::iTextMode == -1 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy @@ -1314,7 +1287,7 @@ TWorld::Update_Camera( double const Deltatime ) { tempangle = Controlled->VectorFront() * ( Controlled->MoverParameters->ActiveCab == -1 ? -1 : 1 ); modelrotate = atan2( -tempangle.x, tempangle.z ); - if( Console::Pressed( VK_CONTROL ) ? ( Console::Pressed( Global::Keys[ k_MechLeft ] ) || + if( Global::ctrlState ? ( Console::Pressed( Global::Keys[ k_MechLeft ] ) || Console::Pressed( Global::Keys[ k_MechRight ] ) ) : false ) { // jeśli lusterko lewe albo prawe (bez rzucania na razie) bool lr = Console::Pressed( Global::Keys[ k_MechLeft ] ); @@ -1333,7 +1306,7 @@ TWorld::Update_Camera( double const Deltatime ) { Camera.Yaw = 0; // odchylenie na bok od Camera.LookAt if( Train->Dynamic()->MoverParameters->ActiveCab == 0 ) Camera.LookAt = Camera.Pos - Train->GetDirection(); // gdy w korytarzu - else if( Console::Pressed( VK_SHIFT ) ) { // patrzenie w bok przez szybę + else if( Global::shiftState ) { // patrzenie w bok przez szybę Camera.LookAt = Camera.Pos - ( lr ? -1 : 1 ) * Train->Dynamic()->VectorLeft() * Train->Dynamic()->MoverParameters->ActiveCab; @@ -1780,13 +1753,13 @@ TWorld::Render_UI() { // OutText1+= " Slowing Down !!! "; // } } - /*if (Console::Pressed(VK_F5)) + /*if (Console::Pressed(GLFW_KEY_F5)) {Global::slowmotion=true;}; - if (Console::Pressed(VK_F6)) + if (Console::Pressed(GLFW_KEY_F6)) {Global::slowmotion=false;};*/ - if( Global::iTextMode == VK_F8 ) { - Global::iViewMode = VK_F8; + if( Global::iTextMode == GLFW_KEY_F8 ) { + Global::iViewMode = GLFW_KEY_F8; OutText1 = " FPS: "; OutText1 += to_string( Timer::GetFPS(), 2 ); //OutText1 += sprintf(); @@ -1796,7 +1769,7 @@ TWorld::Render_UI() { OutText1 += to_string( Ground.iRendered ); } - // if (Console::Pressed(VK_F7)) + // if (Console::Pressed(GLFW_KEY_F7)) //{ // OutText1=FloatToStrF(Controlled->MoverParameters->Couplers[0].CouplingFlag,ffFixed,2,0)+", // "; @@ -1804,7 +1777,7 @@ TWorld::Render_UI() { //} /* - if (Console::Pressed(VK_F5)) + if (Console::Pressed(GLFW_KEY_F5)) { int line=2; OutText1="Time: "+FloatToStrF(GlobalTime->hh,ffFixed,2,0)+":" @@ -1831,7 +1804,7 @@ TWorld::Render_UI() { }; // */ /* - if (Console::Pressed(VK_F6)) + if (Console::Pressed(GLFW_KEY_F6)) { //GlobalTime->UpdateMTableTime(100); //OutText1=FloatToStrF(SquareMagnitude(Global::pCameraPosition-Controlled->GetPosition()),ffFixed,10,0); @@ -1918,17 +1891,20 @@ TWorld::Render_UI() { } glDisable( GL_LIGHTING ); + //m7todo: title + /* if( Controlled ) SetWindowText( hWnd, Controlled->MoverParameters->Name.c_str() ); else SetWindowText( hWnd, Global::SceneryFile.c_str() ); // nazwa scenerii + */ glBindTexture( GL_TEXTURE_2D, 0 ); glColor4f( 1.0f, 0.0f, 0.0f, 1.0f ); glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -0.50f ); - if( Global::iTextMode == VK_F1 ) { // tekst pokazywany po wciśnięciu [F1] - // Global::iViewMode=VK_F1; + if( Global::iTextMode == GLFW_KEY_F1 ) { // tekst pokazywany po wciśnięciu [F1] + // Global::iViewMode=GLFW_KEY_F1; glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym OutText1 = "Time: " @@ -1952,16 +1928,16 @@ TWorld::Render_UI() { OutText3 = ""; // Pomoc w sterowaniu - [F9]"; // OutText3=AnsiString(Global::pCameraRotationDeg); //kąt kamery względem północy } - else if( Global::iTextMode == VK_F12 ) { // opcje włączenia i wyłączenia logowania + else if( Global::iTextMode == GLFW_KEY_F12 ) { // opcje włączenia i wyłączenia logowania OutText1 = "[0] Debugmode " + std::string( DebugModeFlag ? "(on)" : "(off)" ); OutText2 = "[1] log.txt " + std::string( ( Global::iWriteLogEnabled & 1 ) ? "(on)" : "(off)" ); OutText3 = "[2] Console " + std::string( ( Global::iWriteLogEnabled & 2 ) ? "(on)" : "(off)" ); } - else if( Global::iTextMode == VK_F2 ) { // ABu: info dla najblizszego pojazdu! + else if( Global::iTextMode == GLFW_KEY_F2 ) { // ABu: info dla najblizszego pojazdu! TDynamicObject *tmp = FreeFlyModeFlag ? Ground.DynamicNearest( Camera.Pos ) : Controlled; // w trybie latania lokalizujemy wg mapy if( tmp ) { - if( Global::iScreenMode[ Global::iTextMode - VK_F1 ] == 0 ) { // jeśli domyślny ekran po pierwszym naciśnięciu + if( Global::iScreenMode[ Global::iTextMode - GLFW_KEY_F1 ] == 0 ) { // jeśli domyślny ekran po pierwszym naciśnięciu OutText3 = ""; OutText1 = "Vehicle name: " + tmp->MoverParameters->Name; // yB OutText1+="; d: "+FloatToStrF(tmp->ABuGetDirection(),ffFixed,2,0); @@ -2155,7 +2131,7 @@ TWorld::Render_UI() { tmp->NextConnected->GetName() + ":" + to_string( tmp->MoverParameters->Couplers[ 1 ].CouplingFlag ) : std::string( "NULL" ) ); - if( Console::Pressed( VK_F2 ) ) { + if( Console::Pressed( GLFW_KEY_F2 ) ) { WriteLog( OutText1 ); WriteLog( OutText2 ); WriteLog( OutText3 ); @@ -2228,7 +2204,7 @@ TWorld::Render_UI() { // OutText3="enrot="+FloatToStrF(Controlled->MoverParameters->enrot,ffFixed,6,2); // OutText3="; n="+FloatToStrF(Controlled->MoverParameters->n,ffFixed,6,2); } // koniec treści podstawowego ekranu FK_V2 - else if( Global::iTextMode == VK_F5 ) { // przesiadka do innego pojazdu + else if( Global::iTextMode == GLFW_KEY_F5 ) { // przesiadka do innego pojazdu if( FreeFlyModeFlag ) // jeśli tryb latania { TDynamicObject *tmp = Ground.DynamicNearest( Camera.Pos, 50, true ); //łapiemy z obsadą @@ -2251,7 +2227,7 @@ TWorld::Render_UI() { else SafeDelete( Train ); // i nie ma czym sterować // Global::pUserDynamic=Controlled; //renerowanie pojazdu względem kabiny - // Global::iTextMode=VK_F4; + // Global::iTextMode=GLFW_KEY_F4; if( Train ) InOutKey(); // do kabiny } @@ -2285,8 +2261,8 @@ TWorld::Render_UI() { } */ } - else if( Global::iTextMode == VK_F10 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy - // Global::iViewMode=VK_F10; + else if( Global::iTextMode == GLFW_KEY_F10 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy + // Global::iViewMode=GLFW_KEY_F10; // return false; OutText1 = ( "To quit press [Y] key." ); OutText3 = ( "Aby zakonczyc program, przycisnij klawisz [Y]." ); @@ -2483,9 +2459,9 @@ TWorld::Render_UI() { // ABu 150205: prosty help, zeby sie na forum nikt nie pytal, jak ma ruszyc :) if( Global::detonatoryOK ) { - // if (Console::Pressed(VK_F9)) ShowHints(); //to nie działa prawidłowo - prosili wyłączyć - if( Global::iTextMode == VK_F9 ) { // informacja o wersji, sposobie wyświetlania i błędach OpenGL - // Global::iViewMode=VK_F9; + // if (Console::Pressed(GLFW_KEY_F9)) ShowHints(); //to nie działa prawidłowo - prosili wyłączyć + if( Global::iTextMode == GLFW_KEY_F9 ) { // informacja o wersji, sposobie wyświetlania i błędach OpenGL + // Global::iViewMode=GLFW_KEY_F9; OutText1 = Global::asVersion; // informacja o wersji OutText2 = std::string( "Rendering mode: " ) + ( Global::bUseVBO ? "VBO" : "Display Lists" ); if( Global::iMultiplayer ) @@ -2497,7 +2473,7 @@ TWorld::Render_UI() { Global::Bezogonkow( ( (char *)gluErrorString( err ) ) ); } } - if( Global::iTextMode == VK_F3 ) { // wyświetlenie rozkładu jazdy, na razie jakkolwiek + if( Global::iTextMode == GLFW_KEY_F3 ) { // wyświetlenie rozkładu jazdy, na razie jakkolwiek TDynamicObject *tmp = FreeFlyModeFlag ? Ground.DynamicNearest( Camera.Pos ) : Controlled; // w trybie latania lokalizujemy wg mapy @@ -2585,7 +2561,7 @@ TWorld::Render_UI() { } } } - // if ((Global::iTextMode!=VK_F3)) + // if ((Global::iTextMode!=GLFW_KEY_F3)) { // stenogramy dźwięków (ukryć, gdy tabelka skanowania lub rozkład?) glColor3f( 1.0f, 1.0f, 0.0f ); //żółte for( int i = 0; i < 5; ++i ) { // kilka linijek diff --git a/World.h b/World.h index 7868971c..acf2bf22 100644 --- a/World.h +++ b/World.h @@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once +#include #include #include "Camera.h" #include "Ground.h" @@ -22,8 +23,8 @@ class TWorld void DistantView(); public: - bool Init(HWND NhWnd, HDC hDC); - HWND hWnd; + bool Init(GLFWwindow *w); + GLFWwindow *window; GLvoid glPrint(const char *fmt); void OnKeyDown(int cKey); void OnKeyUp(int cKey); diff --git a/maszyna.sln b/maszyna.sln index 1c19b757..49bfe6ea 100644 --- a/maszyna.sln +++ b/maszyna.sln @@ -1,25 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "maszyna", "maszyna.vcxproj", "{8E0232E5-1C67-442F-9E04-45ED2DDFC960}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x64.ActiveCfg = Debug|x64 + {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x64.Build.0 = Debug|x64 {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x86.ActiveCfg = Debug|Win32 {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Debug|x86.Build.0 = Debug|Win32 + {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x64.ActiveCfg = Release|x64 + {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x64.Build.0 = Release|x64 {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x86.ActiveCfg = Release|Win32 {8E0232E5-1C67-442F-9E04-45ED2DDFC960}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal diff --git a/maszyna.vcxproj b/maszyna.vcxproj index c0f7ee8a..a4a1c191 100644 --- a/maszyna.vcxproj +++ b/maszyna.vcxproj @@ -1,14 +1,22 @@  - + Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {8E0232E5-1C67-442F-9E04-45ED2DDFC960} @@ -18,12 +26,22 @@ Application true - v120_xp + v140_xp + + + Application + true + v140_xp Application false - v120_xp + v140_xp + + + Application + false + v140_xp @@ -31,20 +49,37 @@ + + + + + + eu07++ $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\ + + eu07++ + eu07++ $(SolutionDir)tmp\$(PlatformShortName)-$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\ false + C:\Users\VB\Desktop\maszyna\lib;$(IncludePath) + C:\Users\VB\Desktop\maszyna\lib-vc2015;$(LibraryPath) + + + false + eu07++ + C:\Users\VB\Desktop\maszyna\lib;$(IncludePath) + C:\Users\VB\Desktop\maszyna\lib-vc2015;$(LibraryPath) @@ -64,6 +99,23 @@ $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories) + + + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + Level3 + ProgramDatabase + $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)opengl;$(SolutionDir)python/include;%(AdditionalIncludeDirectories) + Use + true + false + true + + + true + Windows + $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories) + + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) @@ -83,6 +135,24 @@ $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories) + + + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + $(SolutionDir);$(SolutionDir)console;$(SolutionDir)mczapkie;$(SolutionDir)opengl;$(SolutionDir)python/include;%(AdditionalIncludeDirectories) + Use + true + + + true + Windows + true + true + $(DXSKD_DIR)lib/$(PlatformShortName);$(SolutionDir)opengl;$(SolutionDir)python/libs;%(AdditionalLibraryDirectories) + + @@ -114,7 +184,6 @@ - @@ -125,7 +194,9 @@ Create + Create Create + Create @@ -171,7 +242,6 @@ - diff --git a/maszyna.vcxproj.filters b/maszyna.vcxproj.filters index d18b00e4..4052a36a 100644 --- a/maszyna.vcxproj.filters +++ b/maszyna.vcxproj.filters @@ -13,9 +13,6 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - {d91dfdb6-7d84-4b52-a16a-bad302b45e3c} - {fafd38ab-4c2a-48c8-8e66-ad0d928573b3} @@ -156,9 +153,6 @@ Source Files - - Source Files\opengl - Source Files\mczapkie @@ -191,9 +185,6 @@ Header Files\opengl - - Header Files\opengl - Header Files diff --git a/maszyna.vcxproj.user b/maszyna.vcxproj.user index b99aece4..760c128e 100644 --- a/maszyna.vcxproj.user +++ b/maszyna.vcxproj.user @@ -4,9 +4,18 @@ ..\..\Projects\maszyna WindowsLocalDebugger + + ..\..\Projects\maszyna + WindowsLocalDebugger + ..\..\Projects\maszyna WindowsLocalDebugger _NO_DEBUG_HEAP=1 + + ..\..\Projects\maszyna + WindowsLocalDebugger + _NO_DEBUG_HEAP=1 + \ No newline at end of file diff --git a/opengl/ARB_Multisample.cpp b/opengl/ARB_Multisample.cpp deleted file mode 100644 index 0c58a540..00000000 --- a/opengl/ARB_Multisample.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*======================================================================================== - - Name: ARB_multisample.cpp - Author: Colt "MainRoach" McAnlis - Date: 4/29/04 - Desc: This file contains the context to load a WGL extension from a string - As well as collect the sample format available based upon the graphics card. - -========================================================================================*/ - -#include "stdafx.h" -#include "arb_multisample.h" -#include "glew.h" -#include "wglew.h" - -// Declairations We'll Use -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 - -bool arbMultisampleSupported = false; -int arbMultisampleFormat = 0; - -// WGLisExtensionSupported: This Is A Form Of The Extension For WGL -bool WGLisExtensionSupported(const char *extension) -{ - const size_t extlen = strlen(extension); - const char *supported = NULL; - - // Try To Use wglGetExtensionStringARB On Current DC, If Possible - PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB"); - - if (wglGetExtString) - supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC()); - - // If That Failed, Try Standard Opengl Extensions String - if (supported == NULL) - supported = (char*)glGetString(GL_EXTENSIONS); - - // If That Failed Too, Must Be No Extensions Supported - if (supported == NULL) - return false; - - // Begin Examination At Start Of String, Increment By 1 On False Match - for (const char* p = supported; ; p++) - { - // Advance p Up To The Next Possible Match - p = strstr(p, extension); - - if (p == NULL) - return false; // No Match - - // Make Sure That Match Is At The Start Of The String Or That - // The Previous Char Is A Space, Or Else We Could Accidentally - // Match "wglFunkywglExtension" With "wglExtension" - - // Also, Make Sure That The Following Character Is Space Or NULL - // Or Else "wglExtensionTwo" Might Match "wglExtension" - if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' ')) - return true; // Match - } -} - -int InitMultisample(HINSTANCE hInstance,HWND hWnd,PIXELFORMATDESCRIPTOR pfd,int mode) -{//used to query the multisample frequencies - arbMultisampleSupported=false; - //see if the string exists in WGL! - if (!WGLisExtensionSupported("WGL_ARB_multisample")) - return 0; - //get our pixel format - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB=(PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); - if (!wglChoosePixelFormatARB) - return 0; - //get our current device context - HDC hDC=GetDC(hWnd); - int pixelFormat; - int valid; - UINT numFormats; - float fAttributes[]={0,0}; - // These attributes are the bits we want to test for in our sample - // everything is pretty standard, the only one we want to - // really focus on is the SAMPLE BUFFERS ARB and WGL SAMPLES - // these two are going to do the main testing for whether or not - // we support multisampling on this hardware. - int iAttributes[]= - { - WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, - WGL_SUPPORT_OPENGL_ARB,GL_TRUE, - WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB,24, - WGL_ALPHA_BITS_ARB,8, - WGL_DEPTH_BITS_ARB,16, - WGL_STENCIL_BITS_ARB,0, - WGL_DOUBLE_BUFFER_ARB,GL_TRUE, - WGL_SAMPLE_BUFFERS_ARB,GL_TRUE, - WGL_SAMPLES_ARB,mode, - 0,0 - }; -/* - //first we check to see if we can get a pixel format for 4 samples - valid=wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats); - if (valid&&(numFormats>=1)) - {//if we returned true, and our format count is greater than 1 - arbMultisampleSupported=true; - arbMultisampleFormat=pixelFormat; - return arbMultisampleSupported; - } -*/ - while (iAttributes[19]>1) - {//our pixel format with (mode) samples failed, test for less samples - valid=wglChoosePixelFormatARB(hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats); - if (valid&&(numFormats>=1)) - {//if we returned true, and our format count is greater than 1 - arbMultisampleSupported=true; - arbMultisampleFormat=pixelFormat; - return iAttributes[19]; //return number of samples - } - iAttributes[19]>>=1; - } - return 0; -} diff --git a/opengl/ARB_Multisample.h b/opengl/ARB_Multisample.h deleted file mode 100644 index a688e851..00000000 --- a/opengl/ARB_Multisample.h +++ /dev/null @@ -1,25 +0,0 @@ -/*==================================== - Name: ARB_multisample.h - Author: Colt "MainRoach" McAnlis - Date: 4/29/04 - Desc: - This file contains our external items - -====================================*/ - -#ifndef __ARB_MULTISAMPLE_H__ -#define __ARB_MULTISAMPLE_H__ - -#include - -//Globals -extern bool arbMultisampleSupported; -extern int arbMultisampleFormat; - -//If you don't want multisampling, set this to 0 -#define CHECK_FOR_MULTISAMPLE 1 - -//to check for our sampling -int InitMultisample(HINSTANCE hInstance,HWND hWnd,PIXELFORMATDESCRIPTOR pfd,int mode=4); - -#endif diff --git a/stdafx.h b/stdafx.h index 22d52bd3..8c369415 100644 --- a/stdafx.h +++ b/stdafx.h @@ -57,3 +57,9 @@ #include #include #include + +#include "opengl/glew.h" +#include "opengl/wglew.h" + +//m7todo: jest tu bo nie chciao mi si wpycha do wszystkich plikw +#include \ No newline at end of file