Jump to content
  • Advertisement
Sign in to follow this  

OpenGL sdl texture to opengl for video

This topic is 4003 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was searching for a good way to play movies on my engine (SDL/openGL) for (win/linux). I found "smpeg" wich gave me a lot of headaches, but i cant find anything better than this so i must deal with it. Its works fine on linux and not too fine on windows. I must activate SDL_OPENGLBLIT for SDl bliting operations for "smpeg" and i think that SDL_OPENGLBLIT isnt the best way so im trying to replace the blitting fuction on "smpeg" for a simple opengl texture and glswapbuffers and change SDL_OPENGLBLIT for SDL_OPENGL. The old fuction do this.
SDLMovieDrawIMG(SDL_Surface *img, SDL_Surface *dst, int x, int y)
    SDL_Rect dest;
    dest.x = x;
    dest.y = y;
    SDL_BlitSurface(img, NULL, dst, &dest);

I replace it whit this:
SDLMovieDrawIMG(SDL_Surface *img, SDL_Surface *dst, int x, int y)
   glGenTextures(1, &movie_texture);

    glBindTexture(GL_TEXTURE_2D, movie_texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->w, img->h, 0, GL_RGB, GL_UNSIGNED_BYTE, img->pixels);

    glBindTexture(GL_TEXTURE_2D, movie_texture);

    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(-1.0f, -1.0f, 0.0f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f( 1.0f, -1.0f, 0.0f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f( 1.0f,  1.0f, 0.0f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(-1.0f,  1.0f, 0.0f);


    glDeleteTextures(1, &movie_texture);

I can see something but something extremelly bad, it seems like if the texture was repeated with blending at the same frame. The original SDL surface (SDLSurface *img) was create this way:

SDL_Surface *tempSurface2 = SDL_CreateRGBSurface( SDL_SWSURFACE, sdlmovie.movieInfo.width * sdlmovie.MaxScaleX, sdlmovie.movieInfo.height * sdlmovie.MaxScaleY, 32, sdlmovie.screen->format->Rmask, sdlmovie.screen->format->Gmask, sdlmovie.screen->format->Bmask, sdlmovie.screen->format->Amask );

// this is the SDLSurface *img
sdlmovie.movieSurface = SDL_DisplayFormat( tempSurface2 );

Any idea what im doing wrong?? Thanks in advance.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!