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 - SuperApe

Pages: 1 [2]
Thank you, yes, fixed. (the fancier original had a capital D there) 'Appreciated.

And, I agree, there should be a compilation error nestled in the build log output somewhere, but I'm not seeing it. Incidentally, another thing I tried was to insert my GLSL attempts into an online sandbox. SFML should output something if I just try and load a non-existent file or empty string, yeah?

    sf::Shader dummy;
    dummy.loadFromMemory("", sf::Shader::Fragment);

So, if this should show me an error, clearly, I'm not looking in the right place for it.

[EDIT:] ... and watching the shader variable, tracing via breakpoints, and watching the progress logged only confirms that, yes, the previous loading operations mentioned fail without mention in (all) console logs and, yes, the data in these is left uninitialized. :\

My experience with shaders is minimal, my experience is SFML is a little more, with C++ a little more than that. Now combining them, and stumped after trying and chasing the issues I can think of. Help / Ideas are appreciated.

This text drawn to the graphics window confirms that shaders are available.
    std::string debugText = "";
    if ( sf::Shader::isAvailable() )
        debugText = "Shaders are available on this system";
        debugText = "No shaders, sorry";

This was my initial attempt, using an external GLSL file, and after drawing a base tile layer, loading subsequent layers (roots, rocks, grass) and drawing them to the render texture called terrainGrassLayer using that shader:
    sf::Shader tileBlend;
    bool shaderLoaded = tileBlend.loadFromFile( "src/TerrainTest.glsl", sf::Shader::Fragment );
                if ( sf::Shader::isAvailable() && shaderLoaded )
                    // do alpha setting each tile for each terrain layer (potentially blending over texture) with GLSL
                    terrainGrassLayer.draw( terrainLayer, &tileBlend );
                    // tile blend shader not found, just draw tile with tile center alpha value
                    terrainLayer.setColor( pixelAlpha );
                    terrainGrassLayer.draw( terrainLayer );
                    // in other words, do far less interesting alpha assignment and draw to a render texture
        // (then in main loop)
        // draw calls
        rWin.setView( vw );
        rWin.draw( terrainLayerSprite );

With the above, I can confirm (again) Shaders are available, but that the shader did not load. I can confirm the shader did not load by commenting out the draw( terrainLayer ) line and seeing only a base terrain tile layer (dirt) drawn earlier on. So, only the else block works at this time, and shaderLoaded must be false.

I tried moving the filepath (project directory, cpp source directory, image asset directory in my project), tried re-writing the shader a couple times, including GLSL from SFML examples.

So, I tried loading from memory instead (figuring my GLSL, even the most basic I can make it) isn't right:
    const std::string fragmentShader = \
    "uniform sampler2D tSample;" \
    "uniform float tileAlphaCenter;" \
    "void main()" \
    "{" \
    "    vec4 pixel = texture2d( tSample, gl_TexCoord[0].xy );" \
    "    pixel.a = tileAlphaCenter;" \
    "    gl_FragColor = gl_Color * pixel;" \
    bool shaderLoaded = tileBlend.loadFromMemory( fragmentShader, sf::Shader::Fragment );

Still, shaderLoaded is false, and frustratingly, there is no standard error output. But, there should be, if the load didn't work, right? The idea that there is no SFML output, just warnings from the compiler regarding C++11 standards leads me to wonder if I'm looking for SFML errors in the wrong place in CodeBlocks. :\ Like, I say, I'm stumped and up for any ideas. 'Much appreciated.

'Need to see the GLSL file I tried?

uniform sampler2D tSample;
uniform float tileAlphaCenter;

void main()
    vec4 pixel = texture2d( tSample, gl_TexCoord[0].xy );
    pixel.a = tileAlphaCenter;
    gl_FragColor = gl_Color * pixel;

I'll save the much fancier GLSL file I started with for another time. ;)

Pages: 1 [2]