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

Pages: [1]
1
Graphics / Re: problem with sf::VertexArray
« on: December 23, 2014, 09:41:53 pm »
If by "my window is not open" you mean it doesn't appear though your application is running - have you put the necessary dlls in the working directory of your program?

i mean window very soon closed after opening,

2
Graphics / Re: problem with sf::VertexArray
« on: December 23, 2014, 01:34:47 pm »
i do that, compiled but my window is not open,


3
Graphics / Re: problem with sf::VertexArray
« on: December 23, 2014, 01:01:38 pm »
outside of         while (window.pollEvent(event) ) ?

4
Graphics / problem with sf::VertexArray
« on: December 23, 2014, 12:26:18 pm »
hey, im beginner in sfml and here i want  draw one vertex between two points but when i call window.draw(lines); I get an error: Use undeclared identifier "lines"
what should i do?
thanks

   sf::RenderWindow window(sf::VideoMode(600, 400), "Convex Hull");

   
   
    std::vector<sf::RectangleShape> rects;
   
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event) )
        {
       
       
       
       
            if (event.type == sf::Event::Closed)
                window.close();
            else if (event.type == sf::Event::MouseButtonPressed &&
                     event.mouseButton.button == sf::Mouse::Left&&
                     rects.size() < 10) {
               
                posx.push_back(event.mouseButton.x);
                posy.push_back(event.mouseButton.y);
               
//                cout << posx[f] << "   " << posy[f] << endl;
                f++;
               
//                cout << f << endl;
                sf::RectangleShape rect { { 2, 2 } };
                rect.setPosition(sf::Vector2f(sf::Mouse::getPosition(window)));
                rect.setFillColor(sf::Color::Green);
                rects.push_back(rect);
               
                cout << &rects << endl;
               
                sf::VertexArray lines(sf::LinesStrip, 2);
                lines[0].position = sf::Vector2f(posx[0], posy[0]);
                lines[1].position = sf::Vector2f(posx[10], posy[10]);
               
               

               
            }
           
            if (f == 10)
                break;
        }
   
       
        window.clear();
        for (const auto &r : rects)
            window.draw(r);
       
             window.draw(lines); // Error is here
       
        window.display();
    }
       

5
Graphics / Re: draw rectangles with clicking mouse
« on: December 19, 2014, 12:45:52 pm »
Quote
Hi there,

is this what you want?

yes of course, thanks a lot,,,
and one little question, how can i limit number of click on screen, for example: just 10 time click
In other words i want just 10 rectangle,

thanks again.

6
Graphics / draw rectangles with clicking mouse
« on: December 19, 2014, 11:53:51 am »
hey,
i want use muose click and get some positions in window, and set positions for draw some rectangles, but i have two problem,

1- i dont know where set number of point should press by user;(for example just 10 positions)
2- my rectangle not saved on screen, when user click on new position The previous rectangle Removed،

 while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
           
           
           
            switch (event.type) {
                case sf::Event::Closed:
                    window.close();
                    break;
                case sf::Event::MouseButtonPressed: ;
                   
                    cout << "Mouse button has been pressed " << endl;
                   
                    cout << event.mouseButton.x << "   " << event.mouseButton.y << endl;
                   
                    posx=event.mouseButton.x;
                    posy=event.mouseButton.y;
               
                   
                   
                    break;
       
                   
                    }
           
           
           
            sf::RectangleShape Rectangle;
 
                Rectangle.setSize(sf::Vector2f(3, 3));
                Rectangle.setOutlineColor(sf::Color::Green);
                Rectangle.setFillColor(sf::Color::Green);
                Rectangle.setPosition(posx,posy);

           
            window.clear();
           
         
                window.draw( Rectangle);

            window.display();
           
        }

7
Graphics / Re: draw rectangle---- 2 or more with different position
« on: May 19, 2014, 04:26:27 pm »
hello I'm back again with bin packing problem,,,
this is my sample code i can't draw 2 or more rectangle with one loop in first step  :-\
please help me...

//
//  main.cpp
//  sfml-tutorial
//
//  Created by Mohammad Alikhani on 5/6/14.
//  Copyright (c) 2014 Mohammad Alikhani. All rights reserved.
//

#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;

int main()
{
    int x_main,y_main,rectangle_number;
    int total_big_area;
    cout << "please Enter the size of main rectangle between 0-1000" << endl;
    cin >> x_main >> y_main;
    while (x_main>1000 && y_main>1000) {
        cout << "wronge number your x or y over than 1000 >>> please Enter again: " << endl;
        cin >> x_main >> y_main ;
    }
    total_big_area=x_main*y_main;
   
    VideoMode videoMode(x_main,y_main);
    RenderWindow window(videoMode,"Rectangle Bin-packing");
   
    for (int i=0; i<10; i++) {
        RectangleShape rectangle;
        rectangle.setPosition(30,10);
        rectangle.setSize(Vector2f(100, 30));
        rectangle.setFillColor(Color::Yellow);
        rectangle.setOutlineColor(Color::Red);
        rectangle.setOutlineThickness(2);
    }
   
    while (window.isOpen())
    {
        Event Event;
        while (window.pollEvent(Event)) {
           
            if (Event.type == Event::Closed) {
                window.close();
            }
        }
        window.clear();
        window.draw(rectangle);
        window.display();
       
       
    }
    return EXIT_SUCCESS;
}


8
Graphics / Re: draw rectangle---- 2 or more with different position
« on: May 10, 2014, 06:51:29 pm »
Thanks for answering
user interface of my program is command line,
yes of course ، i use render window، look...
VideoMode videoMode(x_main,y_main);
    RenderWindow window(videoMode,"Rectangle Bin-packing");
x_mian and y_main are Length and width of main rectangle, and set by user in command line...

how can i use this code in a loop, draw 2 or more time rectangles with different position in one compile?
RectangleShape rectangle;
    rectangle.setPosition(30,10);
    rectangle.setSize(Vector2f(100, 30));
    rectangle.setFillColor(Color::Yellow);
    rectangle.setOutlineColor(Color::Red);
    rectangle.setOutlineThickness(2);

excuse me im beginner

9
Graphics / Re: draw rectangle---- 2 or more with different position
« on: May 10, 2014, 04:53:58 pm »
thanks for your reply,,,
excuse me i have many mistake in my writing because english is not my main language,
i want create a program for rectangle bin packing and i want to use SFML to solve this problem,

in this program i have many rectangles with different size and different position and All these Be set by the user,
i use
RectangleShape rectangle;
in one (for) loop but not worked and don't show the rectangles, now my question is here What should I use for show rectangles?
thanks again

10
Graphics / draw rectangle---- 2 or more with different position
« on: May 10, 2014, 04:05:05 pm »
hi I'm beginner in SFML and i want to draw some rectangle with user choose,,,
but i can draw just one rectangle, what should i do for more draw with different position,
thanks

this is my code please help me...
 RectangleShape rectangle;
    rectangle.setPosition(30,0 );
    rectangle.setSize(Vector2f(100, 30));
    rectangle.setFillColor(Color::Yellow);
    rectangle.setOutlineColor(Color::Red);
    rectangle.setOutlineThickness(2);

Pages: [1]