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

Author Topic: Can we make RenderStates and Drawable loadable resources?  (Read 9255 times)

0 Members and 1 Guest are viewing this topic.

therocode

  • Full Member
  • ***
  • Posts: 125
    • View Profile
    • Development blog
Re: Can we make RenderStates and Drawable loadable resources?
« Reply #15 on: May 27, 2015, 10:17:56 pm »
How does being able to load collada and other such 3D vertex formats benefit the common use cases for a multimedia library?

The use case you stated was really contrived and complicated and I can't see that arise in even 1 out of 100 applications. You'll have to describe a more real-world general use case which actually sounds attractive to other people than your own very specific usage. Until you do that you'll not manage to convince anyone.

Also, saying "why not adding it?" is not a valid argument. Things are added for proper reasons, not lack of counter arguments. The burden of proof, so to say, is on you.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Can we make RenderStates and Drawable loadable resources?
« Reply #16 on: May 27, 2015, 10:20:23 pm »
I completely agree with therocode; it doesn't seem like your use case is a limitation that you actually encountered while writing an SFML application ;)

Please read also the points listed in the "Scope" paragraph here. Most of those points apply to your feature request.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

GraphicsWhale

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Can we make RenderStates and Drawable loadable resources?
« Reply #17 on: May 28, 2015, 01:12:30 am »
Using a 3D format to support 2D geometry is a terrible idea.

3D formats exist because 3D is notably more difficult than 2D, and unless you're creating a voxel engine it would be extremely difficult to create 3D models without some sort of modeling software. And of course, you need a specified format that your modeling software supports and a parser is available for it. Hence such a formats' existence.

2D almost never needs such a system. Pretty much any problem from rendering to collision can be handled without resorting to detailed geometry files. Which would greatly explain why such a format doesn't even exist.

SFML is fairly high level, and mostly is for taking away complexity where it doesn't benefit the developer (such as dealing with OpenGL, OpenAL, the native API, etc), but assumes you can handle everything that is irrelevant to it's libraries (system, sound, graphics, networking, etc). Parsing non-standard formats is one of those things.

You might want to parse X format, the next guy Y format, but we can't parse everything in existence. What SFML can do is utilize formats like PNG and WAV because they're ubiquitous. And A 3D format not utilized properly is still considered, at least by me, to be non-standard.

But I still don't know why you want to do this. If you want your game easily editable, do like I said and just use a scripting language, and if you want to simplify modding/development even more, have your engine work out the exact vertex coordinates on it's own.

After all, wouldn't:

draw.lua
local shader = graphics.getShader("shaders/custombutton.vert", "shaders/custombutton.frag")
function drawButton(button)
    graphics.useShader(shader)
    graphics.setTexture(button_texture)
    graphics.drawRectangle(button:getX(), button:getY(), button:getWidth(), button:getHeight())
end
 

Be easier to edit AND a lot more flexible than this?

button_vertices.obj
v 0.0, 0.0, 0.0
v 0.0, 1.0, 0.0
v 1.0, 0.0, 0.0
v 1.0, 0.0, 0.0
v 0.0, 1.0, 0.0
v 1.0, 1.0, 0.0
t 0.0, 0.0, 0.0
t 0.0, 1.0, 0.0
t 1.0, 0.0, 0.0
t 1.0, 0.0, 0.0
t 0.0, 1.0, 0.0
t 1.0, 1.0, 0.0
 

button_draw_details.txt
vertex_shader=shaders/custombutton.vert
fragment_shader=shaders/custombutton.frag
 

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Can we make RenderStates and Drawable loadable resources?
« Reply #18 on: May 28, 2015, 02:18:57 pm »
If you want to load sf::VertexArray from a file, there'd indeed be some file format to use: SVG. However, implementing and loading would be another thing (and it can get complicated).

I agree, it would be cool being able to load vector graphics from files you can just edit in some editor (like Inkscape), but unfortunately it's a rather complex topic. :)

Doing so for 3D formats would make things even more complicated without any real gain.

 

anything