aboutsummaryrefslogtreecommitdiff
path: root/src/accelerate/myqtconcurrent.cpp
diff options
context:
space:
mode:
authorDavid Doan <daviddoan@Davids-MacBook-Pro-193.local>2023-12-13 01:37:28 -0500
committerDavid Doan <daviddoan@Davids-MacBook-Pro-193.local>2023-12-13 01:37:28 -0500
commit8afef246ac0d7adf03eae794fc1ba5ba25f64dd8 (patch)
tree05582f1d5a50ca9d21c9c12d06dd258d40b113a3 /src/accelerate/myqtconcurrent.cpp
parenta31f51672fe92d8d5cb2c9319a0ba35a52d3b51b (diff)
parent8337f9b0b63e2e63b714acd5d24b622d7330cbc2 (diff)
Merge branch 'main' of https://github.com/NicholasBottone/the-all-americans-in-cs1230
render button
Diffstat (limited to 'src/accelerate/myqtconcurrent.cpp')
-rw-r--r--src/accelerate/myqtconcurrent.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/src/accelerate/myqtconcurrent.cpp b/src/accelerate/myqtconcurrent.cpp
index 12e9138..1615bca 100644
--- a/src/accelerate/myqtconcurrent.cpp
+++ b/src/accelerate/myqtconcurrent.cpp
@@ -45,34 +45,29 @@ void RayTracer::renderParallel(RGBA *imageData, const RayTraceScene &scene)
for (int imageRow = 0; imageRow < scene.height(); imageRow++) {
for (int imageCol = 0; imageCol < scene.width(); imageCol++) {
// FIXME: for now, use height as depth
- for (int imageDepth = 0; imageDepth < scene.depth(); imageDepth++) {
- // compute the ray
- float x = (imageCol - scene.width()/2.f) * viewplaneWidth / scene.width();
- float y = (imageRow - scene.height()/2.f) * viewplaneHeight / scene.height();
- float z = (imageDepth - scene.depth()/2.f) * viewplaneDepth / scene.depth();
-
- glm::vec4 pWorld = Vec4Ops::transformPoint4(glm::vec4(0.f), camera.getViewMatrix(), camera.getTranslationVector());
- glm::vec4 dWorld = Vec4Ops::transformDir4(glm::vec4(x, y, z, -1.0), camera.getViewMatrix());
- // get the pixel color
- glm::vec4 pixelColor = getPixelFromRay(pWorld, dWorld, scene, 0);
-
- if (pixelColor.r > 0) {
- std::cout << "pixelColor.r: " << pixelColor.r << ", x" << imageCol << ", y" << imageRow << ", z" << imageDepth << std::endl;
- }
-
- // set the pixel color
- if (imageDepth == 250)
- {
- int index = imageRow * scene.width() + imageCol;
- imageData[index] = RGBA{
- (std::uint8_t) (pixelColor.r * 255.f),
- (std::uint8_t) (pixelColor.g * 255.f),
- (std::uint8_t) (pixelColor.b * 255.f),
- (std::uint8_t) (pixelColor.a * 255.f)
- };
- }
-
+ int imageDepth = (int) ((settings.w + 100.f) * (5.f / 2.f));
+ // compute the ray
+ float x = (imageCol - scene.width()/2.f) * viewplaneWidth / scene.width();
+ float y = (imageRow - scene.height()/2.f) * viewplaneHeight / scene.height();
+ float z = (imageDepth - scene.depth()/2.f) * viewplaneDepth / scene.depth();
+
+ glm::vec4 pWorld = Vec4Ops::transformPoint4(glm::vec4(0.f), camera.getViewMatrix(), camera.getTranslationVector());
+ glm::vec4 dWorld = Vec4Ops::transformDir4(glm::vec4(x, y, z, -1.0), camera.getViewMatrix());
+ // get the pixel color
+ glm::vec4 pixelColor = getPixelFromRay(pWorld, dWorld, scene, 0);
+
+ if (pixelColor.r > 0) {
+ std::cout << "pixelColor.r: " << pixelColor.r << ", x" << imageCol << ", y" << imageRow << ", z" << imageDepth << std::endl;
}
+
+ // set the pixel color
+ int index = imageRow * scene.width() + imageCol;
+ imageData[index] = RGBA{
+ (std::uint8_t) (pixelColor.r * 255.f),
+ (std::uint8_t) (pixelColor.g * 255.f),
+ (std::uint8_t) (pixelColor.b * 255.f),
+ (std::uint8_t) (pixelColor.a * 255.f)
+ };
}
}
QList<RGBA> pixels = QtConcurrent::blockingMapped(l, pixelRoutine);