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

Author Topic: SFML 2.0 - gl commands  (Read 3371 times)

0 Members and 2 Guests are viewing this topic.

Roswell_r

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML 2.0 - gl commands
« on: April 01, 2011, 03:51:39 am »
with sfml2.0 can I inherit from drawable, overload the render function and then call my own gl commands such as glbegin glend glvertex etc... so i can draw basic shapes like lines or points?

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
SFML 2.0 - gl commands
« Reply #1 on: April 01, 2011, 08:04:12 am »
You can, but it's not designed for (yet ? )

SFML optimise rendering of basic Drawables such like sprite with sf::Renderer, although you won't with openGL calls like glBegin.
Pointilleur professionnel

Roswell_r

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML 2.0 - gl commands
« Reply #2 on: April 01, 2011, 12:35:08 pm »
I might have to do a speed test to see if drawing a heap of shapes in a render function is faster then using gl commands to do the lines with GL_LINES.

But I tested glcommands and they work fine. I did PushStates and PopStates after I was done however.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 - gl commands
« Reply #3 on: April 01, 2011, 01:01:33 pm »
Quote
I might have to do a speed test to see if drawing a heap of shapes in a render function is faster then using gl commands to do the lines with GL_LINES.

Seriously... this is unlikely to happen, don't bother with tests ;)
Direct OpenGL will always be faster than SFML since SFML is OpenGL + a layer of abstraction. In this case it may make a big difference on performances.
Laurent Gomila - SFML developer

Roswell_r

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML 2.0 - gl commands
« Reply #4 on: April 16, 2011, 07:25:56 am »
bringing back and old thread because its related, I have decided to use gl commands in my drawable render overload because I could be constantly creating new lines/shapes.

however what I have found is I can't seem to render anything in local space. I am sure the Render function has the modelview matrix already pushed onto the matrix stack and so my verts should be adjusted accordingly, however i don't see any lines when i draw them.

here is basically what im doing:
renderer.push
glcolor4i
gl set line width
glbegin(line)
glvertex2fs...
glend
renderer.pop

but nothing comes up. Any ideas? I can post code if required.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 - gl commands
« Reply #5 on: April 16, 2011, 09:38:48 am »
SFML 2?
Laurent Gomila - SFML developer

Roswell_r

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML 2.0 - gl commands
« Reply #6 on: April 17, 2011, 12:40:49 pm »
yes sfml2.0

Edit: Figured it out, I remember from old sfml 1.6 that Draw would apply matrices and Render would do the drawing. But in SFML2 it is different, Draw just applies a matrix to the renderer and the Renderer AddVertex function performs multiplication before calling the glVertex2f.

I've had to make modifications to sfml2 renderer to handle drawing lines. should add it sometime laurent!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 - gl commands
« Reply #7 on: April 17, 2011, 02:26:39 pm »
I plan to rewrite all the internals (and public API as well) of drawables for SFML 2. So don't bother too much with the current code, and don't worry about features that are currently missing ;)
Laurent Gomila - SFML developer