2 Commits

Author SHA1 Message Date
9a08770e6f przywrócenie trybu wydajności (jako komentarz), uprzątnięcie kodu 2025-01-08 05:38:53 +01:00
Pc
fa824192b7 To co w nazwie brancha + konsola w vsc 2025-01-07 23:16:46 +01:00

View File

@@ -75,46 +75,12 @@ void SetDCPixelFormat(HDC hDC);
int polygonmode = 0; int polygonmode = 0;
std::time_t lastTime = std::time(nullptr); std::time_t lastTime = std::time(nullptr);
int monitormode = 0; int monitormode = 1;
int monitormodecounter = 0; int monitormodecounter = 0;
std::time_t monitormodehelper; std::time_t monitormodehelper;
//Zmienne do ruchu ##############################################
/*
float Foward = 0.0f; // Pozycja łazika w przód/tył
float Sides = 0.0f; // Pozycja łazika w lewo/prawo
float Rotation = 0.0f; // Rotacja łazika (w stopniach)
// Zmienne do sterowania kamerą
float CameraHeight = 50.0f; // Wysokość kamery
void MoveRover(bool forward) {
// Zamieniamy kąt na radiany
float radRotation = Rotation * GL_PI / 180.0f;
// Wektor ruchu w kierunku przód/tył (kierunek łazika)
float moveX = cos(radRotation);
float moveZ = sin(radRotation);
// Ruch w przód
if (forward) {
Sides -= 1.1f * moveX;
Foward -= 1.1f * moveZ;
}
// Ruch w tył
else {
Sides += 1.1f * moveX;
Foward += 1.1f * moveZ;
}
}
// Funkcja do obrotu kamery i łazika (A/D)
void RotateRoverAndCamera(float angle) {
Rotation += angle;
if (Rotation >= 360.0f) Rotation -= 360.0f;
if (Rotation < 0.0f) Rotation += 360.0f;
}
*/
//Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FPSCounter fpsCounter; FPSCounter fpsCounter;
static const int targetFPS = 144; // Celowany FPS static const int targetFPS = 144; // Celowany FPS
@@ -148,11 +114,11 @@ float MoveSpeed = 1.0f; // Prędkość poruszania się
float velocity = 0.0f; // Aktualna prędkość łazika float velocity = 0.0f; // Aktualna prędkość łazika
const float friction = 0.1f; // Współczynnik tarcia (μ) const float friction = 0.1f; // Współczynnik tarcia (μ)
const float maxSpeed = 3.0f; // Maksymalna prędkość łazika const float maxSpeed = 3.0f; // Maksymalna prędkość łazika
const float acceleration = 0.1f; const float acceleration = 0.2f;
float rotationVelocity = 0.0f; // Prędkość obrotu łazika float rotationVelocity = 0.0f; // Prędkość obrotu łazika
const float rotationAcceleration = 0.1f; // Przyspieszenie obrotu const float rotationAcceleration = 0.1f; // Przyspieszenie obrotu
const float rotationFriction = 0.05f; // Współczynnik tarcia obrotu const float rotationFriction = 0.05f; // Współczynnik tarcia obrotu
const float maxRotationSpeed = 5.0f; // Maksymalna prędkość obrotu const float maxRotationSpeed = 3.0f; // Maksymalna prędkość obrotu
@@ -825,19 +791,7 @@ void RenderScene(void) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} }
// prymitywny licznik FPS
if (monitormode) {
std::time_t now_t = std::time(nullptr);
//yRot -= 1; // showcase demo
if (now_t > monitormodehelper) {
std::cout << (int)(monitormodecounter / (now_t - monitormodehelper)) << " fps\n";
monitormodehelper = now_t;
monitormodecounter = 0;
}
else {
monitormodecounter++;
}
}
// Clear the screen // Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -998,7 +952,7 @@ void CreateConsole() {
freopen_s(&conerr, "conout$", "w", stderr); freopen_s(&conerr, "conout$", "w", stderr);
} }
else { else {
MessageBox(NULL, "Nie udało się utworzyć konsoli.", "Błąd", MB_OK | MB_ICONERROR); MessageBox(NULL, "Nie udalo sie utworzyc konsoli.", "Blad", MB_OK | MB_ICONERROR);
} }
} }
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
@@ -1085,11 +1039,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// Create palette if needed // Create palette if needed
hPalette = GetOpenGLPalette(hDC); hPalette = GetOpenGLPalette(hDC);
// Create the rendering context and make it current
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
SetupRC();
// Create the rendering context and make it current // Create the rendering context and make it current
hRC = wglCreateContext(hDC); hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC); wglMakeCurrent(hDC, hRC);
@@ -1208,14 +1157,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// Validate the newly painted client area // Validate the newly painted client area
if (!monitormode) ValidateRect(hWnd, NULL); if (!monitormode) ValidateRect(hWnd, NULL);
else InvalidateRect(hWnd, NULL, FALSE); else InvalidateRect(hWnd, NULL, FALSE);
break; //break;
// Limit FPS // Limit FPS
LimitFPS(targetFPS); LimitFPS(targetFPS);
// Update FPS counter // Update FPS counter
fpsCounter.update(); if (monitormode) fpsCounter.update();
break; break;
case WM_QUERYNEWPALETTE: case WM_QUERYNEWPALETTE:
// If the palette was created. // If the palette was created.
if (hPalette) { if (hPalette) {
@@ -1254,28 +1204,32 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_KEYUP: case WM_KEYUP:
switch (wParam) { switch (wParam) {
case 'W': case 'W':
keyWPressed = false; keyWPressed = false;
break; break;
case 'S': case 'S':
keySPressed = false; keySPressed = false;
break; break;
case 'A': case 'A':
keyAPressed = false; keyAPressed = false;
break; break;
case 'D': case 'D':
keyDPressed = false; keyDPressed = false;
break; break;
// Obsługa innych klawiszy // Obsługa innych klawiszy
} }
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
switch (wParam) { switch (wParam) {
case VK_UP: case VK_UP:
@@ -1316,24 +1270,27 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case 'W': case 'W':
keyWPressed = true; keyWPressed = true;
break; break;
case 'S': case 'S':
keySPressed = true; keySPressed = true;
break; break;
case 'A': case 'A':
keyAPressed = true; keyAPressed = true;
break; break;
case 'D': case 'D':
keyDPressed = true; keyDPressed = true;
break; break;
case 114: // F3 // case 114: // F3
monitormode = !monitormode; // monitormode = !monitormode;
if (monitormode) { // if (monitormode) {
monitormodehelper = std::time(nullptr) - 1; // monitormodehelper = std::time(nullptr) - 1;
timestampedCout("Wlaczono tryb monitorowania wydajnosci."); // timestampedCout("Wlaczono tryb monitorowania wydajnosci.");
} // }
if (!monitormode) timestampedCout("Wylaczono tryb monitorowania wydajnosci."); // if (!monitormode) timestampedCout("Wylaczono tryb monitorowania wydajnosci.");
break; // break;
default: default:
timestampedCout("Nacisnieto nierozpoznany klawisz: " << (int)wParam); timestampedCout("Nacisnieto nierozpoznany klawisz: " << (int)wParam);
@@ -1363,6 +1320,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_TIMER: case WM_TIMER:
RenderScene(); RenderScene();