58
« on: December 08, 2011, 06:47:12 pm »
I have notced some more problems when it comes to SFML2 and linux,
usiing the following code:
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
sf::Texture tex;
tex.LoadFromFile("ship.png");
sf::Sprite spr = sf::Sprite(tex);
sf::Shader bloom;
bloom.LoadFromFile("Bloom.fx");
bloom.SetParameter("amount", 0.6f);
bloom.SetParameter("blurSize", 0.5f / 800);
sf::RenderTexture bloomImage;
bloomImage.Create(800,600);
sf::Sprite bloomSprite = sf::Sprite(bloomImage.GetTexture());
while (App.IsOpened())
{
sf::Event Event;
while (App.PollEvent(Event)) if (Event.Type == sf::Event::Closed) App.Close();
App.Clear();
bloomImage.Clear(sf::Color(0.f,0.f,0.f,0.f));
bloomImage.Draw(spr, bloom);
bloom.SetParameter("horizontal", 0);
bloomImage.Display();
App.Draw(bloomSprite, bloom);
bloom.SetParameter("horizontal", 1);
App.Display();
}
return 0;
}
and shader
#version 120
uniform float blurSize;
uniform float amount;
uniform sampler2D texture;
uniform float horizontal;
void main()
{
vec4 sum = vec4(0.0);
float gaussian[17] = float[17] (0.148, 0.145, 0.136, 0.123, 0.107, 0.090, 0.072, 0.055, 0.041, 0.029, 0.020, 0.013, 0.008, 0.005, 0.003, 0.002, 0.001);
int length = gaussian.length();
for (int i = -length + 1; i < length; i++)
{
vec2 coords = vec2(gl_TexCoord[0].x - i * blurSize, gl_TexCoord[0].y);
if (horizontal == 0)
coords = vec2(gl_TexCoord[0].x, gl_TexCoord[0].y - i * blurSize);
sum += texture2D(texture, coords) * gaussian[int(abs(i))] * 0.5;
}
float avg = dot(sum.rgb, vec3(0.299, 0.587, 0.114));
sum = vec4(avg, avg, avg, 1);
vec4 col = (sum * sum * amount) + texture2D(texture, gl_TexCoord[0].xy);
gl_FragColor = col;
}
It exits with error code 1, when i use gdb to debug and set a break point at exit I got this:
Reading symbols from /home/richy/codeblocks/anoy/bin/Debug/anoy...done.
(gdb) b exit
Function "exit" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (exit) pending.
(gdb) b _exit
Function "_exit" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (_exit) pending.
(gdb) b exit()
Function "exit()" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 3 (exit()) pending.
(gdb) run
Starting program: /home/richy/codeblocks/anoy/bin/Debug/anoy
[Thread debugging using libthread_db enabled]
Breakpoint 1, __GI_exit (status=1) at exit.c:99
99 exit.c: No such file or directory.
in exit.c
(gdb) bt
#0 __GI_exit (status=1) at exit.c:99
#1 0x00855697 in _intel_batchbuffer_flush ()
from /usr/lib/i386-linux-gnu/dri/i965_dri.so
#2 0x008594f0 in intel_flush () from /usr/lib/i386-linux-gnu/dri/i965_dri.so
#3 0x00859532 in ?? () from /usr/lib/i386-linux-gnu/dri/i965_dri.so
#4 0x009354b0 in _mesa_flush () from /usr/lib/i386-linux-gnu/dri/libdricore.so
#5 0x00935bce in _mesa_Flush () from /usr/lib/i386-linux-gnu/dri/libdricore.so
#6 0x00167ac1 in sf::priv::RenderTextureImplFBO::UpdateTexture (
this=0x8b5cc50)
at /home/richy/Desktop/LaurentGomila-SFML-09854ba/src/SFML/Graphics/RenderTextureImplFBO.cpp:140
#7 0x001670e0 in sf::RenderTexture::Display (this=0xbfffdb00)
at /home/richy/Desktop/LaurentGomila-SFML-09854ba/src/SFML/Graphics/RenderTexture.cpp:115
#8 0x080494e0 in main () at /home/richy/codeblocks/anoy/main.cpp:40
(gdb)
Also in linux I have noticed that unless you load textures once the current window has been created they are broken, however in windows you can load textures at any time and the images will be fine. not sure if this is meant to happen or what