Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Brokkoli075

Pages: [1]
1
Graphics / Re: Checking monitor's refresh rate
« on: January 04, 2024, 07:50:10 am »
Thank you for your answer!

I actually tried it with vsync both enabled and disabled but there are still outliers in any case. Is there any way I can "read out" the clock of the monitor so that I can dynamically adjust my program to its clock?

Otherwise, can I dynamically read out the monitor's frequency somehow. I fear that it's not exactly stable and the functions provided by windows.h only give me full integer values.

PS: I'm using light engine and monitor interchangeably here because the light engine is recognized as a second monitor by the computer.

2
Graphics / Checking monitor's refresh rate
« on: January 04, 2024, 12:51:56 am »
Hey Guys,

I'm working on the development of a 3D printer. I need to send a white and black screen to a light engine at a speed approaching the frame rate. Since the monitor is operating at 30 Hz (according to windows settings) the maximum speed at which i can alternate between light and dark screens is 33.33 ms, right? I am currently sending pictures at these intervals meaning 33.33 ms bright screen then a 100 ms of dark screen. I measured the results with the iphone slow motion camera. Firstly, I am having a lot of outliers piling up in between around 66 ms. This would mean that my final 3D prints are faulty. Secondly, the dark time averages out at around 80 ms not 100 ms. Is there anyway I can check the actual light engine (monitor's) frame rate dynamically? It's a simple hdmi connection. Is there anything I'm misunderstanding about how my code, the monitor and the GPU interact?

3
Graphics / Re: Image Sequence Displaying too slowly
« on: December 19, 2023, 12:44:20 am »
I'm running my program on a dell laptop (UHD Graphics 620). According to my task manager, my GPU should have 3.9 GB of available space. What are other options that I could use to implement this program?

4
Graphics / Image Sequence Displaying too slowly
« on: December 18, 2023, 02:59:39 am »
Hey everyone,

I need some help with getting the following code to work for a 3D printer light engine. My problem is that the code was working fine at 1920x1080 resolution but at 4k the system seems to overload. I have a 100 pictures to load and the total size of the folder is around 20 MB. If I try to run the program, the pictures are displayed in very irregular time intervals. Is there any way for me to fix the overloading issue? Is there something fundamental that I'm doing wrong here? I'm a Mechanical Engineer so I'm not too adept at coding. I would be very thankful for any help here.


#include <SFML/Graphics.hpp>
#include <iostream>
#include <chrono>
#include <thread>
#include <vector>
#include <string>
#include <filesystem>

#ifdef USING_WINDOWS
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
#endif

namespace fs = std::filesystem;

int main() {
    // Directory containing images
    std::string directoryPath = "C:/Lab/trial2";

    // Vector to store image paths
    std::vector<std::string> imagePaths;


    std::cout << "Adding paths to imagePaths vector." << std::endl;

    // Iterate over files in the directory and add image paths to the vector
    for (const auto& entry : fs::directory_iterator(directoryPath)) {
        imagePaths.push_back(entry.path().string());
    }

    std::cout << "Finished." << std::endl;
        // Create a window
    sf::RenderWindow window(sf::VideoMode(3840, 2160), "Projector Display", sf::Style ::None);

    // Retrieve the desktop mode of the primary monitor
    sf::VideoMode desktop = sf::VideoMode::getDesktopMode();

    // Position the window to start at the beginning of the second monitor
    // Assuming the second monitor is to the right of the primary
    window.setPosition(sf::Vector2i(desktop.width, 0));


    std::cout << "Loading images into texture." << std::endl;

    // Load images
    std::vector<sf::Texture> textures(imagePaths.size());
    for (size_t i = 0; i < imagePaths.size(); ++i) {
        if (!textures[i].loadFromFile(imagePaths[i]))
            return -1;
    }

    std::cout << "Finished. Starting main operation." << std::endl;
    // Main loop
    size_t currentImage = 0;
    sf::Clock clock, imageClock, darkScreenClock;
    bool showImage = true;


    // Pre-calculate the scale for all sprites
    float scaleX = static_cast<float>(window.getSize().x) / textures[0].getSize().x;
    float scaleY = static_cast<float>(window.getSize().y) / textures[0].getSize().y;

    // Main loop

    // Set time intervals (in seconds)
    float imageDisplayTime = 0.1f; // Time to display each image
    float darkScreenTime = 0.1f; // Time to display the dark screen
    bool allImagesShown = false;
    bool finalDarkScreenShown = false;


    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();
        }



        // Handle image and dark screen logic
        if (clock.getElapsedTime().asSeconds() >= (showImage ? imageDisplayTime : darkScreenTime)) {
            clock.restart(); // Reset the clock for the next phase

            if (showImage) {
                currentImage++;
                if (currentImage >= textures.size()) {
                    allImagesShown = true; // All images have been shown
                    currentImage = 0;
                }
            }


            showImage = !showImage; // Toggle between image and dark screen
        }



        // Display image or dark screen
        if (showImage) {
            sf::Sprite sprite(textures[currentImage]);
            sprite.setScale(scaleX,scaleY);

            window.clear();
            window.draw(sprite);
        }
        else {
            window.clear();
        }

        window.display();

        // Exit after showing the final dark screen
        if (allImagesShown && !showImage && !finalDarkScreenShown) {
            finalDarkScreenShown = true;
            showImage = false; // Ensure one last dark screen
        }
        else if (finalDarkScreenShown && !showImage) {
            break;
        }
    }

    return 0;
       
}

 


Pages: [1]