Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Video rendering  (Read 2504 times)

0 Members and 1 Guest are viewing this topic.

Knucklehead

  • Newbie
  • *
  • Posts: 19
    • View Profile
Video rendering
« on: March 13, 2015, 07:18:33 am »
Hello,
I am basically trying to create cutscenes in my game. I successfully did this by using sfe::Movie. The down side is this, sfe::movie is a child of type drawable and I need to render the drawable to a sf::window rather than a sf::RenderWindow. Is there some sort of handle in drawables I can use to create a texture then render that texture to a full screen quad? Is there some sort of work around? my end goal is to create a texture of the current frame in the video and render that texture to screen using openGL. Thanks for your time.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer

Knucklehead

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Video rendering
« Reply #2 on: March 13, 2015, 03:06:37 pm »
http://sfemovie.yalir.org/1.0/html/classsfe_1_1_movie.html#a414687eb9ddcdcd247a0b382caa6a345


Ah I didn't call get currentframe() I was calling update on the movie object and it wasn't updating the image thank you so much I'll try this out!

Knucklehead

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Video rendering
« Reply #3 on: March 13, 2015, 03:51:38 pm »
movie.update();
////movie is of object type sfe::Movie;
                sf::Texture currentTexture = movie.getCurrentImage();
                /////////////////////////////
////this is creating the openGL texture
                sf::Image picture = currentTexture.copyToImage();
                glDeleteTextures(1,&texture_handle);
                glGenTextures(1, &texture_handle);
                glBindTexture(GL_TEXTURE_2D, texture_handle);
                glEnable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, currentTexture.getSize().x,
                        currentTexture.getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE,
                        picture.getPixelsPtr());

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

///////////////////////////////////////////////////////////////////////////////////
//this block is sending all the info to the shaders;
                pipeline->useVertexShader(pipeline->_VertPassThrough);
                pipeline->useFragmentShader(pipeline->_FragmentShader);

                glEnable(GL_TEXTURE_2D);
                glActiveTexture(GL_TEXTURE0);

                glBindTexture(GL_TEXTURE_2D, texture_handle);
                //sf::Texture::bind(&currentTexture);
                pipeline->sendToShader("tex", 0);

                glBindVertexArray(vertexArray);

                glDrawArrays(GL_TRIANGLES, 0, vertexSize);

                glBindTexture(GL_TEXTURE_2D, NULL);
                glBindVertexArray(0);
                currentTime = 0.0f;



so this in a nutshell is just a quick block of code that im using to test the currentimage function. The getCurrentImage is only returning the first image
« Last Edit: March 13, 2015, 03:58:10 pm by Knucklehead »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Video rendering
« Reply #4 on: March 13, 2015, 03:59:10 pm »
According to the documentation, it should not. Have you tried to use the texture directly, without copying it to an image and creating your own GL texture? (by the way, what you do here is extremely expensive)
Laurent Gomila - SFML developer

Knucklehead

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Video rendering
« Reply #5 on: March 13, 2015, 04:14:08 pm »
The image object is needed for the pixelPtr for openGL. Also yeah I know its really expensive so I created a cutscene state so all the resources can be allocated for it. I've tried using the texture and binding it using sf::texturebind(currentTexture); it still only returns one image. According to the documentation in the .hpp file

    /** @brief Returns the latest movie image
         *
         * The returned image is a texture in VRAM.
         * If the movie has no video stream, this returns an empty texture.
         *
         * @note As in the classic update()/draw() workflow, update() needs to be called
         * before using this method if you want the image to be up to date
         *
         * @return the current image of the movie for the activated video stream
         */   



so movie.update() is being called before the getcurrentImage(); and this should work so this leads me to believe Im missing some function call that increases the currentFrame() counter.
« Last Edit: March 13, 2015, 04:23:34 pm by Knucklehead »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Video rendering
« Reply #6 on: March 13, 2015, 05:02:14 pm »
I can't help you more, what you do looks correct. I don't know if sfe::Movie has a dedicated forum, but at least there's a thread in the Projects forum here where you can ask for help. I guess you can also contact the author directly.
Laurent Gomila - SFML developer