backend::Device doesn't exist?

Hi, i’m trying to create a fragment shader and apply it to a sprite but the problem is this code that converts a file path to frag shader to a programState that i can apply to a Node

backend::ProgramState* CreateProgramStateFromFragment(const std::string& fragmentShaderPath)
{
    const auto fileUtils = cocos2d::FileUtils::getInstance();
    const auto fragmentFullPath = fileUtils->fullPathForFilename(fragmentShaderPath);
    const auto fragSource = fileUtils->getStringFromFile(fragmentFullPath);
    const auto program = backend::Device::getInstance()->newProgram(cocos2d::positionTextureColor_vert, fragSource);

    const auto programState = new (std::nothrow) backend::ProgramState(program);

    // Program must be released if no longer used, since it is not auto-released
    CC_SAFE_RELEASE(program);

    return programState;
}

backend::Device doesn’t exist am i messing something?

Thanks for reading <3

Copying code without understanding it is probably not the best idea. To fix your issue, read up on header files:

https://www.learncpp.com/cpp-tutorial/header-files/
https://www.cplusplus.com/forum/articles/10627/

1 Like