Jump to content


Blitting sdl surfaces with opengl


10 replies to this topic

#1 rogerdv

    Member

  • Members
  • PipPip
  • 99 posts

Posted 22 August 2003 - 09:49 PM

Does somebody know how to blit an sdl surface with opengl?

#2 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

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:
    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.

#3 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

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
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....

#4 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

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.

#5 rogerdv

    Member

  • Members
  • PipPip
  • 99 posts

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 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

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.
right click, open, done..

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....

#7 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

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.
no
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....

#8 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 25 August 2003 - 06: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 :).
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.

#9 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

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....

#10 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 25 August 2003 - 06:54 PM

That is cool. Cool and unfortunately rare.
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.

#11 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

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....





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users