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

Author Topic: Error when attempting to load a shader from a file  (Read 3083 times)

0 Members and 1 Guest are viewing this topic.

stewart

  • Newbie
  • *
  • Posts: 9
    • View Profile
Error when attempting to load a shader from a file
« on: September 15, 2013, 01:15:55 pm »
(C++ and SFML noob)

Been looking at this for 4 hours now. Got me beat. I can't load a shader from a file. I am running VS Express 2012, SFML 2.1, Windows 8.

My code:

        sf::Shader shader;
        shader.loadFromFile("C:\\Users\\Stewart\\Documents\\Visual Studio 2012\\Projects\\Stewmines\\bloom",  sf::Shader::Fragment);
 


The shader. (Downloaded and pasted). I just wanted to get something working before I started hacking away.
uniform sampler2D bgl_RenderedTexture;

void main()
{
   vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   int j;
   int i;

   for( i= -4 ;i < 4; i++)
   {
        for (j = -3; j < 3; j++)
        {
            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
        }
   }
       if (texture2D(bgl_Rend eredTexture, texcoord).r < 0.3)
    {
       gl_FragColor = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
    }
    else
    {
        if (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
        {
            gl_FragColor = sum*sum*0.009 + texture2D(bgl_RenderedTexture, texcoord);
        }
        else
        {
            gl_FragColor = sum*sum*0.0075 + texture2D(bgl_RenderedTexture, texcoord);
        }
    }
}
 

When my program executes the loadFromFile member function I get the following error

Unhandled exception at 0x6E31DD22 (msvcr110.dll) in Stewmines.exe: 0xC0000005: Access violation reading location 0x00995000.
 

The output window gives me the following garble. Note the total output is about 100 - 200 lines however I have included only the last two as each line is the same as the first.
&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯
&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;¯&#9632;^&#8616;ÏP&#9787;´ &#9829;î û î û 8 û 8
 û  PÖ
 

The output that VS gives me. Again I have only added the last few lines to keep this post sane :).

First-chance exception at 0x6E31DD22 (msvcr110.dll) in Stewmines.exe: 0xC0000005: Access violation reading location 0x00995000.
Unhandled exception at 0x6E31DD22 (msvcr110.dll) in Stewmines.exe: 0xC0000005: Access violation reading location 0x00995000.
The thread 0x9f4 has exited with code 0 (0x0).
The thread 0x1524 has exited with code 0 (0x0).
The program '[8024] Stewmines.exe' has exited with code 0 (0x0).
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error when attempting to load a shader from a file
« Reply #1 on: September 15, 2013, 02:36:08 pm »
Make sure that you don't mix debug and release, as stated in the tutorial.
Laurent Gomila - SFML developer

stewart

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Error when attempting to load a shader from a file
« Reply #2 on: September 16, 2013, 02:31:08 am »
Make sure that you don't mix debug and release, as stated in the tutorial.

Thanks Laurent. I have a feeling I am liking to release form debug.  Will check at home tonight.

stewart

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Error when attempting to load a shader from a file
« Reply #3 on: September 16, 2013, 10:31:58 am »
Make sure that you don't mix debug and release, as stated in the tutorial.

Confirmed.  To all who encounter this issue: Make sure that you link to the debug libs and not the release libs. This can be done in your project settings under VS 2012. Debug libs have a -d appended to the file name.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Error when attempting to load a shader from a file
« Reply #4 on: September 16, 2013, 10:38:06 am »
... or just read the tutorials carefully :P
Laurent Gomila - SFML developer