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

Author Topic: How to use Opengl 3.x in SFML  (Read 4376 times)

0 Members and 1 Guest are viewing this topic.

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
How to use Opengl 3.x in SFML
« on: April 16, 2016, 10:13:56 pm »
Hello, I'm trying to modify the standard vertex and fragment shader to be used with version 330.
Is it possible to do this without directly using opengl?

This is the vertex shader I'd like to use:

#version 330 core

layout(location = 0) in vec2 in_position;
layout(location = 1) in vec3 in_color;
layout(location = 2) in vec2 in_tex_coord;

out vec4 v2f_color;
out vec2 v2f_tex_coord;

uniform mat4 mvp;

void main()
{
    gl_Position = mvp * vec4(in_position.x, in_position.y, 0, 1);
        v2f_color = vec4(in_color, 1);
        v2f_tex_coord = in_tex_coord;
}

I draw to the render window using the VertexArray class.
Is it possible to get the model view projection matrix and send it to the shader?
Also, how would I go about sending "in" values to the vertex shader using sfml?

Or do I just have to go back to version 120 in order to not be bothered directly with opengl?

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: How to use Opengl 3.x in SFML
« Reply #1 on: April 24, 2016, 01:01:30 pm »
Maybe my questions wasnt very clear.
I want to know if I have to use low level opengl in order to use version higher than 120, because after 120 things like gl_TexCoord or gl_ModelViewProjectionMatrix are deprecated. So you have to pass them to the shader manually.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: How to use Opengl 3.x in SFML
« Reply #2 on: April 24, 2016, 01:04:28 pm »
I want to know if I have to use low level opengl in order to use version higher than 120, because after 120 things like gl_TexCoord or gl_ModelViewProjectionMatrix are deprecated. So you have to pass them to the shader manually.
You do.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: How to use Opengl 3.x in SFML
« Reply #3 on: April 24, 2016, 04:00:35 pm »
Cheers

 

anything