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

Author Topic: OpenGL SFML graphics module troubles [Solved].  (Read 2350 times)

0 Members and 1 Guest are viewing this topic.

Misant

  • Newbie
  • *
  • Posts: 3
    • View Profile
OpenGL SFML graphics module troubles [Solved].
« on: September 07, 2014, 04:00:59 am »
Hello,
After searching the forum, the only other thread I could find that covered this was from 2012:
http://en.sfml-dev.org/forums/index.php?topic=7508.msg49549#msg49549

Unfortunately, the thread concludes with recommending that he updates his version as the new version may have contained a fix.

However, I'm having the exact same difficulty. Basically, I'm unable to render 2D text in an SFML window that's integrated with OpenGL. My code setup is identical to the OP in the aforementioned thread and generally, is identical to the OpenGL example in the SDK. The only difference is the inclusion of a VBO. The OpenGL elements, objects, textures all render fine. However, the 2D SFML elements (text) do not.

If I remove the VBO, everything renders correctly, though it would be extremely useful to be able to use them. Is there a workaround for this, or is it still a known problem?

I'll refrain from posting the code, if only because the relevant elements are identical to the SDK example. In theory, I'm set up correctly, and can get the SDK example working fine. However, when implementing the VBO for the OpenGL elements, the 2D SFML text stops working.

Relevant info: Ubuntu 14.04, OpenGL 4.4, SFML 2.1

I truly appreciate any advice, and thank you in advance. :)
« Last Edit: September 08, 2014, 12:30:22 am by Misant »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: OpenGL SFML graphics module troubles.
« Reply #1 on: September 07, 2014, 05:39:34 am »
Try
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
before drawing with SFML.

Misant

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: OpenGL SFML graphics module troubles.
« Reply #2 on: September 07, 2014, 06:06:16 am »
Oh, wow. I was so not expecting a working answer so quickly :D

That works perfectly and fixes everything.

If you don't mind humoring me, why is binding a vao before drawing necessary? When I saw your answer I was really skeptical, but thought I'd try it anyway. I was a little shocked that it worked, to be honest.

I'm truly interested, if you have time to explain, but, either way, you have my genuine gratitude.

Thanks again! :)

edit*
also, I'm new to this forum. Is there a form of reputation or anything I can give in response to your answer, or do I need to mark anything closed, or is it all good?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: OpenGL SFML graphics module troubles.
« Reply #3 on: September 07, 2014, 01:36:51 pm »
edit*
also, I'm new to this forum. Is there a form of reputation or anything I can give in response to your answer, or do I need to mark anything closed, or is it all good?

I believe adding "[Solved]" to the thread title is the norm here.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: OpenGL SFML graphics module troubles.
« Reply #4 on: September 07, 2014, 02:16:00 pm »
I'm new to this forum.
Hi, and welcome!  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: OpenGL SFML graphics module troubles.
« Reply #5 on: September 07, 2014, 02:45:12 pm »
Quote
If you don't mind humoring me, why is binding a vao before drawing necessary? When I saw your answer I was really skeptical, but thought I'd try it anyway. I was a little shocked that it worked, to be honest.

Because when you bind with the id 0 (NULL) it is the same as unbinding the previous bound object. When you leave your own objects bound it messing up SFML's rendering. If you search around I believe binary1248 has a post on this explaining in more detail.
« Last Edit: September 07, 2014, 02:46:49 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Misant

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: OpenGL SFML graphics module troubles.
« Reply #6 on: September 08, 2014, 12:11:53 am »
Quote
If you don't mind humoring me, why is binding a vao before drawing necessary? When I saw your answer I was really skeptical, but thought I'd try it anyway. I was a little shocked that it worked, to be honest.

Because when you bind with the id 0 (NULL) it is the same as unbinding the previous bound object. When you leave your own objects bound it messing up SFML's rendering. If you search around I believe binary1248 has a post on this explaining in more detail.

Ah, that makes sense, I think. I'll look up that post.

And thanks for the welcomes everyone :)

 

anything