Well, I bit the bullet and decided to work on some software using SDL 1.3
I’m under the impression that to render to a window, you need to use
textures. Well, after searching the wiki and SDL_video.h, there doesn’t
seem to be a way to directly access pixels from a texture to convert an
image. I noticed there seems to be a lot of code that still uses
SDL_Surface * and even found a a function that converts a surface to a
texture. Is that the proper way to do things, so does anyone have a
suggestion?
I’m using opencv to capture a webcam and do some shape tracking, but I find
SDL has much better event handling and graphic display.
I’m also not sure of the pixel format from the IplImage - I did a few
searches and the best I hear is that it is BGR format…SDL_Texture has some
options to use that, but I’m not sure what BGR format it is (the wiki lists
a few different versions…)
I think I have some old code for accessing opencv images, I could post
it Monday if you like, assuming you don’t get anything better before
then.On Sat, Jul 17, 2010 at 8:18 PM, Alex Barry <alex.barry at gmail.com> wrote:
Well, I bit the bullet and decided to work on some software using SDL 1.3
I’m under the impression that to render to a window, you need to use
textures.? Well, after searching the wiki and SDL_video.h, there doesn’t
seem to be a way to directly access pixels from a texture to convert an
image.? I noticed there seems to be a lot of code that still uses
SDL_Surface * and even found a a function that converts a surface to a
texture.? Is that the proper way to do things, so does anyone have a
suggestion?
I’m using opencv to capture a webcam and do some shape tracking, but I find
SDL has much better event handling and graphic display.
I’m also not sure of the pixel format from the IplImage - I did a few
searches and the best I hear is that it is BGR format…SDL_Texture has some
options to use that, but I’m not sure what BGR format it is (the wiki lists
a few different versions…)
If you have some code, though, that would be helpful
Thanks for the help
-AlexOn Sat, Jul 17, 2010 at 8:32 PM, Justin Coleman wrote:
I think I have some old code for accessing opencv images, I could post
it Monday if you like, assuming you don’t get anything better before
then.
On Sat, Jul 17, 2010 at 8:18 PM, Alex Barry <@Alex_Barry> wrote:
Well, I bit the bullet and decided to work on some software using SDL 1.3
I’m under the impression that to render to a window, you need to use
textures. Well, after searching the wiki and SDL_video.h, there doesn’t
seem to be a way to directly access pixels from a texture to convert an
image. I noticed there seems to be a lot of code that still uses
SDL_Surface * and even found a a function that converts a surface to a
texture. Is that the proper way to do things, so does anyone have a
suggestion?
I’m using opencv to capture a webcam and do some shape tracking, but I
find
SDL has much better event handling and graphic display.
I’m also not sure of the pixel format from the IplImage - I did a few
searches and the best I hear is that it is BGR format…SDL_Texture has
some
options to use that, but I’m not sure what BGR format it is (the wiki
lists
a few different versions…)
It seems that you’d have to convert each frame to a texture, just to discard
it after displaying it. I would think to stick with SDL_Surfaces, which are
perfectly valid in SDL 1.3.
Jonny DOn Sat, Jul 17, 2010 at 8:35 PM, Alex Barry <alex.barry at gmail.com> wrote:
If you have some code, though, that would be helpful
Thanks for the help
-Alex
On Sat, Jul 17, 2010 at 8:32 PM, Justin Coleman wrote:
I think I have some old code for accessing opencv images, I could post
it Monday if you like, assuming you don’t get anything better before
then.
On Sat, Jul 17, 2010 at 8:18 PM, Alex Barry <alex.barry at gmail.com> wrote:
Well, I bit the bullet and decided to work on some software using SDL
1.3
I’m under the impression that to render to a window, you need to use
textures. Well, after searching the wiki and SDL_video.h, there doesn’t
seem to be a way to directly access pixels from a texture to convert an
image. I noticed there seems to be a lot of code that still uses
SDL_Surface * and even found a a function that converts a surface to a
texture. Is that the proper way to do things, so does anyone have a
suggestion?
I’m using opencv to capture a webcam and do some shape tracking, but I
find
SDL has much better event handling and graphic display.
I’m also not sure of the pixel format from the IplImage - I did a few
searches and the best I hear is that it is BGR format…SDL_Texture has
some
options to use that, but I’m not sure what BGR format it is (the wiki
lists
a few different versions…)
After some tinkering and frustration, I got it to work:
SDL_Surface surface =
SDL_CreateRGBSurfaceFrom((void)frame->imageData,
frame->width,
frame->height,
frame->depth*frame->nChannels,
frame->widthStep,
0xff0000, 0x00ff00, 0x0000ff, 0 );
SDL_Texture *texture = SDL_CreateTextureFromSurface( 0, surface );
SDL_RenderCopy( texture, NULL, NULL );
SDL_DestroyTexture( texture );
SDL_FreeSurface( surface );
I hope that helps someone else, too.On Sat, Jul 17, 2010 at 9:17 PM, Jonathan Dearborn wrote:
It seems that you’d have to convert each frame to a texture, just to
discard it after displaying it. I would think to stick with SDL_Surfaces,
which are perfectly valid in SDL 1.3.
Jonny D
On Sat, Jul 17, 2010 at 8:35 PM, Alex Barry <@Alex_Barry> wrote:
If you have some code, though, that would be helpful
Thanks for the help
-Alex
On Sat, Jul 17, 2010 at 8:32 PM, Justin Coleman wrote:
I think I have some old code for accessing opencv images, I could post
it Monday if you like, assuming you don’t get anything better before
then.
On Sat, Jul 17, 2010 at 8:18 PM, Alex Barry <@Alex_Barry> wrote:
Well, I bit the bullet and decided to work on some software using SDL
1.3
I’m under the impression that to render to a window, you need to use
textures. Well, after searching the wiki and SDL_video.h, there
doesn’t
seem to be a way to directly access pixels from a texture to convert an
image. I noticed there seems to be a lot of code that still uses
SDL_Surface * and even found a a function that converts a surface to a
texture. Is that the proper way to do things, so does anyone have a
suggestion?
I’m using opencv to capture a webcam and do some shape tracking, but I
find
SDL has much better event handling and graphic display.
I’m also not sure of the pixel format from the IplImage - I did a few
searches and the best I hear is that it is BGR format…SDL_Texture has
some
options to use that, but I’m not sure what BGR format it is (the wiki
lists
a few different versions…)