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

Pages: [1]
1
General / Does setframelimit have a memory leak in 2.1?
« on: November 01, 2014, 10:57:56 am »
Using C++ and after commenting out the line my program stopped increasing in memory by 4kb every second?  With it uncommented it would consistently increase in memory every 4kb which is pretty nuts to me.  This happened using C# too, but I thought it was just my shitty coding that was the issue.  Thought I'd check memory usage with SFML before I got into my game and bam noticed that and I'm not sure if that's normal?

Nothing special in my code:

void Game::run()
{
        //initialize window
        window.create(VideoMode(width, height), name);

        //set framerate
        //window.setFramerateLimit(60);

        //load assets
        loadAssets();

        //game loop
        loop();
}

2
DotNet / Question regarding image loading.
« on: July 07, 2014, 06:26:43 pm »
Yesterday I was messing around and tried downloading an image from the internet: http://wfiles.brothersoft.com/c/cat-photograph_195926-1280x720.jpg this image to be exact.  The program crashed repeatedly saying it couldn't load the image, so I thought it was to do w/ my bindings (went sort of nuts w/ recompiling etc... lol) and then I opened the image in paint and resaved it to something else and it loaded properly?

Why exactly was the script crashing?  It was a basic:
Image bg = new Image("bg.jpg");

W/ bare minimum window creation:

RenderWindow window = new RenderWindow(new VideoMode(windowSize.X, windowSize.Y), "Window", Styles.Titlebar | Styles.Close);

window.Closed += (object s, EventArgs e) => {
        RenderWindow w = (RenderWindow) s;
        w.Close();
};

Image bg = new Image("bg.jpg");

while(window.IsOpen) {
        window.DispatchEvents();
        window.Clear(Color.Magenta);
        window.Draw(bg);
        window.Display();
}

Which was weird to me.  Note was using the latest source bindings, compiled w/ VS2012 + the CSFML files from here http://nightlybuilds.ch/project/show/4/CSFML/

3
When I click on the area using a standard render window (black part) the window doesn't focus until I click the title bar or the edge of the window.

I read they fixed this a long time ago, so either the dotnet bindings aren't updated or it was never fixed :/?

4
1. Want to emulate this effect
2. By creating a render window, filling it with black.  Drawing to it and then setting the transparency of the color I drew on the render window (will be updated based sprite position, not really important atm)
3. Display the render window to the screen after everything else is loaded to create said effect.


5
DotNet / Capturing keypresses every frame
« on: September 04, 2013, 09:09:12 pm »
I had issues using the win.keypressed window event handler so I found a post that said if I wanted to capture keypresses every frame I would need to use Keyboard.IsKeypressed() which works wonderfully, except Laurent said in a post I randomly stumbled upon that you shouldn't use this because it executes even if the window isn't focused.

Is there a work around to this?  Because I couldn't previously get the window key events to work how I wanted as it didn't want to capture when the key was being held down, I was forced to press down everytime to do what I wanted.  Which didn't make sense.

Hope I explained everything correctly.  Basically I'm looking for a way to disable the keyboard.iskeypressed when the window isn't focused or if there is a better way to use window keyboard events that captures when you hold down on the key properly because win.SetKeyRepeatEnabled(true); doesn't help the situation.

6
Wonder if there's a way to get the current float rect data for later calculations (for move checks)

            //load current camera view
            View view = new View(new FloatRect(0, 200, width, height));

Or should I create a class that manages this data?

7
General / Just found this view tutorial on github Laurent
« on: August 09, 2013, 07:22:13 pm »
Dude it's so much better than the one on the main site https://github.com/SFML/SFML/wiki/Tutorial%3A-Using-View you totally should update it for the website :P

I say this because the code examples here are a bit more detailed and it took me a while to find this for some reason.

8
So I'm playing with SFML 2.1 and trying to get a sf::RenderTexture setup and then pass it to a sprite and output it to the window.

So I ran a test and did the following:

call above int main()
sf::Sprite testing() {
        //scene main texture
        sf::RenderTexture scene_texture;
        scene_texture.create( 800,600 );

        //top menu section
        sf::Texture menubg_texture;
        menubg_texture.create( 800, 107 );
        if( !menubg_texture.loadFromFile( "Assets/Scenes/Default/background_section.png", sf::IntRect( 0, 0, 800, 107 ) ) ) {
                cout << "Couldn't load file" << endl;
        }

        sf::Sprite menubg_sprite( menubg_texture );

        menubg_sprite.setTextureRect( sf::IntRect( 0, 0, 800, 107 ) );
        menubg_sprite.setPosition( 0.f, 0.f );

        //draw menu to scene
        scene_texture.clear( sf::Color( 0, 255, 0 ) );
        scene_texture.draw( menubg_sprite );
        scene_texture.display();

        //sf::Sprite scene_sprite( scene_texture.getTexture() );
       
        sf::Sprite sprite;
        sprite.setTexture( scene_texture.getTexture() );
        return sprite;
}

The main.cpp main() function

int main() {
        sf::RenderWindow app_window( sf::VideoMode( 800, 600 ), "Temporary Window", sf::Style::Titlebar | sf::Style::Close );
        sf::RectangleShape background( sf::Vector2f(800.f, 600.f) );
        background.setPosition( 0.f, 0.f );
        background.setFillColor( sf::Color(255, 0, 0) );

        // Start the game loop
        while ( app_window.isOpen() ) {


                // Process events
                sf::Event event;

                while ( app_window.pollEvent( event ) ) {

                        // Close window : exit
                        if ( event.type == sf::Event::Closed ) {
                                app_window.close();
                        }

                        // Mouse Events
                        if( event.type == sf::Event::MouseMoved ) {
                        }

                        if( event.type == sf::Event::MouseButtonPressed ) {
                                if( sf::Mouse::isButtonPressed( sf::Mouse::Left ) ) {
                                }
                        }
                }


                // Clear screen
                app_window.clear( sf::Color( 0, 255, 0) );

                //draw stuff
                app_window.draw( background );
                app_window.draw( testing() );

                // Update the window
                app_window.display();
        }

        return EXIT_SUCCESS;
}

So I'm like okay what's going on here.  I literally copy the code from the function and replace the:

app_window.draw( testing() ); with the code from above then do: app_window.draw(sprite);

And the image texture loads perfectly.  What am I doing wrong or is this a bug with SFML 2.1?  About to test SFML 2.0 right now.

9
Wouldn't the "display" function be described better as "update" since that's exactly what it does according to the description?

Quote
void    display ()
    Update the contents of the target texture.
http://sfml-dev.org/documentation/2.0/classsf_1_1RenderTexture.php

10
Before I had #define SFML_STATIC in the main.cpp file before compiling (and figuring out that you had to add each cpp file to the command else things wouldn't link properly, which is irrelevant) and I would get an error where RenderWindow wouldn't work.  Yet, I defined the SFML_STATIC definition before including my header file right.  So when I remove it from the main cpp file to the header file everything magically works again?  Why is this?

Is it because the SFML/Graphic.hpp etc.. files need to know about this constant before proceeding directly in the file itself before the header include?

(ps: disregard the include file names and what not they are irrelevant to teh question)

main.cpp
/**
 * Game Instance
 * @Author:     Lamonte & Jordan
 * @Copyright: 2013-
 */


#include "t_game.h"

int main() {
        G_Instance game;
        return 0;
}
 
g_instance.h
#ifndef GAME_CORE_H
#define GAME_CORE_H
#define SFML_STATIC
#include <SFML/Graphics.hpp>

class G_Instance {
        sf::RenderWindow window;
public:
        G_Instance();
};
#endif

g_instance.cpp
#include "t_game.h"

G_Instance::G_Instance() {
       
        window.create(sf::VideoMode(200,200), "Works");
}

11
So I'm trying to compile on windows using g++ and I get a few errors, not sure what I'm doing wrong.

Quote
C:\Users\Lamonte\Documents\Project\C++>g++ main.cpp -Ic:\SFML-2.0\include
In file included from c:\SFML-2.0\include\SFML/System.hpp:34,
                 from c:\SFML-2.0\include\SFML/Window.hpp:32,
                 from c:\SFML-2.0\include\SFML/Graphics.hpp:32,
                 from main.cpp:1:
c:\SFML-2.0\include\SFML/System/Err.hpp:32: ostream: No such file or directory
In file included from c:\SFML-2.0\include\SFML/System.hpp:39,
                 from c:\SFML-2.0\include\SFML/Window.hpp:32,
                 from c:\SFML-2.0\include\SFML/Graphics.hpp:32,
                 from main.cpp:1:
c:\SFML-2.0\include\SFML/System/String.hpp:32: locale: No such file or directory

In file included from c:\SFML-2.0\include\SFML/System.hpp:43,
                 from c:\SFML-2.0\include\SFML/Window.hpp:32,
                 from c:\SFML-2.0\include\SFML/Graphics.hpp:32,
                 from main.cpp:1:
c:\SFML-2.0\include\SFML/System/Utf.hpp:33: locale: No such file or directory

Source: main.cpp
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Pages: [1]