diff options
author | Mateja <mail@matejamaric.com> | 2021-02-19 14:09:35 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-02-19 14:09:35 +0100 |
commit | ea5f50550ea2027043c9c3d0f5d998a1a1d336a5 (patch) | |
tree | 77c6ca8c0c36a34105c46b1288667695ebda85d7 | |
parent | 2e0fffe40057a99ec284fc68b2cda411a54a0220 (diff) | |
download | erender-ea5f50550ea2027043c9c3d0f5d998a1a1d336a5.tar.gz erender-ea5f50550ea2027043c9c3d0f5d998a1a1d336a5.zip |
Improve variable names.
-rw-r--r-- | src/main.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp index 94a8b30..f229003 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,22 +32,22 @@ int main() sf::Image image;
image.loadFromFile("model/modelTexture.png");
- Bitmap map(image.getSize().x, image.getSize().y);
+ Bitmap modelTexture(image.getSize().x, image.getSize().y);
const sf::Uint8* pp = image.getPixelsPtr();
for (int i = 0; i < image.getSize().x * image.getSize().y * 4; i += 4) {
- map.pixels[i + 0] = (unsigned char)pp[i + 0];
- map.pixels[i + 1] = (unsigned char)pp[i + 1];
- map.pixels[i + 2] = (unsigned char)pp[i + 2];
- map.pixels[i + 3] = (unsigned char)pp[i + 3];
+ modelTexture.pixels[i + 0] = (unsigned char)pp[i + 0];
+ modelTexture.pixels[i + 1] = (unsigned char)pp[i + 1];
+ modelTexture.pixels[i + 2] = (unsigned char)pp[i + 2];
+ modelTexture.pixels[i + 3] = (unsigned char)pp[i + 3];
}
std::chrono::high_resolution_clock::time_point time1 = std::chrono::high_resolution_clock::now();
- ObjModel vehicle("model/model.obj");
+ ObjModel model("model/model.obj");
std::chrono::high_resolution_clock::time_point time2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> speed = std::chrono::duration_cast<std::chrono::duration<double>>(time2 - time1);
std::cout << "Model loading time: " << speed.count() << "s\n";
- std::cout << "Vertice count: " << vehicle.vertices.size() << "\nNumber of normals: " << vehicle.normals.size() << "\nUV count: " << vehicle.uvcoo.size() << "\n";
- std::cout << "Number of faces: " << vehicle.faces.size() << "\n";
+ std::cout << "Vertices count: " << model.vertices.size() << "\nNumber of normals: " << model.normals.size() << "\nUV count: " << model.uvcoo.size() << "\n";
+ std::cout << "Number of faces: " << model.faces.size() << "\n";
while (window.isOpen())
{
@@ -65,14 +65,14 @@ int main() Matrix4f project = Matrix4f::perspective(1.0f, 10000.0f, fov, width / height);
Matrix4f end_matrix = project * move * rotate * scale;
- ObjModel vehicle2 = vehicle.multiplyMatrix(end_matrix);
- vehicle2.divideW();
- vehicle2.screenspace(width, height);
+ ObjModel projectedModel = model.multiplyMatrix(end_matrix);
+ projectedModel.divideW();
+ projectedModel.screenspace(width, height);
render.fill(255, 255, 255);
render.resetZBuf();
- render.renderModel(vehicle2, map);
+ render.renderModel(projectedModel, modelTexture);
texture.update((sf::Uint8*)render.pixels);
window.draw(sprite);
|