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

Author Topic: SFML 2.0 Shader class vs own shader class for 3D  (Read 2634 times)

0 Members and 1 Guest are viewing this topic.

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Shader class vs own shader class for 3D
« on: February 11, 2012, 10:23:59 pm »
So, I have taken a quick look at the SFML shader class in 2.0 and have a question. Can you use the SFML Shaders for a 3D shader-based setup, or should I write my own shader class. I know 3D is not the focus of SFML at this time, so would it be better to write my own Shader class, or can SFML handle it?

Thanks,
Kreed

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Shader class vs own shader class for 3D
« Reply #1 on: February 11, 2012, 10:31:48 pm »
What you can do depends on the shader that you write, not on the class that manages it ;)

So yes, it can handle 3D.
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Shader class vs own shader class for 3D
« Reply #2 on: February 12, 2012, 08:33:44 am »
The only real question I have, is how do Ido this with the SFML shaders? I don't see a function for this in the documentation.

GLuint loc = glGetAttribLocation( program, "vPosition" );
glEnableVertexAttribArray( loc );
glVertexAttribPointer( loc, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0) );

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Shader class vs own shader class for 3D
« Reply #3 on: February 12, 2012, 09:49:08 am »
Oh yeah, sf::Shader doesn't support generic vertex attributes. Sorry.
Laurent Gomila - SFML developer

kreed

  • Newbie
  • *
  • Posts: 14
    • View Profile
SFML 2.0 Shader class vs own shader class for 3D
« Reply #4 on: February 13, 2012, 11:26:47 pm »
That's fine, I was just confused. I'll write my own Shader class. SFML is still awesome regardless of that.

MickaGL

  • Newbie
  • *
  • Posts: 6
    • View Profile
SFML 2.0 Shader class vs own shader class for 3D
« Reply #5 on: February 20, 2012, 09:05:18 pm »
or you can add this in the "shader.hpp"

Code: [Select]
   unsigned int GetProgram() const
    {
        return myShaderProgram;
    }

 

anything