The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Unable to access SDL_Texture element ( w, and h)
keestu


Joined: 21 Jan 2014
Posts: 44
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?
Unable to access SDL_Texture element ( w, and h)
Jonas Kulla
Guest

2014-02-12 6:05 GMT+01:00 keestu:
Quote:
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
keestu


Joined: 21 Jan 2014
Posts: 44
So kind of you. Smile. Thanks Jonas Kulla.
keestu


Joined: 21 Jan 2014
Posts: 44
Between, how do we access the pixels, and pitches members of SDL_Texture through SDL_QueryTexture, i did not find . kindly point out?
keestu


Joined: 21 Jan 2014
Posts: 44
Well, looks like SDL_LockTexture can help me Wink.
Unable to access SDL_Texture element ( w, and h)
Jonas Kulla
Guest

2014-02-12 6:21 GMT+01:00 keestu:
Quote:
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.