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

Pages: [1]
1
Graphics / [SOLVED] Drawing an Arrow
« on: April 08, 2011, 06:28:17 pm »
Perfect, this works, thank you!

2
Graphics / [SOLVED] Drawing an Arrow
« on: April 08, 2011, 05:11:58 pm »
Hello!

I am having trouble drawing an Arrow, mainly with the triangle.

This code draws a line and a Triangle between any two points, but the Triangle does not have the correct orientation (it is always the same). I thought that by rotating the Triangle it would fix this, but the rotation is not in place but about the origin.

Code: [Select]
sf::Shape Line = sf::Shape::Line(x1,y1,x2,y2,1,sf::Color::White);
sf::Shape Triangle;
float angle = 2 * PI/3;
float angle_rect = PI/2;
float d = 50;

for (int i = 0; i < 3; i++) {
Triangle.AddPoint(x2+d*sin(angle*i), y2+d*cos(angle*i), sf::Color::White);
}
App.Draw(Line);
sf::Vector2f av =Triangle.GetPosition();
App.Draw(Triangle);

(NOTE: this code does not have the rotation in it)
Any advice?

3
Graphics / [SOLVED] sf::Shape pointers
« on: March 24, 2011, 10:10:57 pm »
Oh gotcha thanks :)

Well I'm using cpGUI and it accepts a pointer for the cpShapeButton. If I pass the address of a statically allocated object it goes out of scope, and since it won't accept an object, I think I do have to allocate it.

4
Graphics / [SOLVED] sf::Shape pointers
« on: March 24, 2011, 10:04:23 pm »
Great! That works! Thank you very much :)

5
Graphics / [SOLVED] sf::Shape pointers
« on: March 24, 2011, 09:28:25 pm »
Hi.

Code: [Select]
sf::Shape * genSquare =  new sf::Shape::Rectangle(0,0,100,100,sf::Color::Red);

This will not compile for me. I get an "expected type-specifier" error.

Any thoughts?

I need it to be a pointer else it will go out of scope for the other object I am using it for and thus cause a bad access.

EDIT: sf::Shape::Rectangle is not a constructor, it's a static function, so I
need to type it.

The correct code is this:
Code: [Select]
sf::Shape * genSquare =  new sf::Shape(sf::Shape::Rectangle(0,0,100,100,sf::Color::Red));

6
Window / SFML support for double click
« on: February 11, 2011, 05:56:24 am »
Great. I was planning on implementing with a sf::Clock, but open to advice.

7
Window / SFML support for double click
« on: February 11, 2011, 02:23:23 am »
Hey all,

Just wondering if SFML has built in double click functionality?

Thanks

8
Graphics / [SOLVED] SFML Rectangle draws wrong color after GL calls
« on: February 09, 2011, 11:06:41 pm »
After I do my GL calls, I display a rectangle on the screen depending upon user input. I am aware that by pressing T you will forever display the rectangle (correct functionality).

This is my code (for just the main loop):

Code: [Select]
sf::Shape Rect = sf::Shape::Rectangle(0,0,1920,1080,sf::Color::Black);
Rect.EnableFill(true);
Rect.SetPosition(0,0);

while (theVars->App.IsOpened())
    {
sf::Event event;
bool draw = false;
theVars->App.Clear();

while(theVars->App.GetEvent(event)){
if (event.Type == sf::Event::MouseButtonPressed) {
const sf::Input& Input = theVars->App.GetInput();
if (event.MouseButton.Button == sf::Mouse::Left) {
selectSquares(Input.IsKeyDown(sf::Key::LShift), event.MouseButton.X, event.MouseButton.Y);
}
}
if (event.Type == sf::Event::KeyPressed) {
keyDown(event.Key.Code);
}
if (theVars->App.GetInput().IsKeyDown(sf::Key::T)) {
draw = true;
}
}

// Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        theVars->App.SetActive();

display();
// Finally, display rendered frame on screen
if(draw)
theVars->App.Draw(Rect);


        theVars->App.Display();
}


Note:: display() is all my OpenGL stuff.

When the rectangle gets drawn the color of the box changes.

Any help?

EDIT: This is caused when you enable lighting in Open GL code. In order to use SFML drawings and display the correct color, you must first disable lighting. You can then reenable it after you draw.

Working Code:

Code: [Select]
glDisable(GL_LIGHTING);
theVars->App.Draw(Rect);
glEnable(GL_LIGHTING);

9
Window / [SOLVED] Having a Window variable in a class
« on: February 09, 2011, 12:54:09 am »
Thanks Mon, I think that is it.

However, I am fine with pointers! Thanks all, I really appreciate it.

10
Window / [SOLVED] Having a Window variable in a class
« on: February 07, 2011, 10:11:20 pm »
Hello,

Is it possible to declare a window variable in a class?

Right now I have

Code: [Select]
class dumbClass{
  sf::Window App;
};


And it gives me errors about NonCopyable. Clearly I am doing something wrong.

edit: I figured out the problem. Doesn't want me to instantiate without it's constructor, so I just made a pointer to the window. (sf::Window * app)

Pages: [1]