将sf :: Texture存储在dll中的静态变量中

时间:2017-01-29 17:29:38

标签: c++ sfml

实际上我使用dll将一些方法导出到非托管应用程序。

我需要为sf :: Texture创建一个静态var,但是当我尝试时,dll没有被正确初始化。

我只是添加这一行:

static Texture test3;

dll停止了。

1 个答案:

答案 0 :(得分:0)

关于“静态”作为限定符的效果,其他答案涵盖了这些效果。如果你想使用“静态”,你应该知道“静态”在做什么。

In a C++ namespace does the `static` qualifier have any effect when prefixing non-member subroutines declared in the header?

我不知道您要实现的目标,但我认为您可能希望通过DLL中定义的函数来访问该值。

在示例中

source.cpp

static Texture *myInternalTexture;

void InitInternalTexture(){
    myInternalTexture = new Texture( blah);
}

Texture *GetInternalTexture(){
    return myInternalTexture;
}

void ReleaseInternalTexture(){
    delete myInternalTexture;
}

根据您的使用情况,您可能更喜欢访问纹理参考或复制,我不知道您需要做什么。如果您可以轻松调整上面的代码以使用纹理类型。