문제

I am trying to get the EnvironmentMap using the function

bool SILVERLINING_API GetEnvironmentMap(void *&texture, int facesToRender = 6);

I am working with OpenSceneGraph which is a API over OpenGL. The function description says:

\param texture A pointer to the platform-specific texture handle containing the cube map. On OpenGL this is a GLuint; on DirectX9 it is a LPDIRECT3DCUBETEXTURE9; on DirectX10 it is a ID3D10ShaderResourceView *; on DirectX11 it is a ID3D11ShaderResourceView *.

So I am trying code like this:

GLuint id;
silverLining->atmosphere()->GetEnvironmentMap(id);

And I am getting the error: "cannot convert parameter 1 from 'GLuint' to 'void *&'" The same is with

GLuint *id;
silverLining->atmosphere()->GetEnvironmentMap(id);

So I suppose as I am doing it along with the description and it doesn't work, maybe there is some special way to handle parameters like "void*&"?

Any word of advice on which direction I should be looking?

도움이 되었습니까?

해결책

C++ is strongly typed language, so you the types have to match. In the first try your supplying object of type GLuint to a fucntion that takes void*. In second example your supplying pointer to GLuint to the same function.

The only way to make this work is to supply GetEnvironmentMap function with something of Type void* (or something that may be implicitly cast to it).

EDIT: If you're using OpenGL, GetEnvironmentMap function will gladly accept pointer to GLuint as first parameter, but it has to be casted (to void*) and it has to be valid. The code that might help you is

GLuint myEnvironmentMapTex;
silverLining->atmosphere()->GetEnvironmentMap((void*)&myEnvironmentMapTex);

Void* is a pointer that points to some memory that no-one knows what holds (it looses any type information - 'void==no type'). Read more here: pointer to void

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top