Unable to access SDL_Texture element ( w, and h)

Hello,

Not sure, what could be an issue, that i am getting the below error.

error: dereferencing pointer to incomplete type

whenever i trying to acess SDL_Texture elements, for example

SDL_Texture *tmp = SDL_CreateTexture (…);
Try to print t tmp->w and tmp->h .

Could someone kindly help?

2014-02-12 6:05 GMT+01:00 keestu :

Hello,

Not sure, what could be an issue, that i am getting the below error.

error: dereferencing pointer to incomplete type

whenever i trying to acess SDL_Texture elements, for example

SDL_Texture *tmp = SDL_CreateTexture (…);
Try to print t tmp->w and tmp->h .

Could someone kindly help?

SDL_Texture is an opaque struct. To get information about it, use
http://wiki.libsdl.org/SDL_QueryTexture

So kind of you. :). Thanks Jonas Kulla.

Between, how do we access the pixels, and pitches members of SDL_Texture through SDL_QueryTexture, i did not find . kindly point out?

Well, looks like SDL_LockTexture can help me ;).

2014-02-12 6:21 GMT+01:00 keestu :

Between, how do we access the pixels, and pitches members of SDL_Texture
through SDL_QueryTexture, i did not find . kindly point out?

I think you are confusing SDL_Texture with SDL_Surface, they are
not the same. A texture is a resource managed by the underlying
graphics implementation, and will therefore often live in GPU
memory, so you have no direct pixel access via a memory pointer
to it. Instead, you have to update it’s contents with either
SDL_UpdateTexture() (for static textures) or alternatively
SDL_Lock/UnlockTexture() (for streaming textures).

As for the pitch, I think you can calculate that parameter off of the
pixel format, although SDL_LockTexture() returns it for your
convenience.