Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example using an FBO #63

Open
Asday opened this issue Jun 5, 2024 · 5 comments
Open

Example using an FBO #63

Asday opened this issue Jun 5, 2024 · 5 comments

Comments

@Asday
Copy link

Asday commented Jun 5, 2024

Followup to #19, which was for some reason closed without a resolution. I'll reproduce my comment from there, here, for convenience.


Please forgive me for being extremely stupid.

Where is it "all documented"? The comment in libmpv/sdl/main.c references render_gl.h, which I think might be mpv/libmpv/render_gl.h which in turn references glGenFrameBuffers(), which isn't mentioned in the SDL docs I found, nor is "frame", nor "buffer".

Googling for "sdl glgenframebuffers", or "sdl get framebuffer", or "sdl get fbo" all lead to the same couple of StackOverflow questions about directly modifying pixels, not getting an int I can give to mpv_opengl_fbo.fbo.

Googling for "sdl mpv fbo" gets me an example of using the opengl-cb API which the README in this repo says doesn't exist any more, an arch linux BBS thread where some guy symlinks his system python2 to python to get libreoffice to work, and this dang issue.

Could someone please point me towards where this is "all documented"? Please remember that if I try really hard, I can just about reach 30 IQ.

@sfan5
Copy link
Member

sfan5 commented Jun 5, 2024

While the documentation (the comment in render_gl.h) is brief I think it is clear.
However you don't seem to be familiar with OpenGL or what an FBO is, which raises the question of what are you even trying to do?

If you explain that maybe someone here can help you.

@Asday
Copy link
Author

Asday commented Jun 5, 2024

Thank you for getting back to me so quickly!

I download youtube videos and watch them later in mpv instead of relying on the god-awful youtube interface. I have the videos, thumbnails, metadata, and comments all downloaded, and I can manually sift through them, but it's a pain in the neck.

I'm doing my best (which isn't very good) to use C++, SDL, and mpv, to write something that kinda looks and acts like youtube, minus the suggestions and search. Sort of a file browser specifically for my "watch later" directory, where I can scroll through thumbnails, click on them to play videos, and read through the comments.

From what I understand (which is very little), this requires me to create a framebuffer object, to which mpv can render its output. My terminology is going to be mixed up here, but from there I believe I can use the FBO as a texture, allowing me to scale and transform it as I wish, which is an important difference from sdl/main.c, as that renders mpv covering the entire application window.

@sfan5
Copy link
Member

sfan5 commented Jun 6, 2024

From what I understand (which is very little), this requires me to create a framebuffer object, to which mpv can render its output. My terminology is going to be mixed up here, but from there I believe I can use the FBO as a texture, allowing me to scale and transform it as I wish, which is an important difference from sdl/main.c, as that renders mpv covering the entire application window.

This is all correct.
However how are you realizing the rest of your GUI? Interop will be difficult if that's not OpenGL as well.

@Asday
Copy link
Author

Asday commented Jun 6, 2024

The plan was to see how far I could get with things like TTF_RenderText_Solid and SDL_RenderDrawRect and if that turned out to be too painful, give up and look into what ImGui is and how to use it.

I'm clearly in over my head, but my understanding was that SDL was a layer on top of OpenGL (or maybe other graphics APIs, but SDL in this case at least), so the interop wouldn't be so bad - I'd just have to make sure to update the view from the texture mpv is rendering to often enough, and make sure not to try and draw on top of it.

Even if I'm headed for a brick wall, it seems like it'll be fun to get there, so I'm glad I got the above correct. Would you be able to point me in the direction of some documentation/examples rendering to an FBO that don't assume quite as much knowledge?

@sfan5
Copy link
Member

sfan5 commented Jun 7, 2024

The SDL renderer is a software renderer.

Your options are to either switch to OpenGL or use the software rendering support as in main_sw, which works with SDL_Renderer. Be warned that it will not be fast/efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants