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

Author Topic: Missing OpenGL primitive types  (Read 5842 times)

0 Members and 1 Guest are viewing this topic.

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Missing OpenGL primitive types
« on: July 10, 2012, 12:42:06 pm »
I've noticed that only 7 out 10 OpenGL primitive types are represented in sf::PrimitiveType.
Why are the 3 other ones missing? (GL_LINE_LOOP, GL_QUADS_STRIP, GL_POLYGON)?
Could they be added? They could be useful.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Missing OpenGL primitive types
« Reply #1 on: July 10, 2012, 01:16:54 pm »
I'd like the API to remain as simple as possible. Therefore, I have implemented only the most used primitive types, and keep the others for later, when I have more feedback. I don't like to implement things "just because they are available".

If you don't need them, don't request them ;)
Laurent Gomila - SFML developer

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Re: Missing OpenGL primitive types
« Reply #2 on: July 10, 2012, 02:35:58 pm »
I'd like the API to remain as simple as possible. Therefore, I have implemented only the most used primitive types, and keep the others for later, when I have more feedback. I don't like to implement things "just because they are available".
I understand your point, but if you provide OpenGL primitive types, then users may expect to be able to use all the 10 of them, as they are all well known and documented.
And the enum PrimitiveType already exists, so the API is barely impacted.

If you don't need them, don't request them ;)
You're right, so here are the use cases that lead me to notice they are missing ;)

- Drawing a hexagonal-tiled map:
// create hexagon (6 vertices) for each tile
sf::Vertex vertices[NB_TILES * 6];
...
// drawing tiles
for (int i = 0; i < NB_TILES; ++i)
    target.draw(vertices + (i * 6), 6, GL_POLYGON, states);

which would be more optimized than using a ConvexShape per tile, especially if you don't need transformations for each tile.
And GL_POLYGON could have many other usages anyway.

- I was also trying to draw the outline of a shape, LINE_LOOP could spare the user from creating an additional Vertex for looping with LINE_STRIP.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Missing OpenGL primitive types
« Reply #3 on: July 10, 2012, 02:52:51 pm »
Quote
I understand your point, but if you provide OpenGL primitive types, then users may expect to be able to use all the 10 of them, as they are all well known and documented.
I don't provide OpenGL primitive types, I provide SFML primitive types. OpenGL is just an implementation detail, people shouln't expect sfml-graphics to be a thin wrapper around OpenGL. It has its own API.
That's why I said "request it if you need it, not because you know that it is internally available in OpenGL". Many things are available in OpenGL, you know ;)

Quote
You're right, so here are the use cases that lead me to notice they are missing
Ah, I prefer this kind of argument :)

Quote
Drawing a hexagonal-tiled map
GL_POLYGON is deprecated in OpenGL 3.x (if this article that I didn't read is a reliable source). There's no point supporting it; if it wasn't deprecated, I woudn't even use it anyway.

Quote
I was also trying to draw the outline of a shape, LINE_LOOP could spare the user from creating an additional Vertex for looping with LINE_STRIP.
Come on, it's just one vertex to add :P
Laurent Gomila - SFML developer

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Re: Missing OpenGL primitive types
« Reply #4 on: July 18, 2012, 05:45:56 pm »
GL_POLYGON is deprecated in OpenGL 3.x (if this article that I didn't read is a reliable source). There's no point supporting it; if it wasn't deprecated, I woudn't even use it anyway.

Nevermind, I've just discoverd that TrianglesFan cover all my needs as well.
Googling "opengl polygon deprecated" give some results indeed, I didn't know about this.