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

Pages: [1]
1
Graphics / Re: renderwindow.getPosition() return different value
« on: October 05, 2013, 01:14:57 pm »
window.getPosition().x returns the value '10'. At any case, I resolved the problem change from SFML 2.0 to SFML 2.1

2
Graphics / Re: renderwindow.getPosition() return different value
« on: October 04, 2013, 03:12:19 pm »
Aaaaa ok, sorry. at any rate, it doesn't work. I get other values with window.getPosition().x yet.

3
Graphics / Re: renderwindow.getPosition() return different value
« on: October 04, 2013, 09:41:03 am »
No, there is no delay to change the values. It return different values, but the window remains in the correct position I specify
My OS is Linux Fedora 19.

4
Graphics / renderwindow.getPosition() return different value
« on: October 03, 2013, 09:16:52 pm »
Hi!
If I get the position of window with window.getPosition() method, I received a different value that sometimes changes it;

    window.create(sf::VideoMode(windowSize.x, windowSize.y, colordepth), windowTitle, (fullscreen ? sf::Style::Fullscreen : sf::Style::Resize|sf::Style::Close));


    window.setPosition(sf::Vector2i(50,50));
    std::cout<<window.getPosition().x<<std::endl; // return sometimes 10, other 640


    handle = window.getSystemHandle();

    window.setFramerateLimit(framerate);

5
General / Re: Problem SFML with Box2d
« on: May 30, 2013, 05:43:00 pm »
Ok, I found the problem. Box2d have the origin in the center, but SFML have it in the top-left. To resolve this I set the origin in the middle:
box.setOrigin(width/2, height/2);

6
General / Re: Problem SFML with Box2d
« on: May 30, 2013, 02:49:51 pm »
I set 300, because 30 draw very fast. With 300 draw slow.
And the box dont colllide with the ground when his positon X is >100. I dont understand why happen this if the ground have 200 width and his position X is 0

7
General / Problem SFML with Box2d
« on: May 30, 2013, 01:21:12 pm »
Hi!
In this code I try generate a Box that must fall and collide with a ground. Simple.
But when the box falls, it don´t collide with the ground. I think that the positions and sizes match, so I don´t now why it fails.

Code:

#include "SFML/Graphics.hpp"
#include "Box2D/Box2D.h"
#include <stdio.h>
#include <iostream>

#define PPM 30 // Pixel Per Meters

using namespace sf;
using namespace std;

int main()
{
    bool running = true;

    RenderWindow app(VideoMode(800,600,32),"First Test");

    sf::RectangleShape box(sf::Vector2f(100,50));
    box.setPosition(sf::Vector2f(150.f,4.f));

    sf::RectangleShape ground(sf::Vector2f(200,50));
    ground.setPosition(sf::Vector2f(0,500));

    // set up the world
    b2Vec2 gravity(0.0f,9.8f);
    b2World *myWorld = new b2World(gravity);

    // creamos y configuramos el suelo
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0.0f, 500.0f);
    b2Body* groundBody = myWorld->CreateBody(&groundBodyDef);

    b2PolygonShape groundBox;
    groundBox.SetAsBox(100.0f, 25.0f);

    groundBody->CreateFixture(&groundBox, 0.0f);

    // creamos y configuramos un cuerpo dinamico
    b2BodyDef bodyDef;
    bodyDef.type = b2_dynamicBody;
    bodyDef.position.Set(150.f, 4.0f);

    b2Body* body = myWorld->CreateBody(&bodyDef);

    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(50.0f, 25.0f);

    b2FixtureDef fixtureDef;
    fixtureDef.shape = &dynamicBox;
    fixtureDef.density = 1.0f;
    fixtureDef.friction = 0.3f;

    body->CreateFixture(&fixtureDef);

    float timeStep = 1.0f / 300.0f; // 30fps

    int velIter = 8;
    int posIter = 3;

    //app.setFramerateLimit(30);

    while(running)
    {
        Event event;
        while(app.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
            running = false;
        }

        myWorld->Step(timeStep, velIter, posIter);

        b2Vec2 pos = body->GetPosition();

        box.setPosition(sf::Vector2f(pos.x,pos.y));

        app.clear();

        app.draw(box);

        app.draw(ground);

        app.display();
    }

    app.close();
    delete myWorld;

    return EXIT_SUCCESS;
}
 

8
Graphics / Re: [SOLVED]Two views to a window
« on: May 28, 2013, 03:55:17 pm »
Thanks!!

9
Graphics / [SOLVED]Two views to a window
« on: May 27, 2013, 06:05:45 pm »
Hi!
I am doing the SFML 2.0 tutorial "Controlling the 2D camera with views". This tutorial say that its posible create two views ( ie: gameview and minimapview) , but don´t say how can I set it to a window. In the example the author only set one view.

http://www.sfml-dev.org/tutorials/2.0/graphics-view.php

10
Window / Re: Second window not responding
« on: May 23, 2013, 11:14:20 am »
Yeah! Its works! Thank you! ;D

11
Window / Second window not responding
« on: May 22, 2013, 05:12:50 pm »
Hi!
When i create two windows, the second window not responding:
#include <iostream>
#include "SFML/Window.hpp"
#include "SFML/OpenGL.hpp"

using namespace std;

// http://www.sfml-dev.org/tutorials/2.0/window-opengl.php

void SetWindow(sf::Window &window, int x, int y, int w, int h)
{
    // cambia la posicion de la ventana
    window.setPosition(sf::Vector2i(x,y));

    window.setSize(sf::Vector2u(w,h));

    window.setTitle("SFML window");

    sf::WindowHandle handle = window.getSystemHandle();

    window.setFramerateLimit(30);
}

sf::ContextSettings SetGLWindow()
{
    sf::ContextSettings settings;
    settings.depthBits = 24;
    settings.stencilBits = 8;
    settings.antialiasingLevel = 4;
    settings.majorVersion = 3;
    settings.minorVersion = 0;
    return settings;

}

void renderingThread(sf::Window* window)
{
    // activa el contexto de ventana
    window->setActive(true);

    // el bucle de renderizado
    while(window->isOpen())
    {
        // draw...

        // Limpiamos los buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // termina el actual frame ( internamente intercambia el front y back buffer)
        window->display();
    }
}

int main()
{
    sf::Window window1(sf::VideoMode(800,600), "Window1",sf::Style::Default, SetGLWindow());

    sf::Window window2(sf::VideoMode(512,512), "Window2",sf::Style::Default, SetGLWindow());

    // Configuramos la ventana
    SetWindow(window1,10,50,800,600);
    SetWindow(window2,100,50,512,512);

    // desactivamos el OpenGL context
    window1.setActive(false);
    window2.setActive(false);


    // Iniciamos el RenderingThreading
    sf::Thread renderthreadWindow1(&renderingThread, &window1);
    renderthreadWindow1.launch();
    sf::Thread renderthreadWindow2(&renderingThread, &window2);
    renderthreadWindow2.launch();

    // corre el programa mientras la ventana este abierta
    while(window1.isOpen())
    {
        // Comprueba todos los eventos de ventana que fueron activados durante la ultima iteracion del bucle
        sf::Event event;
        while(window1.pollEvent(event))
        {
            // evento de "peticion de cerrado": cerramos la ventana
            if(event.type == sf::Event::Closed)
                window1.close();

            if(event.type == sf::Event::Resized)
                glViewport(0,0,event.size.width, event.size.height);
        }
    }

    while(window2.isOpen())
    {
        // Comprueba todos los eventos de ventana que fueron activados durante la ultima iteracion del bucle
        sf::Event event;
        while(window2.pollEvent(event))
        {
            // evento de "peticion de cerrado": cerramos la ventana
            if(event.type == sf::Event::Closed)
                window2.close();

            if(event.type == sf::Event::Resized)
                glViewport(0,0,event.size.width, event.size.height);
        }
    }

    return 0;
}

 

Pages: [1]