mercredi 1 décembre 2021

problem with assigning a function to multithread c++ 11

im creating a minecraft knock off in c++ for fun, and currently am trying to draw multiple chunks, but performance is terrible so im trying to multithread.

now, onto the issue, when i try to make a new thread but when i add the function to draw in the constructor it puts out this error :

operator -> or ->* applied to "World" instead of to a pointer type error

here is main.cpp code

#include "renderer/renderer.hpp"
#include "world/world.hpp"

#include <thread>

Renderer renderer;
World world;

int main() {
    renderer.init();
    world.generate();

    std::thread drawerThread(world->draw, renderer);

    while (!glfwWindowShouldClose(renderer.window)) {
        glfwPollEvents();
        renderer.clearFrame();
        world.draw(renderer);
        renderer.drawFrame();
    }

    renderer.cleanup();
    return 0;
}

if needed i can add all the other code but my project has about 400+ lines of code

Aucun commentaire:

Enregistrer un commentaire