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

Pages: 1 2 [3] 4
31
General / Re: SFML widget in Qt
« on: March 17, 2014, 07:49:50 am »
Hi

I'm the creator of the post that you refer to.

It's my impression that you're using Windows instead of Mac OS. From the error message, I think that the create method (RenderWindow::create) requires a pointer to a windows handler (HWND *) and does not accept a explicit casting to (void *). Unfortunately, I haven't tried this on Windows, so for now it's the only hint I can provide.

Hope some other friends shed some more light on this issue.

FM

Thanks
Nice tutorial!

Waiting for more help

------------------------------
I found solution
Change line 33 of QSFMLCanvas.cpp to
RenderWindow::create(reinterpret_cast<sf::WindowHandle>(winId()));

32
General / [Solved]SFML widget in Qt
« on: March 16, 2014, 09:03:23 am »
I've follow the tutorial below.
http://becomingindiedev.blogspot.com/2013/10/qt-5-and-sfml-20-integration.html

but It gives many errors. In the picture below


I have no idea, How can I do? So, Please suggest me.

Thanks,

Sorry for bad English

but it give many error.

So, Please suggest how to adjust this code

33
Graphics / Re: View problem
« on: March 16, 2014, 04:23:57 am »
Problem #1: http://sfml-dev.org/tutorials/2.1/graphics-view.php#showing-more-when-the-window-is-resized
I've copy tutorial code to my code (see my upper post).

When I resize window and zoom , my circle will be stretch.
I can't mix "Showing more when the window is resized" with my zoom code.

Problem #2: You need to explain better about what you want exactly.  ;)
Sorry for bad explanation


when I started program
(0,0) coordinate will be on upper left of circle
(like the left side of picture)

when I zoom out
I want (0,0) coordinate to be on upper left of circle(red coordinate) not upper left of window(blue coordinate)
 
I've read Coordinates conversions in tutorial page
but I don't understand how to use it.

Thanks


34
Graphics / Re: View problem
« on: March 16, 2014, 04:01:05 am »
Please help :'(

35
Graphics / Re: AW: View problem
« on: March 14, 2014, 04:30:09 pm »
Don't draw them if the view zoom factor reaches a certain point. How? Well I don't know your code. ;)
OK, I will try it by myself first. If I can't do it. May I ask you again?  :D

and Others problem (many problem :P)
Please guide me

Problem 1
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")  
#endif // SFML_STATIC


#include <SFML/Graphics.hpp>

int posx, posy;
sf::View view1;

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::View view1(sf::FloatRect(0.f, 0.f, window.getSize().x, window.getSize().y));

        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();
                        if (event.type == sf::Event::MouseMoved)
                        {

                                posx = event.mouseMove.x - window.getSize().x / 4;
                                posy = event.mouseMove.y - window.getSize().y / 4;
                        }

                        if (event.type == sf::Event::MouseWheelMoved)
                        {

                                if (event.mouseWheel.delta >= 1)
                                {
                                        view1.zoom(0.9f);
                                        view1.setCenter(posx, posy);
                                        window.setView(view1);
                                }
                                if (event.mouseWheel.delta <= -1)
                                {
                                        view1.zoom(2.f);
                                        view1.setCenter(posx, posy);
                                        window.setView(view1);
                                }


                        }
                        if (event.type == sf::Event::Resized)
                        {
                                sf::View view1(sf::FloatRect(0, 0, event.size.width, event.size.height));
                                sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                                window.setView(sf::View(visibleArea));
                                window.setView(view1);
                        }
                }

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

        return 0;
}

From this code
When I resize window and zoom , my circle will be stretch.

--------------------------------------------------------------------------------------
Problem 2



In the picture(Right side)
when I zoom in or out,
I want (0,0) coordinate to be in the red text not in the blue text

I've try Coordinates conversions in tutorial but doesn't work.


-------------------------------------------------------------------------------------
Sorry for bad English

Thank you very much

 

36
Graphics / Re: View problem
« on: March 14, 2014, 04:45:07 am »
No, I mean Red line  :-[

How to hide it when I zoom out
and
display it when I zoom in

37
Graphics / Re: View problem
« on: March 13, 2014, 12:58:08 pm »
Please Help :'(

38
Graphics / Re: Zoom and View problem
« on: March 12, 2014, 03:44:12 pm »
I think the documentation is pretty clear on what the factor should be to zoom in or out.

And a MouseMoved event inside a MouseWheelMoved event? It will never happen. :o
Thanks

Solved about zoom problem
It's not zoom properly. Sometimes It move the setCenter.
But It not the main problem that I care.
I've change to this
            if (event.type == sf::Event::MouseMoved)
                        {
                                posx = event.mouseMove.x;
                                posy = event.mouseMove.y;
                        }

                        if (event.type == sf::Event::MouseWheelMoved)
                        {
                               
                                if (event.mouseWheel.delta == 1)
                                {
                                        view1.zoom(0.9f);
                                }
                                if (event.mouseWheel.delta == -1)
                                {
                                        view1.zoom(2.f);
                                }
                                view1.setCenter(posx, posy);
                               
                        }

39
Graphics / [Unsolved see lastest rep.] View problem
« on: March 12, 2014, 05:05:00 am »
The picture below is when I zoom in.


The picture below is when I zoom out


When I zoom out I don't program display pink lines
display pink link only when I zoom in

How can I do it?

Thanks

Sorry for bad English

40
Graphics / Re: Click and change fill color help!
« on: March 11, 2014, 02:32:38 pm »
I don't see different between if-loop and while-loop
Please tell me How different?

http://lmgtfy.com/?q=if+vs+while Really not that hard....

Quote
How can I create rectangle every frame? I have no idea

You don't want to create a rectangle shape every frame...

Oh, My bad
How stupid am I :'(
Thanks!

41
Graphics / Re: Click and change fill color help!
« on: March 11, 2014, 01:58:42 pm »
  • Please reread the tutorial about events, handling events must be done in the event loop

while (window.pollEvent(event))
{
    // check the type of the event...
    switch (event.type)
    {
        // window closed
        case sf::Event::Closed:
            window.close();
            break;

        // key pressed
        case sf::Event::KeyPressed:
            ...
            break;

        // we don't process other types of events
        default:
            break;
    }
}
I don't see different between if-loop and while-loop
Please tell me How different?

  • Lets see, if you create a new rectangle shape each frame how do you think it is going to stay red?

How can I create rectangle every frame? I have no idea
I've put this event between window.clear(); and  window.display();
but nothing change

Sorry for ask stupid question...

Thanks

42
Graphics / Re: Click and change fill color help!
« on: March 11, 2014, 01:46:29 pm »
      int main()
{

       
        cout << "enter width: ";
        cin >> x;
        cout << endl;
        cout << "enter height: ";
        cin >> y;

        sf::RenderWindow window(sf::VideoMode(x * 4, y * 4), "Window");


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

                window.clear();

                sf::IntRect r1(100, 100, 100, 100);

                sf::RectangleShape rectangle;
                rectangle.setSize(sf::Vector2f(100, 100));
                rectangle.setOutlineColor(sf::Color::Red);
                rectangle.setFillColor(sf::Color::Blue);
                rectangle.setOutlineThickness(1);
                rectangle.setPosition(100, 100);
                window.draw(rectangle);

       
                if (event.type == sf::Event::MouseButtonPressed)
                {
                        if (event.mouseButton.button == sf::Mouse::Left)
                        {
                                mx = event.mouseButton.x;
                                my = event.mouseButton.y;
                                bool b1 = r1.contains(mx, my);
                                if (b1 == true)
                                {


                                        rectangle.setFillColor(sf::Color::Red);
                                        window.draw(rectangle);
                                        cout << mx << my << endl;



                                }
                        }

                }
               
                window.display();

               
               
        }

        system("pause");
}
 

I've try to write my code
Result is my rectangle change to red only I pressed my mouse
How an I fix this?

43
Graphics / Re: Click and change fill color help!
« on: March 11, 2014, 07:56:03 am »
Not really...

You either use event handling (see the tutorial) or use real time input (see the tutorial), you should not mix both.

To check whether a point is in a rect, you can simply use the SFML rect.contains(point) function (see documentation). ;)

Thanks!

44
Graphics / Click and change fill color help!
« on: March 10, 2014, 10:10:56 am »
int x;
int y;

int main()
{
        while
                {
                        if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                                {
                                        x = sf::Event::MouseButtonEvent::x;
                                        y = sf::Event::MouseButtonEvent::y;
                                }
                         //check that What rectangle which (x,y) is inside

                        (Rectangle that I clicked name).setFillColor(sf::Color::Green);
                }

}

This is my approximately code.
Is that Correct?
and Please tell me How can I check that What rectangle which (x,y) is inside

Thanks
Sorry for bad English
   



45
General / Re: My vertex line is blinking
« on: March 10, 2014, 07:18:34 am »
I suspect it's because you are calling window.draw(outlinex, 2, sf::Lines); before window.clear(). Move your for loop to in between window.clear() and window.display() and see if that fixes your issue.
Thanks! Problem solved

Couple of things to note here:
  • As The Terminator mentioned: sf::RenderWindow::clear should always be called before sf::RenderWindow::draw.
  • Your array outlines is created inside the for-loop. When the for loop ends, the scope where your vertex was created ends and the object gets destroyed.
  • You draw your vertices only once, not every frame. Read the big red box on this tutorial. It mentions how you should do it and also refers to double-buffering which is why the lines are blinking.

Please do read the tutorials as they are very useful and clear.

I'm clearly understand.
Thanks!

Pages: 1 2 [3] 4