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

Pages: [1] 2 3 ... 5
1
Graphics / Re: Is this the right way to use sf::VertexBuffer ?
« on: May 25, 2018, 12:28:19 pm »
yes, it does work...and yay, a reply...
ok thank you

2
Graphics / Re: Is this the right way to use sf::VertexBuffer ?
« on: May 22, 2018, 05:15:27 am »
hi

3
SFML projects / Drawable group class
« on: May 17, 2018, 03:26:36 pm »
I made a class that can store classes that is derived from drawables...I made two :
this one just makes it easier to draw multiple objects, it has a function that can make it so it won't draw one of them, or you can just make the group invisible, it is named ObserveGroup

https://github.com/Flaze07/useful-stuff/tree/master/for%20sfml/ObserveGroup

the second one has complete ownership over the objects, just like the ObserveGroup, this one can make one of the objects invisible, or itself invisible :

https://github.com/Flaze07/useful-stuff/tree/master/for%20sfml/OwnGroup

4
Audio / Re: undefined reference to _imp___ZN2sf11SoundStreamC2Ev
« on: May 16, 2018, 07:00:04 pm »
I think building it yourself will fix this problem...since it did for me

5
General / Re: What's wrong with this code?
« on: May 14, 2018, 09:30:11 am »
wait, isn't it better to cast the windowSize rather than creating an object ? I mean
camera.setSize( Vector2f{ window.getSize() } );
 
isn't this better ?
camera.setSize( static_cast< Vector2f >( window.getSize() );
 

although I don't know very well.... I hope someone would clear me on this

6
General / Re: Can't delete objects without memory dumping
« on: May 12, 2018, 01:25:56 pm »
Hmm.. I wonder why obstacle.fall( 10 ) would give out an error "obstacle.fall( 10 ) is not of type Obstacle"...never got one of those...why not post Obstacle class too :D


also to answer your question
Foo *foo = new Foo( "Foo", 4, 4);
 

you still need to call ( I am pretty sure  )
delete foo;
 
if you use unique_ptr ( which is the correct way since C++11. Unless you really need raw pointer )
std::unique_ptr< Foo > foo = std::make_unique( new Foo{ "Foo", 4, 4 } );
 
there is no need to call delete

I learnt C++ here : http://www.cplusplus.com/doc/tutorial/ although the site has bad reputation, it works for me

best way to learn C++ is through books :D

7
Graphics / Is this the right way to use sf::VertexBuffer ?
« on: May 12, 2018, 05:19:35 am »
Static :
#include <array>
#include <SFML/Graphics.hpp>

int main()
{

    const float start = 100;
    const float width = 200;

    sf::RenderWindow win{ sf::VideoMode{ 600, 600 }, "using VertexBuffer" };
    win.setFramerateLimit( 60 );

    sf::VertexBuffer v_buffer{ sf::Quads, sf::VertexBuffer::Static };
    v_buffer.create( 4 );

    std::array< sf::Vertex, 4 > v_arr;
    v_arr.at( 0 ).position = sf::Vector2f{ start, start + width };
    v_arr.at( 1 ).position = sf::Vector2f{ start, start };
    v_arr.at( 2 ).position = sf::Vector2f{ start + width, start };
    v_arr.at( 3 ).position = sf::Vector2f{ start + width, start + width };

    v_arr.at( 0 ).color = sf::Color::Blue;
    v_arr.at( 1 ).color = sf::Color::Red;
    v_arr.at( 2 ).color = sf::Color::Green;
    v_arr.at( 3 ).color = sf::Color::White;

    v_buffer.update( v_arr.data() );

    while( win.isOpen() )
    {
        sf::Event event;
        while( win.pollEvent( event ) )
        {
            if ( event.type == sf::Event::Closed ) win.close();
            if ( ( event.type == sf::Event::KeyPressed ) && ( event.key.code == sf::Keyboard::Escape ) ) win.close();
        }

        win.clear();
        win.draw( v_buffer );
        win.display();
    }
}
 

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

int main()
{

    const float start = 0;
    const float width = 200;

    sf::RenderWindow win{ sf::VideoMode{ 600, 600 }, "using VertexBuffer" };
    win.setFramerateLimit( 60 );

    sf::VertexBuffer v_buffer{ sf::Quads, sf::VertexBuffer::Stream };
    v_buffer.create( 4 );

    std::array< sf::Vertex, 4 > v_arr;
    v_arr.at( 0 ).position = sf::Vector2f{ start, start + width };
    v_arr.at( 1 ).position = sf::Vector2f{ start, start };
    v_arr.at( 2 ).position = sf::Vector2f{ start + width, start };
    v_arr.at( 3 ).position = sf::Vector2f{ start + width, start + width };

    v_arr.at( 0 ).color = sf::Color::Blue;
    v_arr.at( 1 ).color = sf::Color::Red;
    v_arr.at( 2 ).color = sf::Color::Green;
    v_arr.at( 3 ).color = sf::Color::White;

    v_buffer.update( v_arr.data() );

    sf::Vector2f init_position;
    init_position.x = ( v_arr.at( 2 ).position.x + v_arr.at( 1 ).position.x ) / 2;
    init_position.y = ( v_arr.at( 0 ).position.y + v_arr.at( 1 ).position.y ) / 2;

    sf::Vector2f position{ init_position };

    while( win.isOpen() )
    {
        sf::Event event;
        while( win.pollEvent( event ) )
        {
            if ( event.type == sf::Event::Closed ) win.close();
            if ( ( event.type == sf::Event::KeyPressed ) && ( event.key.code == sf::Keyboard::Escape ) ) win.close();
        }

        if ( position.x == static_cast<float>( win.getSize().x  ) )
        {
            position = init_position;

            v_arr.at( 0 ).position.x = init_position.x - ( width / 2 );
            v_arr.at( 1 ).position.x = init_position.x - ( width / 2 );
            v_arr.at( 2 ).position.x = init_position.x + ( width / 2 );
            v_arr.at( 3 ).position.x = init_position.x + ( width / 2 );
        }

        v_arr.at( 0 ).position.x += 1;
        v_arr.at( 1 ).position.x += 1;
        v_arr.at( 2 ).position.x += 1;
        v_arr.at( 3 ).position.x += 1;

        position.x += 1;

        v_buffer.update( v_arr.data() );

        win.clear();
        win.draw( v_buffer );
        win.display();
    }
}
 

8
Audio / Re: Sometimes Audio not loading
« on: May 12, 2018, 04:52:21 am »
sometimes as in, there are times when it successfully worked, and there are times when it won't load ( I used two sf::SoundBuffer ), both of them fails to load.
I run it like this
i.e. my .exe is in C:\Program Files\game\game.exe
so my sound is in C:\Program Files\game\media\sound.wav

9
Audio / Sometimes Audio not loading
« on: May 11, 2018, 04:51:09 pm »
This has been bugging me for a while...sometimes, when I load my application, the sound won't load and by won't load I mean
sf::Sound::loadFromFile() return false;
why does this happen ?, also if code is needed, please tell me

10
Graphics / Re: transforming on each vertex array
« on: May 10, 2018, 02:12:12 pm »
after thinking for several hours, I finally got what you mean, thank you

11
Graphics / transforming on each vertex array
« on: May 01, 2018, 11:45:49 am »
for example :
std::vector< sf::RectangleShape > rect;
//stuffs

int i = 0;
for ( auto& a : rect )
{
        ++i;
        rect.setRotation( 90 + i );
}
 

each of the rect will have different rotations.
I know how to apply transform to vertex array, but if I want the vertex array to have different roations, how do I do that ?

sf::VertexArray vert{ sf::Quads, 8 };
//stufs
sf::Transform t;
t.setRotation( 90 );
win.draw( vert, t ) // unable to set rotation for each 4 vertices
 

12
General / Re: building sfml problems
« on: April 30, 2018, 07:31:59 pm »
I disabled the DOC and Example option and now, I have built SFML...

13
General / Re: building sfml problems
« on: April 30, 2018, 01:46:02 pm »
I encountered another problem :

14
General / building sfml problems
« on: April 29, 2018, 05:33:28 pm »
There is an attachment. Why does CMake says Android ? Shouldn't it say Windows ( Well, I mean, not really, but it shouldn't be saying it needs Android_SDK )

15
General / How do you make .DLLs with CMake ??
« on: April 07, 2018, 11:31:04 am »
Look, I know that CMake is not a compiler (because it says so in the tutorial to "compile" sfml) but, if I cannot make a .dlls how do I use the library that I built with CMake ?
(Also, this is a problem regarding thor, because I need to build it with CMake, with SFML, there is no problem with just using the pre-compiled ones)

Ok, just realized that I can actually use the .cbp to compile it with CodeBlocks, and it kinda works because it suddenly terminates after 1 minute and 18 seconds

NVM, it worked, it created one .dll and another of .dll.a ????

Edit : Nevermind it worked, and I can successfully integrate THOR into my Project, but why is it thorlib.dll.a instead of just .a

Pages: [1] 2 3 ... 5