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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jorne22

Pages: [1]
1
Feature requests / Graphics: Support for more PrimitiveTypes
« on: March 18, 2019, 06:12:23 pm »
Using geometry shaders, I would like to implement silhouette testing of geometry as demonstrated here. To do this, the geometry shader requires adjacency data modes which SFML currently doesn't have support for.

RenderTarget::drawPrimitives(...) can be modified to accomodate adjacency modes by adding

Code: [Select]
GL_LINE_STRIP_ADJACENCY,
GL_LINES_ADJACENCY,
GL_TRIANGLE_STRIP_ADJACENCY,
GL_TRIANGLES_ADJACENCY

to the modes[] GLEnum inside the drawPrimitives(...) function. To access these modes, the PrimitiveType enum can be modified appropriately. This makes these new modes easy to access via window.draw(...)

The main caveat with this is that the above modes require OpenGL 3.2 or higher. I take it this would affect compatibility across devices?

2
Graphics / Re: Using geometry shaders on sf::Drawables
« on: March 18, 2019, 02:52:50 pm »
Thank you binary, that turned out to be the cause of the issue.

For any future readers, I was able to input sf::Drawable data into the geometry shader by replacing

Code: [Select]
layout (points) in;
with

Code: [Select]
layout (triangles) in;

3
Graphics / Re: Using geometry shaders on sf::Drawables
« on: March 18, 2019, 10:16:38 am »
In my code above I'm attempting to apply my shader to two different objects: an sf::circleshape as well as an sf::vertex.

As you can see, the window displays the desired output when operating on the sf::vertex I.e. the pink triangle.

However, the line
Code: [Select]
window.draw(shape2, &shader);, where I'm attempting to draw the circle shape, in fact doesn't draw anything, and I'm not sure why. I would have expected there to be a circular pattern of triangles in place of the original vertices of the circle.

Even if you replace the geometry shader with one that passes vertices through unmodified, the circleshape is nowhere to be seen.

4
Graphics / Using geometry shaders on sf::Drawables
« on: March 17, 2019, 08:45:14 pm »
Hi, I've been having some trouble using geometry shaders on drawables such as sf::Circles and sf::ConvexShapes. When attempting to draw the object with a loaded geometry shader, nothing is drawn whatsoever. I can only get the geometry shader to successfully execute on an array of sf::Vertex (sf::Vertex[]). I would have expected the geometry shader naturally to operate on each vertex of an sf::Drawable and at least display something, though I'm not well versed in what goes on under the hood of window.draw() so I'm probably missing something.

FWIW I'm on SFML-2.4.2 with MinGW 6.1.0. Here's my code:

Code: [Select]
//main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window;
    sf::VideoMode mode(800, 800);
    window.create(mode, "test");

    sf::Shader shader;
    shader.loadFromFile("./test.vert", "./test.geom", "./test.frag");

    sf::Vertex shape[] = {sf::Vertex({400.0f, 400.0f})};

    sf::CircleShape shape2(5.0f);
    shape2.setPosition(400, 100);
    sf::Drawable* draw = &shape2;

    while(window.isOpen())
    {
        sf::Event currEvent;

        while(window.pollEvent(currEvent))
        {
            switch(currEvent.type)
            {
                case(sf::Event::Closed):
                    window.close();
                    break;
                default:
                    break;
            }
        }

        window.clear(sf::Color::Black);

        window.draw(shape, 1, sf::Points, &shader);
        window.draw(shape2, &shader);

        window.display();
    }
}

Code: [Select]
//test.vert
void main()
{
    vec4 vertex = gl_ModelViewMatrix * gl_Vertex;

    gl_Position = gl_ProjectionMatrix * vertex;

    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_FrontColor = gl_Color;
}

Code: [Select]
//test.geom
layout (points) in;

layout (triangle_strip, max_vertices = 3) out;


// Main entry point
void main()
{
    vec4 offset = vec4(0.1, vec3(0.0));
    vec4 offset2 = vec4(0.0, 0.1, 0.0, 0.0);

    gl_Position = gl_in[0].gl_Position + offset;
    EmitVertex();

    gl_Position = gl_in[0].gl_Position - offset;
    EmitVertex();

    gl_Position = gl_in[0].gl_Position + offset2;
    EmitVertex();

    EndPrimitive();
}

Code: [Select]
//test.frag
void main()
{
    gl_FragColor = vec4(1.0,0.0,1.0,1.0);
}

The window displays a pink triangle at the centre of the window but there is no circleshape or other geometry to be seen.

Pages: [1]