View Full Version : Blitting sdl surfaces with opengl
rogerdv
08-22-2003, 03:49 PM
Does somebody know how to blit an sdl surface with opengl?
baldurk
08-23-2003, 03:08 AM
I've never tried it myself, but you should be able to access the structure and so you can create an opengl texture.
I found this, it might help:
Slightly edited from the SDL_Surface manpage:
typedef struct SDL_Surface {
Uint32 flags;
SDL_PixelFormat *format;
int w, h;
Uint16 pitch;
void *pixels;
SDL_Rect clip_rect;
int refcount;
} SDL_Surface;
/*
flags Surface flags
format Pixel format
w, h Width and height of the surface
pitch Length of a surface scanline in bytes
pixels Pointer to the actual pixel data
clip_rect surface clip rectangle
*/
So I guess you can find out what the width and height are. The pixels pointer type will be defined by the format argument. You'll need to guess or research what the format means though, it wasn't mentioned. I need to leave you some work ;).
davepermen
08-24-2003, 05:12 AM
why does sdl have a manpage? its all directly written in the headers :D
yeah, upload it onto a texture. thats about all you can do
baldurk
08-24-2003, 11:32 AM
well, it's easier to type "man SDL_Surface" than find the dir, find the file, then read it ;P. Besides, there is a little more in the man page than in the header.
rogerdv
08-25-2003, 07:05 AM
The problem with using it as texture is that I want to use that surface as a 2d image on top of the 3d space, using 2d coordinates. I dont wnat to have to calculate all time the correct 3d coords to put the image on top. Im sure it is faster to blit an image than draw a polygon and texture it.
davepermen
08-25-2003, 09:31 AM
well, it's easier to type "man SDL_Surface" than find the dir, find the file, then read it ;P. Besides, there is a little more in the man page than in the header.
right click, open, done..
or, rightclick, go to definition, done..
wow THAT was hard :D
davepermen
08-25-2003, 09:34 AM
The problem with using it as texture is that I want to use that surface as a 2d image on top of the 3d space, using 2d coordinates. I dont wnat to have to calculate all time the correct 3d coords to put the image on top.
void glBlitOnScreen(... your texture here ...) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glBindTexture(... your texture here ...);
glBegin(GL_QUADS); {
glTexCoords2i(0,0); glVertex2i(-1,-1);
glTexCoords2i(1,0); glVertex2i( 1,-1);
glTexCoords2i(1,1); glVertex2i( 1, 1);
glTexCoords2i(0,1); glVertex2i(-1, 1);
} glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
Im sure it is faster to blit an image than draw a polygon and texture it.
no
baldurk
08-25-2003, 12:28 PM
Well, I'm not on VC++, so it's more difficult. It's a moot point on VC++, because windows doesn't have man pages :).
davepermen
08-25-2003, 12:31 PM
well.. i ment it to honour sdl mainly, because its well documented, independend on os and os features :D thats cool..
baldurk
08-25-2003, 12:54 PM
That is cool. Cool and unfortunately rare.
davepermen
08-26-2003, 01:20 AM
yeah.. :(
vBulletin, Copyright ©2000-2009, Jelsoft Enterprises Ltd.