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.


Topics - Richy19

Pages: [1] 2 3
1
System / Checking if thread is still running
« on: October 25, 2013, 12:07:14 pm »
Is there anyway to check if a thread is still alive in SFML?

2
General / Using SFML with libraries that are part of SFML
« on: August 10, 2013, 02:46:50 pm »
I know a while back there could be some problems when using a library (for example GLEW) that is included in SFML along side with SFML if both of these were linked to statically, I just wanted to know what the current state of it is?
Also would it be possible to know what sub-systems of SFML depend on what libraries?
I know the Audio one uses OpenAL and SNDFile, but what about the other subsystems?
My hope is to use SFML only for the window-ing, threading and networking (maybe audio if I ever add it) but I hopefully wont be using the graphics subsystem as I already have some clases that do this for me, however I will be using freetype, and glew as I am on OpenGL and I wanted to know what the rules are regarding this?

3
DotNet / SFML 2 and mono
« on: February 01, 2013, 02:27:40 am »
Im trying to get SFML.Net running o mono, I havejust recompiles SFML, CSFML and SFML.Net, however when trying to run the shader example that comes with SFML.Net I get:
Code: [Select]
Unhandled Exception: System.DllNotFoundException: libcsfml-graphics.so
  at (wrapper managed-to-native) SFML.Graphics.RenderWindow:sfRenderWindow_create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title) [0x00000] in <filename unknown>:0
  at shader.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-graphics.so
  at (wrapper managed-to-native) SFML.Graphics.RenderWindow:sfRenderWindow_create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at SFML.Graphics.RenderWindow..ctor (VideoMode mode, System.String title) [0x00000] in <filename unknown>:0
  at shader.Program.Main () [0x00000] in <filename unknown>:0
The application was terminated by a signal: SIGHUP

Im using the sfmlnet-xxx-2.dll.config files to remap the windows fdll's to linux .so
as so:
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
     <dllmap dll="csfml-audio-2" target="libcsfml-audio.so" />
  </configuration>


<?xml version="1.0" encoding="utf-8"?>
<configuration>
     <dllmap dll="csfml-graphics-2" target="libcsfml-graphics.so" />
  </configuration>


<?xml version="1.0" encoding="utf-8"?>
<configuration>
     <dllmap dll="csfml-window-2" target="libcsfml-window.so" />
  </configuration>

and the csfml files are in usr/local/lib:
Code: [Select]
richy@linux-nc18:/usr/local/lib> ls
Box2D                       libcsfml-network.so.2     libsfml-audio-d.so.2.0     libsfml-network.so.2
libBox2D.a                  libcsfml-network.so.2.0   libsfml-audio-s.a          libsfml-network.so.2.0
libBox2D.so                 libcsfml-system-d.so      libsfml-audio-s-d.a        libsfml-system-d.so
libBox2D.so.2.1.0           libcsfml-system-d.so.2    libsfml-audio.so           libsfml-system-d.so.2
libBulletCollision.a        libcsfml-system-d.so.2.0  libsfml-audio.so.1.6       libsfml-system-d.so.2.0
libBulletDynamics.a         libcsfml-system.so        libsfml-audio.so.2         libsfml-system-s.a
libBulletSoftBody.a         libcsfml-system.so.2      libsfml-audio.so.2.0       libsfml-system-s-d.a
libcsfml-audio-d.so         libcsfml-system.so.2.0    libsfml-graphics-d.so      libsfml-system.so
libcsfml-audio-d.so.2       libcsfml-window-d.so      libsfml-graphics-d.so.2    libsfml-system.so.1.6
libcsfml-audio-d.so.2.0     libcsfml-window-d.so.2    libsfml-graphics-d.so.2.0  libsfml-system.so.2
libcsfml-audio.so           libcsfml-window-d.so.2.0  libsfml-graphics-s.a       libsfml-system.so.2.0
libcsfml-audio.so.2         libcsfml-window.so        libsfml-graphics-s-d.a     libsfml-window-d.so
libcsfml-audio.so.2.0       libcsfml-window.so.2      libsfml-graphics.so        libsfml-window-d.so.2
libcsfml-graphics-d.so      libcsfml-window.so.2.0    libsfml-graphics.so.1.6    libsfml-window-d.so.2.0
libcsfml-graphics-d.so.2    libglfw.a                 libsfml-graphics.so.2      libsfml-window-s.a
libcsfml-graphics-d.so.2.0  libglfw.so                libsfml-graphics.so.2.0    libsfml-window-s-d.a
libcsfml-graphics.so        libLinearMath.a           libsfml-network-d.so       libsfml-window.so
libcsfml-graphics.so.2      libluajit-5.1.a           libsfml-network-d.so.2     libsfml-window.so.1.6
libcsfml-graphics.so.2.0    libluajit-5.1.so          libsfml-network-d.so.2.0   libsfml-window.so.2
libcsfml-network-d.so       libluajit-5.1.so.2        libsfml-network-s.a        libsfml-window.so.2.0
libcsfml-network-d.so.2     libluajit-5.1.so.2.0.0    libsfml-network-s-d.a      lua
libcsfml-network-d.so.2.0   libsfml-audio-d.so        libsfml-network.so         pkgconfig
libcsfml-network.so         libsfml-audio-d.so.2      libsfml-network.so.1.6

Whats even more weird is a project I had that included SFML.Net is now using the newly compiled SFML.Net DLL's and its complaining becuse window.isOpen() doesnt exist, it wants the method to be IsOpen(). However im sure you changd the naming convention for the SFML.Net and CSFML a long time ago.

Anyone know whats going on?

4
Window / Check is window is focused
« on: September 06, 2012, 05:21:54 am »
Is there anyway to check if the window is focused?
I want to hidemouse/set mouse position to center only when it is focused

5
Graphics / Getting font glyphs
« on: July 15, 2012, 09:40:04 pm »
m trying to write my own font rendering system using OGL, and for it I get te texture from a sf::Font like so:

#ifndef BITMAPTEXT_HPP_INCLUDED
#define BITMAPTEXT_HPP_INCLUDED

#include <GL/glew.h>
#include <GL/gl.h>
#include <vector>
#include <SFML/Graphics.hpp>
#include "./Shader.hpp"
#include <glm/glm.hpp>

class BitmapText
{
protected:
    glm::vec3 Pos;
    glm::mat4 Model;

    GLuint vertexbuffer;
    GLuint uvbuffer;

    sf::Font font;
    sf::Texture bitmap;
    Shader shader;
    std::vector<sf::IntRect> Positions;
    std::string text;
    glm::vec4 Color;


    GLuint TextureID;
    GLuint ColorID;
    GLuint MVPID;
    GLuint PositionID;
    GLuint UVID;

    void Rebuild();
public:
    ///
    /// \brief Empty constructor
    ///
    BitmapText();

    ///
    /// \brief Empty deconstructor
    ///
    ~BitmapText();

    ///
    /// \brief Construct class from given arguments
    /// \param Bitmap image
    /// \param Bitmap position array
    bool LoadFile(const std::string& fontFile, int siz );

    ///
    /// \brief Set text
    ///
    void SetText(const std::string& eText);

    void SetPosition(const glm::vec2 &pos);

    virtual void Update();

    virtual void Draw(glm::mat4 &VP);

    void SetColor(float r , float g, float b , float a);
};

#endif // BITMAPTEXT_HPP_INCLUDED








#include <glm/gtx/transform2.hpp>
#include <GL/glew.h>
#include "./BitmapText.hpp"
#include <GL/glfw.h>
#include <iostream>
#include <fstream>
#include "./Utilities.hpp"
#include <limits>


BitmapText::BitmapText()
{

    std::string vertexShader =
    "#version 120\n"
    "uniform mat4 MVP;\n"
    "attribute vec4 Position;\n"
    "attribute vec2 UV;\n"
    "varying vec2 uv;\n"

    "void main(){\n"
        "uv = UV;\n"
        "gl_Position =  MVP * Position;\n"
    "}";

    std::string fragmentShader =
    "#version 120\n"
    "varying vec2 uv;\n"
    "uniform sampler2D Texture;\n"
    "uniform vec4 Color;\n"
    "void main(){\n"
        "vec4 textur = texture2D( Texture, uv ).rgba;\n"
        "textur.rgb = Color.rgb;\n"
        "if(textur.a == 0.0f){\n"
            "textur = vec4(0.0f, 0.0f, 0.0f, 0.0f);\n"
        "}\n"
        "gl_FragColor = textur;\n"
    "}";


    shader.LoadShaderCode(vertexShader ,fragmentShader);




    Color = glm::vec4(1.0f);

    text = "hi";

    glGenBuffers(1, &vertexbuffer);
    glGenBuffers(1, &uvbuffer);



    MVPID = glGetUniformLocation(shader.GetShaderID(), "MVP");
    TextureID = glGetUniformLocation(shader.GetShaderID(), "Texture");
    PositionID = glGetAttribLocation(shader.GetShaderID(), "Position");
    UVID = glGetAttribLocation(shader.GetShaderID(), "UV");
    ColorID = glGetUniformLocation(shader.GetShaderID(), "Color");

//Rebuild();
}

BitmapText::~BitmapText()
{
    glDeleteBuffers(1, &vertexbuffer);
    glDeleteBuffers(1, &uvbuffer);
}

bool BitmapText::LoadFile(const std::string& fontFile, int siz)
{
    font.loadFromFile(fontFile);

    for(unsigned char c = 0; c < std::numeric_limits<unsigned char>::max(); c++)
    {
        sf::Glyph g = font.getGlyph(c, siz, false);
        Positions.push_back(g.textureRect);
    }
    bitmap = font.getTexture( siz );
    bitmap.bind();
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);

    Rebuild();
    return true;
}

void BitmapText::SetText(const std::string& eText)
{
    text = eText;
    Rebuild();
}

void BitmapText::SetPosition(const glm::vec2& pos)
{
    Pos = glm::vec3(pos.x, pos.y, 0.1f);
    Rebuild();
}

void BitmapText::Update()
{

}

void BitmapText::Draw(glm::mat4 &VP)
{

    //glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
    glm::mat4 MVP = VP * Model;

    shader.Bind();
    glUniformMatrix4fv(MVPID, 1, GL_FALSE, &MVP[0][0]);

    glActiveTexture(GL_TEXTURE0);
    bitmap.bind();
    glUniform1i(TextureID, 0);

    glUniform4fv(ColorID,1 , &Color[0]);

    glEnableVertexAttribArray(PositionID);
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glVertexAttribPointer(
        PositionID,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
        3,                  // size
        GL_FLOAT,           // type
        GL_FALSE,           // normalized?
        0,                  // stride
        (void*)0            // array buffer offset
    );

    glEnableVertexAttribArray(UVID);
    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glVertexAttribPointer(
        UVID,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
        2,                  // size
        GL_FLOAT,           // type
        GL_FALSE,           // normalized?
        0,                  // stride
        (void*)0            // array buffer offset
    );

    glDrawArrays(GL_TRIANGLES, 0, text.size() * 6);

    glDisableVertexAttribArray(UVID);
    glDisableVertexAttribArray(PositionID);


    glBindTexture(GL_TEXTURE_2D, 0);
    Shader::Unbind();



    //if(asLines)
    //    glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
    //else
    //    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);

}

void BitmapText::Rebuild()
{
    std::vector<GLfloat> VertexList;
    std::vector<GLfloat> UVList;

    float disp = 0.0f;
    float largestHeight = 0.0f;
    for(int i = 0; i < text.size(); i++)
    {
        sf::IntRect charRect = Positions[text.c_str()[i]];
        if(largestHeight < charRect.height) largestHeight = charRect.height;


        VertexList.push_back(0.0f + disp);
        VertexList.push_back(0.0f);
        VertexList.push_back(0.0f);

        VertexList.push_back(0.0f + disp);
        VertexList.push_back(charRect.height);
        VertexList.push_back(0.0f);

        VertexList.push_back(charRect.width + disp);
        VertexList.push_back(0.0f);
        VertexList.push_back(0.0f);

        VertexList.push_back(charRect.width + disp);
        VertexList.push_back(0.0f);
        VertexList.push_back(0.0f);

        VertexList.push_back(0.0f + disp);
        VertexList.push_back(charRect.height);
        VertexList.push_back(0.0f);


        VertexList.push_back(charRect.width + disp);
        VertexList.push_back(charRect.height);
        VertexList.push_back(0.0f);



        UVList.push_back(charRect.left / bitmap.getSize().x);
        UVList.push_back(charRect.top / bitmap.getSize().y);

        UVList.push_back(charRect.left / bitmap.getSize().x);
        UVList.push_back((charRect.top + charRect.height) / bitmap.getSize().y);

        UVList.push_back((charRect.left + charRect.width ) / bitmap.getSize().x);
        UVList.push_back(charRect.top / bitmap.getSize().y);

        UVList.push_back((charRect.left + charRect.width ) / bitmap.getSize().x);
        UVList.push_back(charRect.top / bitmap.getSize().y);

        UVList.push_back(charRect.left / bitmap.getSize().x);
        UVList.push_back((charRect.top + charRect.height) / bitmap.getSize().y);

        UVList.push_back((charRect.left + charRect.width ) / bitmap.getSize().x);
        UVList.push_back((charRect.top + charRect.height) / bitmap.getSize().y);

        disp += charRect.width;
    }


    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glBufferData(GL_ARRAY_BUFFER, VertexList.size() * sizeof(GLfloat), &VertexList[0], GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glBufferData(GL_ARRAY_BUFFER, UVList.size() * sizeof(GLfloat), &UVList[0], GL_STATIC_DRAW);

    Model = glm::translate(glm::mat4(1.0f),Pos.x , Pos.y, 0.0f);
    //MVP =  * Model;

}

void BitmapText::SetColor(float r , float g, float b , float a)
{
    Color.x = r;
    Color.y = g;
    Color.z = b;
    Color.w = a;
}


 

The code to get the glyphs is:

bool BitmapText::LoadFile(const std::string& fontFile, int siz)
{
    font.loadFromFile(fontFile);

    for(unsigned char c = 0; c < std::numeric_limits<unsigned char>::max(); c++)
    {
        sf::Glyph g = font.getGlyph(c, siz, false);
        Positions.push_back(g.textureRect);
    }
    bitmap = font.getTexture( siz );
    bitmap.bind();
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glGenerateMipmap(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);

    Rebuild();
    return true;
}
 

Is this the correct way to do it?

6
Audio / Help with sound positioning
« on: July 09, 2012, 02:57:14 am »
Im trying to work with 2d sounds, for It I have this code:

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{

    sf::RenderWindow App(sf::VideoMode(600, 600), "My window");

    sf::Texture t;
    t.loadFromFile("Speaker.png");

    sf::Sprite speaker(t);
    speaker.setRotation(90);
    speaker.setOrigin(  t.getSize().x / 2.0f,   t.getSize().x / 2.0f    );
    speaker.setPosition(300, 300);

    sf::Text text("Song: Reunited by Incomptech.com", sf::Font::getDefaultFont(),14);
    text.setPosition(5,5);
    text.setColor(sf::Color::Black);

    sf::Listener::setDirection(0, -1, 0);
    sf::Listener::setPosition(0, 0, 0);

    sf::Music music;
    music.openFromFile("Reunited.ogg");
    music.setLoop(true);
    music.setPosition(300,300,0);
    music.setMinDistance(5.f);
    music.setAttenuation(10.f);
    music.play();

    while (App.isOpen())
    {
        sf::Event event;
        while (App.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                App.close();
        }

        sf::Vector2f pos;   //relative to center of the screen
        pos.x = sf::Mouse::getPosition(App).x - 300;
        pos.y = sf::Mouse::getPosition(App).y - 300;
        sf::Listener::setPosition(pos.x, pos.y, 0);

        App.clear(sf::Color::White);
        App.draw(text);
        App.draw(speaker);
        App.display();
    }

    return 0;
}
 

But when I move the mouse the volume stays at 1, it wont change at all

7
Graphics / SFML2 Texture/Image loadFroPixels
« on: May 03, 2012, 06:49:31 pm »
Im trying to convert the libRocket SFML renderer from 1.6 to 2.0 and I have done more or less everyhthing apart from the texture creation, the included SFML renderer uses the old loadFromPixels but I just wanted to know how you would do this in 2.0

8
Window / Changing to cartesian coordinates
« on: March 09, 2012, 01:43:15 am »
Hi, im trying to use Box2D with SFML however box2D uses cartesian coordinates but SFML uses inverted Y.
Is there any way to change the SFML coordinate system easily? say with the view class or something?

9
DotNet / get window position?
« on: March 02, 2012, 09:50:31 pm »
How do you get the window position?
I want to get the mouse position relative to the window but I need the window position to do this.

10
DotNet / SFML.Net GUI?
« on: March 01, 2012, 02:58:44 am »
Just wondering if there are any SFML.net GUI's that work with the current graphcs API?

11
Graphics / VertexArray's images picking up extra pixel
« on: February 28, 2012, 10:14:00 pm »
I moved my map from lots of sprites to just 1 vertex array and I was messing around with the window view making it follow the mouse(as in the future I will make it follow he player) and I get transparent lines at some positions.
this is the code:
Code: [Select]
SFML.Graphics.View view = new SFML.Graphics.View(new SFML.Window.Vector2f(wid/2.0f,80)
, new SFML.Window.Vector2f(wid,160));

window.SetView(view);


And this is what happens:



It seems to be picking up a line of pixels from the tile bellow it on the tilesheet

12
Feature requests / Batch Drawing
« on: February 27, 2012, 01:50:17 pm »
As a way of making the drawing much faster would it be possible to use batch drawing to draw everything at once?
Not sure if this is already planned for the new graphics API but it would make things much faster.

13
C / Error building latest snapshot
« on: February 25, 2012, 05:05:12 am »
Im having to build CSFML to get the new SFML.Net working on linux but I gt this error when compiling the debug version:

Code: [Select]
[ 62%] Building CXX object src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp: In function ‘sfBool sfRenderTexture_IsSmooth(const sfRenderTexture*)’:
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp:242:5: error: no match for ‘operator==’ in ‘renderTexture->sfRenderTexture::This == 0’
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp:242:5: note: candidates are:
/usr/local/include/SFML/System/Vector3.inl:157:13: note: template<class T> bool sf::operator==(const sf::Vector3<T>&, const sf::Vector3<T>&)
/usr/local/include/SFML/System/String.hpp:416:22: note: bool sf::operator==(const sf::String&, const sf::String&)
/usr/local/include/SFML/System/String.hpp:416:22: note:   no known conversion for argument 1 from ‘const sf::RenderTexture’ to ‘const sf::String&’
/usr/local/include/SFML/Graphics/Rect.inl:125:13: note: template<class T> bool sf::operator==(const sf::Rect<T>&, const sf::Rect<T>&)
/usr/local/include/SFML/System/Vector2.inl:150:13: note: template<class T> bool sf::operator==(const sf::Vector2<T>&, const sf::Vector2<T>&)
/usr/local/include/SFML/Graphics/Color.hpp:98:24: note: bool sf::operator==(const sf::Color&, const sf::Color&)
/usr/local/include/SFML/Graphics/Color.hpp:98:24: note:   no known conversion for argument 1 from ‘const sf::RenderTexture’ to ‘const sf::Color&’
make[2]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o] Error 1
make[1]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/all] Error 2
make: *** [all] Error 2

14
General / Bloom effect without rendertargets
« on: December 24, 2011, 01:50:49 am »
Hi, is there anyway to achieve a bloom effect without the use of renderTargets?
I am currently using an intel graphics card and having a rendertarget makes the progrm crash

15
Graphics / Texture fails in custom openGL
« on: December 12, 2011, 02:59:55 am »
Im trying to use sf::Textures with custom openGL but I get these errors:

An internal OpenGL call failed in Texture.cpp (418) : GL_INVALID_VALUE, a numeric argument is out of range

When loading the image, and:

An internal OpenGL call failed in Texture.cpp (352) : GL_INVALID_OPERATION, the specified operation is not allowed in the current state

When calling sf::Texture.Bind()

Pages: [1] 2 3