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

Author Topic: New graphics API ready  (Read 93211 times)

0 Members and 2 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #75 on: December 12, 2011, 12:57:46 pm »
Quote
I can try this same thing using open source drivers and then I can try to install newest fglrx.

That would be really cool. Thanks for helping.
Laurent Gomila - SFML developer

Wyamiz

  • Newbie
  • *
  • Posts: 3
    • View Profile
New graphics API ready
« Reply #76 on: December 12, 2011, 02:43:38 pm »
Quote from: "Laurent"
Quote
I can try this same thing using open source drivers and then I can try to install newest fglrx.

That would be really cool. Thanks for helping.
It seems to work when using open source drivers :)
Seems like the problem was with fglrx after all. (Or maybe it was with Ubuntu's default configuration of fglrx...)

This new API looks pretty flexible. I can propably do now everything I want by just using SFML API without need for custom OpenGL calls. (Yes, I have been using this library for sometime although I only now registered myself to forum)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #77 on: December 12, 2011, 03:05:46 pm »
Quote
But only the 4 predefined ones. One cannot combine the modes like glBlendFunc(). Not that I needed this functionality right now, just generally

You can never mix OpenGL with SFML this way. So if you use your own OpenGL states, you won't be able to rewrite it with a SFML class. Whether it is particles or anything else.

Quote
I meant GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER. What's the correct term?

This is the correct term, I just didn't think about them ;)
SFML texture filters are supposed to be ok for any 2D rendering (filters other than "nearest" and "bilinear" are mostly for 3D), are you using something else for your particles?

Quote
It seems to work when using open source drivers

Good news :)

Quote
I can propably do now everything I want by just using SFML API without need for custom OpenGL calls.

If you have such a use case, can you tell me more about it?
I like to know what problems the new API is now able to solve compared to the old one.
Laurent Gomila - SFML developer

deadalnix

  • Newbie
  • *
  • Posts: 45
    • View Profile
New graphics API ready
« Reply #78 on: December 12, 2011, 03:17:56 pm »
Hi,

Do you know, approximatively, when this new API will be merged in SFML2 ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #79 on: December 12, 2011, 03:27:40 pm »
Quote
Do you know, approximatively, when this new API will be merged in SFML2 ?

Probably in one or two weeks.
But why is it important? It is in SFML 2, just in a different development branch.
Laurent Gomila - SFML developer

Marukyu

  • Newbie
  • *
  • Posts: 36
    • View Profile
New graphics API ready
« Reply #80 on: December 12, 2011, 07:31:41 pm »
Hi,

first of all, great job on the new API, it's looking great! I'm converting/rewriting my project for it right now, really looking forward to the speed boost once it's optimized.
There's something rather confusing about Vertices though: they allow you to set the coordinates of a texture, but I couldn't find any way to specify which texture a VertexArray should actually be rendered with. Am I overlooking something here or is that code just not written yet? A while ago, an example of the new API was posted, where sf::RenderTarget::SetTexture() or something like that was used, but that doesn't appear to be in the API (anymore).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #81 on: December 12, 2011, 08:08:09 pm »
The global states are now defined in sf::RenderStates, which you pass an instance when you call Draw.

Code: [Select]
sf::RenderStates states;
states.Texture = &texture;
window.Draw(vertexArray, states);

Which, using implicit constructors, can be shortened to:
Code: [Select]
window.Draw(vertexArray, &texture);
Laurent Gomila - SFML developer

Marukyu

  • Newbie
  • *
  • Posts: 36
    • View Profile
New graphics API ready
« Reply #82 on: December 12, 2011, 09:06:13 pm »
Ah, so that's what states are for. I'm rather new to hardware accelerated graphical programming and to the concept of Vertices in this context, so I was thinking it was some internal OpenGL stuff. Thank you for clearing it up! :)

Klaim

  • Full Member
  • ***
  • Posts: 137
    • View Profile
New graphics API ready
« Reply #83 on: December 13, 2011, 12:00:53 am »
Quote from: "Laurent"
Quote
Do you know, approximatively, when this new API will be merged in SFML2 ?

Probably in one or two weeks.
But why is it important? It is in SFML 2, just in a different development branch.


Because the next Ludum Dare is this week end? ;) Merging in the main branch means "it's stable enough" for a lot of devs.

Anyway I guess SFML 2 should be stabilized for the next one.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #84 on: December 13, 2011, 07:33:00 am »
Quote
Merging in the main branch means "it's stable enough" for a lot of devs

Yes, that's exactly why it's still in the 'drawables' branch ;)
I'd say that the code is stable enough, the public API almost stable, but the internal code is not optimized at all, so it's not ready for the master branch.
Laurent Gomila - SFML developer

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
New graphics API ready
« Reply #85 on: December 13, 2011, 04:50:40 pm »
Quick question: now that sf::Shape::Line is gone, how can I easily draw a line from point A to point B ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #86 on: December 13, 2011, 04:53:40 pm »
If your line has a thickness, it's a rectangle and you can use sf::RectangleShape.

If it has no thickness, you can draw two vertices in sf::Lines mode.
Laurent Gomila - SFML developer

batzer

  • Newbie
  • *
  • Posts: 2
    • View Profile
New graphics API ready
« Reply #87 on: December 13, 2011, 05:15:42 pm »
How exactly do you want to optimize the new rendering code?

It seems to be pretty optimized allready so far, but why do you set the OpenGL states on every draw call even though the shader may have to changed?
Isn't it faster to check if a state, shader or whatever has changed and then update it?

Sorry if this question is stupid. I have never used OpenGL before only Direct3D9 and Direct3D11 :)

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
New graphics API ready
« Reply #88 on: December 13, 2011, 05:33:30 pm »
Quote from: "Laurent"
If your line has a thickness, it's a rectangle and you can use sf::RectangleShape.

But if the line is neither vertical (A.x != B.x), nor horizontal (A.y != B.y), we must use trigonometry to compute the line length (rectangle width = distance between A and B), and then rotate the rectangle.

Quote from: "Laurent"
If it has no thickness, you can draw two vertices in sf::Lines mode.

I've played a bit with those primitive types, it's a nice feature :D
I will probably stick to this is solution when dealing with lines without thickness, I guess this is more optimized than using shapes.
But don't you think drawing a simple line should be more user-friendly than using primitive types?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New graphics API ready
« Reply #89 on: December 13, 2011, 05:51:11 pm »
Quote
It seems to be pretty optimized allready so far, but why do you set the OpenGL states on every draw call even though the shader may have to changed?
Isn't it faster to check if a state, shader or whatever has changed and then update it?

Yes... and this is exactly what I'm working on right now to optimize the code ;)

Quote
But if the line is neither vertical (A.x != B.x), nor horizontal (A.y != B.y), we must use trigonometry to compute the line length (rectangle width = distance between A and B), and then rotate the rectangle.

Yes. It's not a big deal.

Quote
I will probably stick to this is solution when dealing with lines without thickness, I guess this is more optimized than using shapes.

Yes, it's definitely more optimized.

Quote
But don't you think drawing a simple line should be more user-friendly than using primitive types?

I think it's pretty simple:
Code: [Select]
void DrawLine(sf::Vector2f a, sf::Vector2f b)
{
    sf::Vertex line[2] = {a, b};
    window.Draw(line, 2, sf::Lines);
}
Laurent Gomila - SFML developer