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

Author Topic: How can I use OpenGL commands for drawing on RenderTexture?  (Read 2355 times)

0 Members and 2 Guests are viewing this topic.

Latexi95

  • Newbie
  • *
  • Posts: 2
    • View Profile
How can I use OpenGL commands for drawing on RenderTexture?
« on: January 14, 2012, 06:44:38 pm »
I would like to use OpenGL commands for drawing on RenderTexture, but just calling RenderTexture::SetActive(true) doesn't seem to work. What am I doing wrong RenderTexture's Draw command works fine.
Code: [Select]
sf::RenderTexture texture;
texture.Create(400,300);
texture.SetActive(true);
glBegin(GL_LINES);
    glColor4ub(color.r,color.g,color.b,color.a);
    glVertex2f(x1,y1);
    glVertex2f(x2,y2);
glEnd();



Sorry about "bad English".

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
How can I use OpenGL commands for drawing on RenderTexture?
« Reply #1 on: January 14, 2012, 07:29:44 pm »
I think its more for drawing as you would normally with opengl. Then textures are for ..texture manipulation at a higher level.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How can I use OpenGL commands for drawing on RenderTexture?
« Reply #2 on: January 14, 2012, 07:53:56 pm »
You need to Clear() before drawing, and Display() after.

And does it work if you display a sprite or a shape in your render-texture?
Laurent Gomila - SFML developer

Latexi95

  • Newbie
  • *
  • Posts: 2
    • View Profile
How can I use OpenGL commands for drawing on RenderTexture?
« Reply #3 on: January 14, 2012, 11:20:26 pm »
Quote from: "Laurent"
You need to Clear() before drawing, and Display() after.

And does it work if you display a sprite or a shape in your render-texture?

I used Clear and Display().
I think my matrices or something "OpenGL think" is incorrect because drawing after using RenderTexture::Draw() works fine. So how could I apply RenderTexture's View? ApplyCurrentView is private member.  :?

Thank you for helping me.

Edit:
I solved that problem.  :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How can I use OpenGL commands for drawing on RenderTexture?
« Reply #4 on: January 15, 2012, 09:43:26 am »
Quote
I solved that problem

How?
Laurent Gomila - SFML developer

sNIk

  • Newbie
  • *
  • Posts: 10
    • View Profile
How can I use OpenGL commands for drawing on RenderTexture?
« Reply #5 on: January 24, 2012, 05:12:32 pm »
Quote from: "Laurent"
Quote
I solved that problem

How?


i think he used glViewport(0,0,width,height). i had a similiar issue these days and could solve it by updating the opengl viewport before drawing to a texture.
OS: Gentoo Linux
Kernel: 2.6.39

GPU: Radeon HD 3650
CPU: Intel(R) Core(TM)2 Duo CPU     T9400  @ 2.53GHz

 

anything