Does somebody know how to blit an sdl surface with opengl?
Blitting sdl surfaces with opengl
Started by rogerdv, Aug 22 2003 09:49 PM
10 replies to this topic
#2
Posted 23 August 2003 - 09: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:
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 ;).
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 ;).
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#3
Posted 24 August 2003 - 11: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
yeah, upload it onto a texture. thats about all you can do
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#4
Posted 24 August 2003 - 05:32 PM
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.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#5
Posted 25 August 2003 - 01:05 PM
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.
#6
Posted 25 August 2003 - 03:31 PM
baldurk said:
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.
or, rightclick, go to definition, done..
wow THAT was hard :D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#7
Posted 25 August 2003 - 03:34 PM
Quote
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);
}
Quote
Im sure it is faster to blit an image than draw a polygon and texture it.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#9
Posted 25 August 2003 - 06:31 PM
well.. i ment it to honour sdl mainly, because its well documented, independend on os and os features :D thats cool..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#11
Posted 26 August 2003 - 07:20 AM
yeah.. :(
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












