poprawiony model łazika (lazik4.obj, stoi tyłem), prymitywany licznik fps

This commit is contained in:
2024-11-29 01:50:22 +01:00
parent 1f00df1842
commit ef1a8b225b
4 changed files with 7461 additions and 3 deletions

14
.gitignore vendored Normal file
View File

@@ -0,0 +1,14 @@
# Czarna lista plików przy commitowaniu
# (pliki do zignorowania przy udostępnianiu)
# folder z rzeczami z visual studio
.vs
# pliki wykonywalne, binarne
grafikaKBT
x64
output.exe
# obiekty testowe
res/models/lazik.obj
res/models/lazik2.obj
res/models/lazik4,5.obj

View File

@@ -67,6 +67,10 @@ BOOL APIENTRY AboutDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
void SetDCPixelFormat(HDC hDC); void SetDCPixelFormat(HDC hDC);
int polygonmode = 0; int polygonmode = 0;
std::time_t lastTime = std::time(nullptr);
int monitormode = 0;
int monitormodecounter = 0;
std::time_t monitormodehelper;
// Change viewing volume and viewport. Called when window is resized // Change viewing volume and viewport. Called when window is resized
void ChangeSize(GLsizei w, GLsizei h) { void ChangeSize(GLsizei w, GLsizei h) {
@@ -195,7 +199,6 @@ std::vector <glm::vec2> uvs;
std::vector <glm::vec3> normals; // Won't be used at the moment. std::vector <glm::vec3> normals; // Won't be used at the moment.
GLuint vertexbuffer; GLuint vertexbuffer;
GLuint uvbuffer; GLuint uvbuffer;
std::time_t lastTime = std::time(nullptr);
void SetupRC() { void SetupRC() {
// Light values and coordinates // Light values and coordinates
@@ -253,7 +256,7 @@ void SetupRC() {
// TODO: zmierzyć czas ładowania łazika w cyklach procesora/mikrosekundach // TODO: zmierzyć czas ładowania łazika w cyklach procesora/mikrosekundach
timestampedCout("Ladowanie lazika..."); timestampedCout("Ladowanie lazika...");
bool res = loadOBJ("res/models/lazik3.obj", vertices, uvs, normals); bool res = loadOBJ("res/models/lazik4.obj", vertices, uvs, normals);
// bool res = loadOBJ("res/models/suzanne.obj", vertices, uvs, normals); // bool res = loadOBJ("res/models/suzanne.obj", vertices, uvs, normals);
if (res) timestampedCout("Pomyslnie zaladowano model lazika.") if (res) timestampedCout("Pomyslnie zaladowano model lazika.")
@@ -297,6 +300,18 @@ 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);
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);
@@ -668,8 +683,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (polygonmode) timestampedCout("Uwaga! Tryb wireframe jest niewydajny i powinien sluzyc tylko do debugowania!"); if (polygonmode) timestampedCout("Uwaga! Tryb wireframe jest niewydajny i powinien sluzyc tylko do debugowania!");
break; break;
case 114: // F3
monitormode = !monitormode;
if (monitormode) {
monitormodehelper = std::time(nullptr) - 1;
timestampedCout("Wlaczono tryb monitorowania wydajnosci.");
}
if (!monitormode) timestampedCout("Wylaczono tryb monitorowania wydajnosci.");
break;
default: default:
getTime;
timestampedCout("Nacisnieto nierozpoznany klawisz: " << (int)wParam); timestampedCout("Nacisnieto nierozpoznany klawisz: " << (int)wParam);
} }

Binary file not shown.

7421
res/models/lazik4.obj Normal file

File diff suppressed because it is too large Load Diff