Compare commits
11 Commits
bea13b98f3
...
Kolizja-Po
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b01fa46b8a | ||
|
|
4759a5419e | ||
| 49fee6ded8 | |||
| b805164ad4 | |||
| e9fba90fa2 | |||
|
|
7d33f8a997 | ||
|
|
1a85de2c23 | ||
|
|
f0a3221e04 | ||
|
|
951b25a5a3 | ||
|
|
4b9503eeec | ||
|
|
735859ed58 |
@@ -13,7 +13,7 @@ public:
|
|||||||
// Aktualizujemy FPS co 1 sekundê
|
// Aktualizujemy FPS co 1 sekundê
|
||||||
if (elapsed.count() >= 1.0) {
|
if (elapsed.count() >= 1.0) {
|
||||||
double fps = frameCount / elapsed.count();
|
double fps = frameCount / elapsed.count();
|
||||||
std::cout << "FPS: " << fps << std::endl;
|
std::cout << "FPS: " << fps << "\n";
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|||||||
336
main.cpp
336
main.cpp
@@ -83,12 +83,12 @@ std::time_t monitormodehelper;
|
|||||||
|
|
||||||
//Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
//Zmienne do ruchu ##############################################^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
FPSCounter fpsCounter;
|
FPSCounter fpsCounter;
|
||||||
|
|
||||||
static const int targetFPS = 144; // Celowany FPS
|
static const int targetFPS = 144; // Celowany FPS
|
||||||
//Fps counter
|
//Fps counter
|
||||||
|
static void LimitFPS(int targetFPS) {
|
||||||
void LimitFPS(int targetFPS) {
|
static auto lastTime = std::chrono::high_resolution_clock::now();
|
||||||
static auto lastTime = std::chrono::steady_clock::now();
|
auto currentTime = std::chrono::high_resolution_clock::now();
|
||||||
auto currentTime = std::chrono::steady_clock::now();
|
|
||||||
std::chrono::duration<double> elapsed = currentTime - lastTime;
|
std::chrono::duration<double> elapsed = currentTime - lastTime;
|
||||||
|
|
||||||
// Obliczamy czas na jedną klatkę
|
// Obliczamy czas na jedną klatkę
|
||||||
@@ -118,15 +118,17 @@ 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.05f; // Współczynnik tarcia (μ)
|
|
||||||
const float maxSpeed = 3.0f; // Maksymalna prędkość łazika
|
|
||||||
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 rotationFriction = 0.05f; // Współczynnik tarcia obrotu
|
const float friction = 0.1f; // Współczynnik tarcia (μ)
|
||||||
const float maxRotationSpeed = 3.0f; // Maksymalna prędkość obrotu
|
const float maxSpeed = 5.0f; // Maksymalna prędkość łazika
|
||||||
|
const float acceleration = 0.2f;
|
||||||
|
|
||||||
|
|
||||||
|
const float rotationAcceleration = 0.075f; // Przyspieszenie obrotu
|
||||||
|
const float rotationFriction = 0.1f; // Współczynnik tarcia obrotu
|
||||||
|
const float maxRotationSpeed = 0.7f; // Maksymalna prędkość obrotu
|
||||||
|
|
||||||
// Struktura do reprezentacji płotu
|
// Struktura do reprezentacji płotu
|
||||||
struct Plot {
|
struct Plot {
|
||||||
@@ -140,7 +142,7 @@ struct Plot {
|
|||||||
|
|
||||||
// Funkcja sprawdzająca kolizję z płotem
|
// Funkcja sprawdzająca kolizję z płotem
|
||||||
// Funkcja sprawdzająca kolizję z płotem, uwzględniając wymiary łazika
|
// Funkcja sprawdzająca kolizję z płotem, uwzględniając wymiary łazika
|
||||||
bool CheckFenceCollision(float roverXMin, float roverXMax, float roverZMin, float roverZMax, const Plot& plot) {
|
static bool CheckFenceCollision(float roverXMin, float roverXMax, float roverZMin, float roverZMax, const Plot& plot) {
|
||||||
if (plot.mod_x == 0) { // Płot pionowy (równoległy do osi Z)
|
if (plot.mod_x == 0) { // Płot pionowy (równoległy do osi Z)
|
||||||
float xMin = plot.xc - plot.gruboscY / 2.0f;
|
float xMin = plot.xc - plot.gruboscY / 2.0f;
|
||||||
float xMax = plot.xc + plot.gruboscY / 2.0f;
|
float xMax = plot.xc + plot.gruboscY / 2.0f;
|
||||||
@@ -169,7 +171,7 @@ bool CheckFenceCollision(float roverXMin, float roverXMax, float roverZMin, floa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Funkcja ogólna do sprawdzania kolizji ze wszystkimi płotami
|
// Funkcja ogólna do sprawdzania kolizji ze wszystkimi płotami
|
||||||
bool CheckAllFencesCollision(float roverXMin, float roverXMax, float roverZMin, float roverZMax, const std::vector<Plot>& fences) {
|
static bool CheckAllFencesCollision(float roverXMin, float roverXMax, float roverZMin, float roverZMax, const std::vector<Plot>& fences) {
|
||||||
for (const auto& fence : fences) {
|
for (const auto& fence : fences) {
|
||||||
if (CheckFenceCollision(roverXMin, roverXMax, roverZMin, roverZMax, fence)) {
|
if (CheckFenceCollision(roverXMin, roverXMax, roverZMin, roverZMax, fence)) {
|
||||||
return true; // Kolizja wykryta z którymś płotem
|
return true; // Kolizja wykryta z którymś płotem
|
||||||
@@ -178,7 +180,7 @@ bool CheckAllFencesCollision(float roverXMin, float roverXMax, float roverZMin,
|
|||||||
return false; // Brak kolizji
|
return false; // Brak kolizji
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateRover(const std::vector<Plot>& fences) {
|
static void UpdateRover(const std::vector<Plot>& fences) {
|
||||||
// Przyspieszanie w przód
|
// Przyspieszanie w przód
|
||||||
if (keyWPressed) {
|
if (keyWPressed) {
|
||||||
velocity += acceleration;
|
velocity += acceleration;
|
||||||
@@ -201,7 +203,7 @@ void UpdateRover(const std::vector<Plot>& fences) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obracanie
|
// Obracanie (rotacja z driftowaniem)
|
||||||
if (keyAPressed) {
|
if (keyAPressed) {
|
||||||
rotationVelocity += rotationAcceleration;
|
rotationVelocity += rotationAcceleration;
|
||||||
if (rotationVelocity > maxRotationSpeed) rotationVelocity = maxRotationSpeed;
|
if (rotationVelocity > maxRotationSpeed) rotationVelocity = maxRotationSpeed;
|
||||||
@@ -211,13 +213,14 @@ void UpdateRover(const std::vector<Plot>& fences) {
|
|||||||
if (rotationVelocity < -maxRotationSpeed) rotationVelocity = -maxRotationSpeed;
|
if (rotationVelocity < -maxRotationSpeed) rotationVelocity = -maxRotationSpeed;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Hamowanie obrotu (wytracanie prędkości z powodu tarcia)
|
// Jeśli żadna z klawiszy A/D nie jest wciśnięta, to stopniowo spowalniamy rotację (drift)
|
||||||
|
float driftFactor = 0.1f; // Mniejsza wartość = dłuższy drift
|
||||||
if (rotationVelocity > 0) {
|
if (rotationVelocity > 0) {
|
||||||
rotationVelocity -= rotationFriction;
|
rotationVelocity -= rotationFriction * driftFactor;
|
||||||
if (rotationVelocity < 0) rotationVelocity = 0;
|
if (rotationVelocity < 0) rotationVelocity = 0;
|
||||||
}
|
}
|
||||||
else if (rotationVelocity < 0) {
|
else if (rotationVelocity < 0) {
|
||||||
rotationVelocity += rotationFriction;
|
rotationVelocity += rotationFriction * driftFactor;
|
||||||
if (rotationVelocity > 0) rotationVelocity = 0;
|
if (rotationVelocity > 0) rotationVelocity = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,18 +230,22 @@ void UpdateRover(const std::vector<Plot>& fences) {
|
|||||||
float newSides = Sides - velocity * cos(radRotation); // Nowa pozycja w osi X
|
float newSides = Sides - velocity * cos(radRotation); // Nowa pozycja w osi X
|
||||||
float newFoward = Foward - velocity * sin(radRotation); // Nowa pozycja w osi Z
|
float newFoward = Foward - velocity * sin(radRotation); // Nowa pozycja w osi Z
|
||||||
|
|
||||||
|
// Wymiary łazika (połówki w osi X i Z)
|
||||||
|
const float roverHalfWidthX = 19.0f; // 38/2
|
||||||
|
const float roverHalfLengthZ = 12.0f; // 24/2
|
||||||
|
|
||||||
// Wyliczenie obszaru zajmowanego przez łazik
|
// Wyliczenie obszaru zajmowanego przez łazik
|
||||||
float roverXMin = newSides - 15.0f;
|
float roverXMin = newSides - roverHalfWidthX;
|
||||||
float roverXMax = newSides + 15.0f;
|
float roverXMax = newSides + roverHalfWidthX;
|
||||||
float roverZMin = newFoward - 15.0f;
|
float roverZMin = newFoward - roverHalfLengthZ;
|
||||||
float roverZMax = newFoward + 15.0f;
|
float roverZMax = newFoward + roverHalfLengthZ;
|
||||||
|
|
||||||
// Sprawdzanie kolizji przed aktualizacją pozycji
|
// Sprawdzanie kolizji przed aktualizacją pozycji
|
||||||
if (Kolizja == true) {
|
if (!Kolizja == true) {
|
||||||
if (CheckAllFencesCollision(roverXMin, roverXMax, roverZMin, roverZMax, fences)) {
|
if (CheckAllFencesCollision(roverZMin, roverZMax, roverXMin, roverXMax, fences)) {
|
||||||
// Jeśli jest kolizja, zatrzymujemy łazik
|
// Jeśli jest kolizja, zatrzymujemy łazik
|
||||||
velocity = 0.0f;
|
velocity = 0.0f;
|
||||||
cout << "Kolizja podczas ruchu\n";
|
//cout << "Kolizja podczas ruchu\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Jeśli brak kolizji, aktualizujemy pozycję
|
// Jeśli brak kolizji, aktualizujemy pozycję
|
||||||
@@ -248,27 +255,44 @@ void UpdateRover(const std::vector<Plot>& fences) {
|
|||||||
|
|
||||||
// Sprawdzanie kolizji podczas obrotu
|
// Sprawdzanie kolizji podczas obrotu
|
||||||
if (rotationVelocity != 0.0f) {
|
if (rotationVelocity != 0.0f) {
|
||||||
// Wyliczamy narożniki łazika po obrocie
|
// Wyliczamy nową rotację
|
||||||
float newRotation = Rotation + rotationVelocity;
|
float newRotation = Rotation + rotationVelocity;
|
||||||
float radNewRotation = newRotation * GL_PI / 180.0f;
|
float radNewRotation = newRotation * GL_PI / 180.0f;
|
||||||
|
|
||||||
// Wyliczamy offsety narożników w nowych współrzędnych
|
// Obracamy narożniki łazika
|
||||||
float offsetX = 15.0f * cos(radNewRotation);
|
std::vector<std::pair<float, float>> corners(4);
|
||||||
float offsetZ = 15.0f * sin(radNewRotation);
|
corners[0] = {Sides - roverHalfWidthX, Foward - roverHalfLengthZ}; // Lewy dolny
|
||||||
|
corners[1] = {Sides + roverHalfWidthX, Foward - roverHalfLengthZ}; // Prawy dolny
|
||||||
|
corners[2] = {Sides - roverHalfWidthX, Foward + roverHalfLengthZ}; // Lewy górny
|
||||||
|
corners[3] = {Sides + roverHalfWidthX, Foward + roverHalfLengthZ}; // Prawy górny
|
||||||
|
bool collisionDetected = false;
|
||||||
|
// Obracamy wszystkie narożniki
|
||||||
|
for (auto& corner : corners) {
|
||||||
|
float x = corner.first;
|
||||||
|
float z = corner.second;
|
||||||
|
|
||||||
// Wyznaczamy nowe granice łazika
|
corner.first = Sides + (x - Sides) * cos(radNewRotation) - (z - Foward) * sin(radNewRotation);
|
||||||
float rotatedXMin = Sides - offsetX;
|
corner.second = Foward + (x - Sides) * sin(radNewRotation) + (z - Foward) * cos(radNewRotation);
|
||||||
float rotatedXMax = Sides + offsetX;
|
|
||||||
float rotatedZMin = Foward - offsetZ;
|
|
||||||
float rotatedZMax = Foward + offsetZ;
|
|
||||||
|
|
||||||
// Sprawdzamy kolizję dla granic po obrocie
|
|
||||||
if (CheckAllFencesCollision(rotatedXMin, rotatedXMax, rotatedZMin, rotatedZMax, fences)) {
|
// Sprawdzamy kolizję na podstawie obróconych narożników
|
||||||
rotationVelocity = 0.0f; // Zatrzymujemy obrót w przypadku kolizji
|
|
||||||
cout << "Kolizja podczas obrotu\n";
|
|
||||||
|
if (CheckAllFencesCollision(corner.first, corner.first, corner.second, corner.second, fences)) {
|
||||||
|
collisionDetected = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
if (CheckAllFencesCollision( corner.second, corner.second, corner.first, corner.first, fences)) {
|
||||||
// Aktualizujemy rotację tylko, jeśli nie ma kolizji
|
collisionDetected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collisionDetected) {
|
||||||
|
rotationVelocity = 0.0f; // Zatrzymujemy obrót
|
||||||
|
//cout << "Kolizja podczas obrotu\n";
|
||||||
|
} else {
|
||||||
|
// Aktualizujemy rotację, jeśli nie ma kolizji
|
||||||
Rotation = newRotation;
|
Rotation = newRotation;
|
||||||
if (Rotation >= 360.0f) Rotation -= 360.0f;
|
if (Rotation >= 360.0f) Rotation -= 360.0f;
|
||||||
if (Rotation < 0.0f) Rotation += 360.0f;
|
if (Rotation < 0.0f) Rotation += 360.0f;
|
||||||
@@ -286,15 +310,19 @@ void UpdateRover(const std::vector<Plot>& fences) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<Plot> fences = {
|
std::vector<Plot> fences = {
|
||||||
{-10.0f, 3.0f, 45.0f, 130.0f, 4.0f, 0},
|
{-550.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0}, // 0 - pionowo
|
||||||
{ 50.0f, 3.0f, -20.0f, 120.0f, 4.0f, 1},
|
{ 50.0f, 3.0f, -600.0f, 1200.0f, 4.0f, 1}, // 1 - poziomo
|
||||||
{110.0f, 3.0f, 45.0f, 130.0f, 4.0f, 0},
|
{ 650.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0}, // 0 - pionowo
|
||||||
{ 50.0f, 3.0f, 110.0f, 120.0f, 4.0f, 1}
|
{ 50.0f, 3.0f, 695.0f, 1200.0f, 4.0f, 1} // 1 - poziomo
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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 static ChangeSize(GLsizei w, GLsizei h) {
|
||||||
GLfloat nRange = 100.0f;
|
GLfloat nRange = 100.0f;
|
||||||
//GLfloat fAspect;
|
//GLfloat fAspect;
|
||||||
// Prevent a divide by zero
|
// Prevent a divide by zero
|
||||||
@@ -332,7 +360,7 @@ void ChangeSize(GLsizei w, GLsizei h) {
|
|||||||
// opis: ładuje mapę bitową z pliku i zwraca jej adres.
|
// opis: ładuje mapę bitową z pliku i zwraca jej adres.
|
||||||
// Wypełnia strukturę nagłówka.
|
// Wypełnia strukturę nagłówka.
|
||||||
// Nie obsługuje map 8-bitowych.
|
// Nie obsługuje map 8-bitowych.
|
||||||
unsigned char* LoadBitmapFile(char* filename, BITMAPINFOHEADER* bitmapInfoHeader) {
|
static unsigned char* LoadBitmapFile(char* filename, BITMAPINFOHEADER* bitmapInfoHeader) {
|
||||||
FILE* filePtr; // wskaźnik pozycji pliku
|
FILE* filePtr; // wskaźnik pozycji pliku
|
||||||
BITMAPFILEHEADER bitmapFileHeader; // nagłówek pliku
|
BITMAPFILEHEADER bitmapFileHeader; // nagłówek pliku
|
||||||
unsigned char* bitmapImage; // dane obrazu
|
unsigned char* bitmapImage; // dane obrazu
|
||||||
@@ -417,7 +445,7 @@ void SetDCPixelFormat(HDC hDC) {
|
|||||||
SetPixelFormat(hDC, nPixelFormat, &pfd);
|
SetPixelFormat(hDC, nPixelFormat, &pfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void skrzynka(GLfloat k) {
|
static void skrzynka(GLfloat k) {
|
||||||
glColor3d(0.8, 0.7, 0.3);
|
glColor3d(0.8, 0.7, 0.3);
|
||||||
|
|
||||||
|
|
||||||
@@ -470,24 +498,29 @@ void skrzynka(GLfloat k) {
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen) {
|
static void platforma(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat xlen, GLfloat zlen) {
|
||||||
|
glColor3d(0.729, 0.91, 0.51); // jasnozielony, dla grass02.bmp
|
||||||
|
|
||||||
glColor3d(0.729, 0.91, 0.51); // jasnozielony, dla grass02.bmp (https://rgbcolorpicker.com/0-1)
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture[1]); // Wybieramy teksturę
|
||||||
|
|
||||||
|
// Ustawienie powtarzania tekstury
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Powtarzanie w kierunku S
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Powtarzanie w kierunku T
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[1]);
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2d(1.0, 1.0); glVertex3d(xc - xlen, yc, zc - zlen);
|
// Powtarzające się współrzędne tekstury (np. *5, aby powtórzyła się 5 razy)
|
||||||
glTexCoord2d(1.0, 0.0); glVertex3d(xc + xlen, yc, zc - zlen);
|
glTexCoord2d(5.0, 5.0); glVertex3d(xc - xlen, yc, zc - zlen); // Lewy dolny
|
||||||
glTexCoord2d(0.0, 0.0); glVertex3d(xc + xlen, yc, zc + zlen);
|
glTexCoord2d(5.0, 0.0); glVertex3d(xc + xlen, yc, zc - zlen); // Prawy dolny
|
||||||
glTexCoord2d(0.0, 1.0); glVertex3d(xc - xlen, yc, zc + zlen);
|
glTexCoord2d(0.0, 0.0); glVertex3d(xc + xlen, yc, zc + zlen); // Prawy górny
|
||||||
|
glTexCoord2d(0.0, 5.0); glVertex3d(xc - xlen, yc, zc + zlen); // Lewy górny
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {
|
|
||||||
|
static void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
@@ -550,7 +583,8 @@ void stodola(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat krawedz) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x) {
|
static void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY, bool mod_x)
|
||||||
|
{
|
||||||
|
|
||||||
GLfloat grubosc = 1.0f;
|
GLfloat grubosc = 1.0f;
|
||||||
|
|
||||||
@@ -772,18 +806,21 @@ void plot(GLfloat xc, GLfloat yc, GLfloat zc, GLfloat length, GLfloat gruboscY,
|
|||||||
lazik user(10.0f, 0.0f, 0.0f, "res/models/lazik4.obj"); // obiekty eksportujemy z Forward Axis Z, Up Axis Y.
|
lazik user(10.0f, 0.0f, 0.0f, "res/models/lazik4.obj"); // obiekty eksportujemy z Forward Axis Z, Up Axis Y.
|
||||||
plane mapa( 0.0f, 0.0f, 0.0f, "res/models/mapka3_nofence_noplatform.obj");
|
plane mapa( 0.0f, 0.0f, 0.0f, "res/models/mapka3_nofence_noplatform.obj");
|
||||||
|
|
||||||
void SetupRC() {
|
static void SetupRC() {
|
||||||
// Light values and coordinates
|
// Light values and coordinates
|
||||||
GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f };
|
GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 1.0f };
|
||||||
GLfloat diffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f };
|
GLfloat diffuseLight[] = { 0.7f, 0.7f, 0.7f, 1.0f };
|
||||||
GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
GLfloat lightPos[] = {50.0f, -100.0f, 50.0f, 1.0f};
|
|
||||||
GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
|
// Multiple light positions (for light coming from all sides)
|
||||||
|
GLfloat lightPos1[] = { 50.0f, -100.0f, 50.0f, 1.0f }; // Light 0 position
|
||||||
|
GLfloat lightPos2[] = { -50.0f, -100.0f, 50.0f, 1.0f }; // Light 1 position
|
||||||
|
GLfloat lightPos3[] = { 50.0f, -100.0f, -50.0f, 1.0f }; // Light 2 position
|
||||||
|
GLfloat lightPos4[] = { -50.0f, -100.0f, -50.0f, 1.0f }; // Light 3 position
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST); // Hidden surface removal
|
glEnable(GL_DEPTH_TEST); // Hidden surface removal
|
||||||
glFrontFace(GL_CCW); // Counter clock-wise polygons face out
|
glFrontFace(GL_CCW); // Counter clockwise polygons face out
|
||||||
//glEnable(GL_CULL_FACE); // Do not calculate inside of jet // !!! znacząco poprawia wydajność
|
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
// Enable lighting
|
// Enable lighting
|
||||||
@@ -793,9 +830,30 @@ void SetupRC() {
|
|||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
|
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
|
||||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
|
glLightfv(GL_LIGHT0, GL_POSITION, lightPos1);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
// Setup and enable light 1
|
||||||
|
glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight);
|
||||||
|
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight);
|
||||||
|
glLightfv(GL_LIGHT1, GL_SPECULAR, specular);
|
||||||
|
glLightfv(GL_LIGHT1, GL_POSITION, lightPos2);
|
||||||
|
glEnable(GL_LIGHT1);
|
||||||
|
|
||||||
|
// Setup and enable light 2
|
||||||
|
glLightfv(GL_LIGHT2, GL_AMBIENT, ambientLight);
|
||||||
|
glLightfv(GL_LIGHT2, GL_DIFFUSE, diffuseLight);
|
||||||
|
glLightfv(GL_LIGHT2, GL_SPECULAR, specular);
|
||||||
|
glLightfv(GL_LIGHT2, GL_POSITION, lightPos3);
|
||||||
|
glEnable(GL_LIGHT2);
|
||||||
|
|
||||||
|
// Setup and enable light 3
|
||||||
|
glLightfv(GL_LIGHT3, GL_AMBIENT, ambientLight);
|
||||||
|
glLightfv(GL_LIGHT3, GL_DIFFUSE, diffuseLight);
|
||||||
|
glLightfv(GL_LIGHT3, GL_SPECULAR, specular);
|
||||||
|
glLightfv(GL_LIGHT3, GL_POSITION, lightPos4);
|
||||||
|
glEnable(GL_LIGHT3);
|
||||||
|
|
||||||
// Enable color tracking
|
// Enable color tracking
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
@@ -804,14 +862,12 @@ void SetupRC() {
|
|||||||
|
|
||||||
// All materials hereafter have full specular reflectivity
|
// All materials hereafter have full specular reflectivity
|
||||||
// with a high shine
|
// with a high shine
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specref);
|
GLfloat specref2[] = {0.2f, 0.2f, 0.2f, 0.2f};
|
||||||
|
glMaterialfv(GL_FRONT, GL_SPECULAR, specref2);
|
||||||
glMateriali(GL_FRONT, GL_SHININESS, 128);
|
glMateriali(GL_FRONT, GL_SHININESS, 128);
|
||||||
|
|
||||||
|
|
||||||
// White background
|
// White background
|
||||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
// Black brush
|
|
||||||
//glColor3f(0.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
// Initialize GLEW
|
// Initialize GLEW
|
||||||
timestampedCout("Inicjalizowanie GLEW...");
|
timestampedCout("Inicjalizowanie GLEW...");
|
||||||
@@ -823,143 +879,96 @@ void SetupRC() {
|
|||||||
|
|
||||||
timestampedCout("Zainicjalizowano GLEW.");
|
timestampedCout("Zainicjalizowano GLEW.");
|
||||||
|
|
||||||
// glfw3 jest w teorii niepotrzebny, ale może się przydać
|
// Initialize GLFW3
|
||||||
// do przepisania kodu na podobny do tego stąd:
|
|
||||||
// https://github.com/opengl-tutorials/ogl/blob/master/tutorial07_model_loading/tutorial07.cpp
|
|
||||||
timestampedCout("Inicjalizowanie GLFW3...");
|
timestampedCout("Inicjalizowanie GLFW3...");
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
timestampedCout("Failed to initialize GLFW");
|
timestampedCout("Failed to initialize GLFW");
|
||||||
}
|
}
|
||||||
timestampedCout("Zainicjalizowano GLFW3.");
|
timestampedCout("Zainicjalizowano GLFW3.");
|
||||||
|
|
||||||
// glGenVertexArrays(1, &VertexArrayID);
|
// Load models
|
||||||
// glBindVertexArray(VertexArrayID);
|
|
||||||
|
|
||||||
// Załaduj shadery
|
|
||||||
|
|
||||||
// programID = LoadShaders("res/shaders/TransformVertexShader.vertexshader", "res/shaders/TextureFragmentShader.fragmentshader");
|
|
||||||
// MatrixID = glGetUniformLocation(programID, "MVP");
|
|
||||||
// user.passProgramID(programID);
|
|
||||||
|
|
||||||
// Załaduj model z pliku .obj
|
|
||||||
|
|
||||||
timestampedCout("Ladowanie modelu lazika...");
|
timestampedCout("Ladowanie modelu lazika...");
|
||||||
user.loadModel();
|
user.loadModel();
|
||||||
timestampedCout("Ladowanie modelu mapki...");
|
timestampedCout("Ladowanie modelu mapki...");
|
||||||
mapa.loadModel();
|
mapa.loadModel();
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
//glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScene(void) {
|
|
||||||
|
|
||||||
|
void static RenderScene(void) {
|
||||||
|
// Ustawienie liczby próbek dla antyaliasingu
|
||||||
|
glfwWindowHint(GLFW_SAMPLES, 16); // 4x MSAA (Wielokrotne próbkowanie)
|
||||||
|
|
||||||
//float normal[3]; // Storage for calculated surface normal
|
// Włączenie antyaliasingu (MSAA)
|
||||||
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
// Save the matrix state and do the rotations
|
// Przywrócenie macierzy modelu i ustawienie obrotów
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
// gluLookAt(
|
// Ustawienie trybu rysowania wielokątów
|
||||||
// 0, 0, 0, // the position of your camera, in world space
|
|
||||||
// 0, 0, 0, // where you want to look at, in world space
|
|
||||||
// 0, 1, 0 // probably glm::vec3(0,1,0), but (0,-1,0) would make you looking upside-down, which can be great too
|
|
||||||
// );
|
|
||||||
|
|
||||||
switch (polygonmode) {
|
switch (polygonmode) {
|
||||||
case 1:
|
case 1:
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Rysowanie linii
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Wypełnianie poligonów
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Czyszczenie ekranu przed rysowaniem
|
||||||
|
|
||||||
// Clear the screen
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// Use our shader
|
// Przywrócenie macierzy widoku
|
||||||
//timestampedCout("programID wynosi " << programID);
|
|
||||||
//glUseProgram(programID);
|
|
||||||
|
|
||||||
// // Bind our texture in Texture Unit 0
|
|
||||||
// glActiveTexture(GL_TEXTURE0);
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, Texture);
|
|
||||||
// // Set our "myTextureSampler" sampler to use Texture Unit 0
|
|
||||||
// glUniform1i(TextureID, 0);
|
|
||||||
//glLoadIdentity(); // Zresetowanie macierzy widoku
|
|
||||||
//
|
|
||||||
//############################################################################################
|
|
||||||
//Sterowanie
|
|
||||||
//############################################################################################
|
|
||||||
gluLookAt(
|
gluLookAt(
|
||||||
Foward - 100.0f * sin((Rotation + 180.0f) * GL_PI / 180.0f), // Pozycja kamery wokół łazika (w poziomie)
|
Foward - 50.0f * sin((Rotation + 180.0f) * GL_PI / 180.0f), // Pozycja kamery
|
||||||
CameraHeight, // Wysokość kamery
|
CameraHeight/4, // Wysokość kamery
|
||||||
Sides - 100.0f * cos((Rotation + 180.0f) * GL_PI / 180.0f), // Kamera wzdłuż osi X i Z
|
Sides - 50.0f * cos((Rotation + 180.0f) * GL_PI / 180.0f), // Kamera wzdłuż osi X i Z
|
||||||
Foward, 0.0f, Sides, // Punkt, na który patrzy kamera (łazik)
|
Foward, 0.0f, Sides, // Punkt patrzenia (łazik)
|
||||||
0.0f, 1.0f, 0.0f // Wektor "góry"
|
0.0f, 1.0f, 0.0f // Wektor "góry"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rysowanie mapy (nie porusza się)
|
// Rysowanie mapy
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor3f(0.0, 1.0, 0.0); // Zielony kolor dla mapy
|
glColor3f(0.0, 1.0, 0.0); // Zielony kolor
|
||||||
platforma(50.0f, 0.0f, 45.0f, 60.0f, 65.0f);
|
mapa.draw();
|
||||||
//mapa.draw();
|
platforma(50.0f, 0.0f, 45.0f, 600.0f, 650.0f);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// Rysowanie łazika (porusza się i obraca)
|
// Rysowanie łazika
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
glTranslatef(Foward, 0.0f, Sides); // Translacja łazika
|
||||||
glTranslatef(Foward, 0.0f, Sides); // Translacja łazika na jego pozycję
|
glRotatef(Rotation, 0.0f, 1.0f, 0.0f); // Obrót łazika
|
||||||
glRotatef(Rotation, 0.0f, 1.0f, 0.0f); // Obrót łazika wokół własnej osi
|
|
||||||
glColor3f(1.0, 0.0, 0.0); // Czerwony kolor dla łazika
|
glColor3f(1.0, 0.0, 0.0); // Czerwony kolor dla łazika
|
||||||
fpsCounter.update();
|
|
||||||
user.draw();
|
user.draw();
|
||||||
UpdateRover(fences);
|
UpdateRover(fences);
|
||||||
|
fpsCounter.update();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
//skrzynka(50);
|
// Rysowanie innych obiektów
|
||||||
plot(-10.0f, 3.0f, 45.0f, 130.0f, 4.0f, 0); // 0 - pionowo
|
plot(-550.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0); // 0 - pionowo
|
||||||
plot( 50.0f, 3.0f, -20.0f, 120.0f, 4.0f, 1); // 1 - poziomo
|
plot( 50.0f, 3.0f, -600.0f, 1200.0f, 4.0f, 1); // 1 - poziomo
|
||||||
plot(110.0f, 3.0f, 45.0f, 130.0f, 4.0f, 0);
|
plot( 650.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0);
|
||||||
plot( 50.0f, 3.0f, 110.0f, 120.0f, 4.0f, 1);
|
plot( 50.0f, 3.0f, 695.0f, 1200.0f, 4.0f, 1);
|
||||||
|
|
||||||
// stodola(2.0f, 0.0f, -7.5f, 20.0f);
|
|
||||||
stodola(10.0f, 0.0f, 2.0f, 40.0f);
|
stodola(10.0f, 0.0f, 2.0f, 40.0f);
|
||||||
|
|
||||||
// Zamiana buforów (double buffering)
|
// Zamiana buforów (double buffering)
|
||||||
//glColor3f(1.0, 0.0, 0.0);
|
// glfwSwapBuffers(window); // Przełączenie buforów
|
||||||
//user.draw();
|
// glfwPollEvents(); // Obsługa zdarzeń
|
||||||
//glColor3f(0.0, 1.0, 0.0);
|
|
||||||
//mapa.draw();
|
|
||||||
//glColor3f(0.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
|
glPopMatrix(); // Przywrócenie poprzedniej macierzy
|
||||||
|
glMatrixMode(GL_MODELVIEW); // Ustawienie trybu modelu-widoku
|
||||||
|
|
||||||
// Zamiana buforów (double buffering)
|
// Wymuszenie wykonania wszystkich rysunków
|
||||||
|
glFlush();
|
||||||
|
|
||||||
// Swap buffers
|
|
||||||
//glfwSwapBuffers(window);
|
|
||||||
//glfwPollEvents();
|
|
||||||
|
|
||||||
//Wyrysowanie prostokata:
|
|
||||||
//glRectd(-10.0,-10.0,20.0,20.0);
|
|
||||||
|
|
||||||
glPopMatrix(); // wymagane
|
|
||||||
glMatrixMode(GL_MODELVIEW); // zmniejsza zużycie GPU
|
|
||||||
|
|
||||||
// Flush drawing commands
|
|
||||||
//glFlush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If necessary, creates a 3-3-2 palette for the device context listed.
|
// If necessary, creates a 3-3-2 palette for the device context listed.
|
||||||
HPALETTE GetOpenGLPalette(HDC hDC) {
|
HPALETTE static GetOpenGLPalette(HDC hDC) {
|
||||||
HPALETTE hRetPal = NULL; // Handle to palette to be created
|
HPALETTE hRetPal = NULL; // Handle to palette to be created
|
||||||
PIXELFORMATDESCRIPTOR pfd; // Pixel Format Descriptor
|
PIXELFORMATDESCRIPTOR pfd; // Pixel Format Descriptor
|
||||||
LOGPALETTE* pPal; // Pointer to memory for logical palette
|
LOGPALETTE* pPal; // Pointer to memory for logical palette
|
||||||
@@ -1029,7 +1038,7 @@ HPALETTE GetOpenGLPalette(HDC hDC) {
|
|||||||
// Return the handle to the new palette
|
// Return the handle to the new palette
|
||||||
return hRetPal;
|
return hRetPal;
|
||||||
}
|
}
|
||||||
void CreateConsole() {
|
void static CreateConsole() {
|
||||||
// Tworzenie nowej konsoli
|
// Tworzenie nowej konsoli
|
||||||
if (AllocConsole()) {
|
if (AllocConsole()) {
|
||||||
// Przekierowanie standardowych strumieni do konsoli
|
// Przekierowanie standardowych strumieni do konsoli
|
||||||
@@ -1047,7 +1056,7 @@ void CreateConsole() {
|
|||||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||||
CreateConsole();
|
CreateConsole();
|
||||||
MSG msg; // Windows message structure
|
MSG msg; // Windows message structure
|
||||||
WNDCLASS wc; // Windows class structure
|
WNDCLASS wc{}; // Windows class structure
|
||||||
HWND hWnd; // Storeage for window handle
|
HWND hWnd; // Storeage for window handle
|
||||||
|
|
||||||
|
|
||||||
@@ -1141,8 +1150,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[0]); // aktywuje obiekt tekstury
|
glBindTexture(GL_TEXTURE_2D, texture[0]); // aktywuje obiekt tekstury
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
@@ -1159,8 +1168,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
bitmapData = LoadBitmapFile((char*)"res/img/grass02.bmp", &bitmapInfoHeader);
|
bitmapData = LoadBitmapFile((char*)"res/img/grass02.bmp", &bitmapInfoHeader);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[1]); // aktywuje obiekt tekstury
|
glBindTexture(GL_TEXTURE_2D, texture[1]); // aktywuje obiekt tekstury
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||||
@@ -1175,8 +1184,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
bitmapData = LoadBitmapFile((char*)"res/img/barnroof.bmp", &bitmapInfoHeader);
|
bitmapData = LoadBitmapFile((char*)"res/img/barnroof.bmp", &bitmapInfoHeader);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[2]); // aktywuje obiekt tekstury
|
glBindTexture(GL_TEXTURE_2D, texture[2]); // aktywuje obiekt tekstury
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
@@ -1191,8 +1200,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
bitmapData = LoadBitmapFile((char*)"res/img/brickwall.bmp", &bitmapInfoHeader);
|
bitmapData = LoadBitmapFile((char*)"res/img/brickwall.bmp", &bitmapInfoHeader);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture[3]); // aktywuje obiekt tekstury
|
glBindTexture(GL_TEXTURE_2D, texture[3]); // aktywuje obiekt tekstury
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
@@ -1238,6 +1247,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
// The painting function. This message sent by Windows
|
// The painting function. This message sent by Windows
|
||||||
// whenever the screen needs updating.
|
// whenever the screen needs updating.
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
|
LimitFPS(targetFPS);
|
||||||
// Call OpenGL drawing code
|
// Call OpenGL drawing code
|
||||||
RenderScene();
|
RenderScene();
|
||||||
|
|
||||||
@@ -1250,7 +1260,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
// Limit FPS
|
// Limit FPS
|
||||||
// Uaktualniaj FPS
|
// Uaktualniaj FPS
|
||||||
LimitFPS(targetFPS); // Ogranicz FPS
|
// Ogranicz FPS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user