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

Author Topic: RenderTarget and OpenGL?  (Read 3974 times)

0 Members and 1 Guest are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
RenderTarget and OpenGL?
« on: February 16, 2017, 12:30:10 am »
Hello there, me again.

Can someone tell me if there is a way to use RenderTargets to render OpenGL objects? I mean, I want to use them for post processing and I am rendering 3D with OpenGL (not using SFML for 3D).

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #1 on: February 16, 2017, 02:37:35 am »
yes,you can draw 3D scene with sf::RenderTarget by using sf::Sprite if you were rendering the whole scene in texture either by sf::RenderTexture or by opengl glFramebufferTexture2D

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #2 on: February 16, 2017, 02:44:26 am »
That's the problem...
How would I use sf::Texture to render a 3D scene to it?  :-\

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #3 on: February 16, 2017, 02:58:49 am »
you should use sf::RenderTexture first to draw 3D scene and then get the underlying texture of sf::RenderTexture object to draw it with sf::Sprite.

check the offcial tutrial how to setpup sf::RenderTexture on this link

i hope this might help

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
RenderTarget and OpenGL?
« Reply #4 on: February 16, 2017, 12:36:20 pm »
You can bind textures for use with OpenGL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #5 on: February 16, 2017, 06:19:30 pm »
You can bind textures for use with OpenGL.
wasn't really necessary with SFML > 2.4. i have updated all my sfml demos when you guys upgraded it. i will post one of them that use sf::RenderTexture in Screenshot Thread. i keep these silly demos for quick setup and help me to memorize it.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #6 on: February 19, 2017, 02:16:54 am »
Thanks for the answers.
Currently I am stuck at drawing the 3d scene to the target. In the tutorial sf::RenderTexture::Draw is used, however I can't use that since I'm not deriving my classes from any SFML class. So how should I render my models to a target?

Chaia*

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: RenderTarget and OpenGL?
« Reply #7 on: February 27, 2017, 12:13:13 am »
You bind the Target by calling sf::RenderTarget::SetActive(), then you set your states, buffers etc. and call the draw function (e.g. glDrawArrays(...)). If you want to mix OpenGl and SFML Rendering you need to reset/push/pop the respective states (see tutorials). Generally you can bind sfml textures and shaders by their bind() function.