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

Pages: [1]
1
Graphics / Re: Anti Aliasing, Textures, Fonts and GUIs
« on: August 03, 2012, 09:54:46 am »
Okay, looks like I found the source of the problem. Here is a screenshot of the anti-aliasing settings in the Radeon control panel:



The "Filter" setting at the bottom has two settings, "Standard" and "Edge-detect". When it's set to "Edge-detect", the "Samples" to the right displays a multiple of the anti-aliasing level. E.g.: 4x to 12x and 8x to 24x. When it's set to "Standard", however, the "Samples" to the right displays the same number as the anti-aliasing level.

More importantly, when the "Filter" is set to "Standard", the artifacts in SFML and TGUI disappear.

Do you know much about this filter? Is there anything that can be done in SFML to prevent this problem from happening when users enable the "Edge-detect" feature?

[attachment deleted by admin]

2
Graphics / Re: Anti Aliasing, Textures, Fonts and GUIs
« on: August 03, 2012, 09:37:58 am »
Without anti-aliasing:
tgui::Window app
    ( sf::VideoMode
        ( std::min(sf::VideoMode::getDesktopMode().width,(unsigned)600)
        , std::min(sf::VideoMode::getDesktopMode().height,(unsigned)600)
        , 32)
    , "Graph Search"
    , sf::Style::Close
    , sf::ContextSettings(0, 0, 0));

With anti-aliasing:
tgui::Window app
    ( sf::VideoMode
        ( std::min(sf::VideoMode::getDesktopMode().width,(unsigned)600)
        , std::min(sf::VideoMode::getDesktopMode().height,(unsigned)600)
        , 32)
    , "Graph Search"
    , sf::Style::Close
    , sf::ContextSettings(0, 0, 8));

To test SFGUI, I simply downloaded the binaries and launched the example programs. Then I forced anti-aliasing on and off in my Radeon Catalyst Control Panel. I'm running Windows 7 64-bit, by the way.

When I was testing just a regular sf::Text without TGUI, I used a normal sf::RenderWindow instead of a tgui::Window.

3
Graphics / Anti Aliasing, Textures, Fonts and GUIs
« on: August 03, 2012, 09:12:03 am »
I'm using the latest SFML and TGUI builds as of 8/2/2012.

I've spent the last couple hours experimenting and reading every search result for anti aliasing on the forums. And so here are my questions and concerns.

First, please look at the attached image:



Looking at the lines and tiny boxes (all drawn with rectangles), it should be obvious that I've turned anti aliasing off in the top image and on in the bottom image. I very much want anti aliasing for my geometry. However, if you look at the TGUI controls at the top left (the label, button and edit box), you'll see that they look fine with anti aliasing disabled (top) but quite ugly with it enabled (bottom). It happens to the label as well, it's just harder to see.

To make sure this wasn't a TGUI specific problem I tested this with SFGUI and got the same ugly artifacts. I also tested this with just a regular sf::Text object (before I ever got TGUI) and the same thing happened.

Here are some of the artifacts I'm seeing in the bottom image:
  • Along the top and bottom edges of the button and edit box, there are little light colored artifacts.
  • In the GUI text, especially the 'u' and 't's in "Button" and the 'E', 't', and 'B' in "Edit Box", the artifacts are kind of sticking out of the letters ever so slightly.
  • In the regular sf:Text object, the 'T' in the top is nice and pixel perfect solid, but in the bottom there is a spot in the middle of the 'T' where it's a bit fuzzy. This can be seen in other letters too.

I want the GUI objects to look how they do in the top, but I want my geometry smoothed like they are in the bottom. So what am I to do here?

[attachment deleted by admin]

4
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 03, 2012, 12:14:07 am »
The formbuilder.exe I downloaded works fine. I wonder what could have caused such a strange bug with my build.

5
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 07:52:58 am »
Hi Texus, I'm having problems with the Form Builder. Strangely, it will only show objects that are in the bottom left of the window (see attachment).

As you can see, there is an obvious rectangle of space at the bottom left where objects show up, but anything outside that space does not. You can clearly see objects being cutoff at the edge of the space. If I create a new object, the properties window will update with the new object's information, but I won't be able to see it at the top left. But I can click on it and drag it to the bottom left where it will show up.

Notice also the Fraps fps numbers in the four corners of the window. The frame rate is around 19-20 fps. You can see it at 19 in the bottom left. However in the other three corners, you see the numbers "19" and "20" pasted on top of each other, never clearing. And in case you didn't know, Fraps only puts the fps in one corner at a time.

Clearly something is wrong here. I've tested TGUI in my own programs and have found no such problems.

SFML2 and TGUI were both built from freshly downloaded src today (8/1/2012).

I've attached the FormBuilder.exe file (see attached rar) so you can test it yourself. Could you possibly send me a working copy of the exe?

[attachment deleted by admin]

6
SFML projects / Re: TGUI: a c++ GUI for SFML (with Form Builder)
« on: August 02, 2012, 06:43:50 am »
Hi Texus, I just wanted to alert you to what I think is a bug in your CMake script.

I followed your instructions for setting up with the CMake GUI. I pointed SFMLDIR to ".../SFML/SFML-2.0" and SFML_INCLUDE_DIR to ".../SFML/SFLM-2.0/include". The obj files compiled fine, but I got tons of linker errors all complaining about sfml. This happened with both NMake and VS 2008.

After some investigating, I noticed that in project settings in VS 2008, the Linker/Input was pointing to ".../SFML/SFML-1.6/[libs]". That just happens to be where I keep my 1.6 version. I double checked several times with CMake and tried recreating everything to make sure I wasn't pointing CMake to the wrong folder, but it kept trying to use the 1.6 libs.

Finally I just moved every folder inside ".../SFML/" other than the SFML-2.0 folder somewhere else and tried again. This time it worked. So that's really strange. Somehow the presence of the SFML-1.6 folder makes the generated scripts point to those libs.

7
So since I'm using a Label as the handle that the SFML Render Window (just "SFML" for short) draws on. So I'm no longer using any of SFML's own events. Instead, I'm using the C++/CLI Winforms interface. However there are times when I want key presses and mouse clicks to be directed to SFML (or rather, certain key presses and mouse clicks should activate code that does something to SFML).

Since I'm using a Label, which cannot gain focus, I need to handle key presses globally (within the form at least). In other words, I need hot keys. Here are some simple examples of what kind of hot keys I'd like (please don't worry about how I make things happen in the SFML, the point is catching the hot keys).

1) When I press 'R', the graphics should reset.
2) When I press 'L', new graphics should be loaded.
3) If I hold Ctrl and click on the SFML, something will happen at the location I clicked.
4) If I hold the Spacebar and mouse drag on the SFML, things will be moved around.
5) If some TextBox control has focus, then key presses should go to the text box and not activate the hot keys.
6) If I MouseClick on some Button control and then start clicking on the SFML and at some point press the Spacebar, the Button should not be clicked again. (Remember, this SFML cannot have focus, so the button I pressed before still has focus.)

So that's what I'd like to do. Here is what I've tried so far:

A) To catch all hot keys, I set the form's KeyPreview property to true. This makes all key presses go to the form before any other controls. Then I simply handle KeyDown, KeyUp, or KeyPress events for the form.

B) To make sure typing in text boxes doesn't activate hot keys, in the KeyDown, KeyUp, or KeyPress events for the form, I check if any text boxes have focus before doing anything with the event, e.g.:

if (ActiveControl->Name != "textBox1" && ActiveControl->Name != "textBox2")
{ handleHotKey(e); }

TextBoxes actually have a PreviewKeyDown event that fires before the Form's KeyPreview, but I'm not sure how I would use it. It fires even before the text enters the TextBox, so setting the event.handled to true actually prevents the text from appearing.

C) To prevent buttons from being activated by the Spacebar, I used the MouseClick event for the buttons instead of the Click event, so only an actual MouseClick on the button will make anything happen. While this works, the Spacebar still activates the button's clicking animation.

Instead of a Label, I've also considered using a TextBox as the handle given to the SFML Render Window. But there are a few problems with this as well. When the TextBox gains or loses focus, it redraws itself, causing a flicker in SFML. When it has focus, even with no text and read only, it still shows the typing/selection caret blinking (disabling the TextBox fixes that, but then it can no longer gain focus). If there was a way to prevent the TextBox from repainting, that could fix the problem. However, even if those problems were fixed, the idea that the TextBox could lose focus by clicking on Buttons and other things seems bad. If I click on some Button (giving it focus), and then hit some hot key, it should still fire off the event.

Basically, it should be assumed that all keyboard events could be doing something to the SFML Render Window, where the exceptions are things like text boxes having focus. Another way to think of it is that the SFML Render Window should always have focus (again, except for TextBoxes, etc).

So far, my methods with the Label all seems to work, but they just feel a bit clumsy. Any suggestions on how to improve this would be appreciated.

Edit: Someone on Stack Overflow had this to say: "Well, don't pick a Label. And definitely not a TextBox. Just make your own Control derived class." Not so sure about that.

8
Thanks Andrei15193, it looks like I have some reading to do. As for portability, well the whole point of this thread is that I'm trying to use Visual Studio to make a Windows Forms program with Design Mode, so I'm definitely targeting Windows. :)

Laurent, looks like I have it working. I removed the C++ paths and libs and added references to the .NET libs. I'll post my code at the bottom (I'm just going to post the entire file so there are no assumptions).

It works great! I didn't have to do any funky stuff with the label's style or with the on paint events like in that other thread. I just gave the label's handle to the RenderWindow constructor and called Clear, Draw and Display from a timer and everything looks nice, with smooth (though very simple so far) animation.

I also have a couple lines of code commented out that will create a separate SFML window instead of using the label. It works just fine as well.

You'll notice all the SFML setup is in a button's click event. I originally had it in the Form's constructor. However the program was starting and then crashing before I ever saw anything. I moved the code to the button just so I could see the form actually appear before I make it crash. But when I hit the button, the exception window popped up and told me what the problem was. It seems before the program was crashing before the popup exception handler was loaded. So I'm just keeping the SFML setup in the button click for now. (Edit: Moving the SFML setup to the form load event solves this problem. SFML starts immediately and automatically and any exceptions are handled by the popup exception handler so you know about them.)

Anyway, the exception was "Unable to load DLL 'csfml-graphics-2': The specified module could not be found." This surprised me, but I went ahead and downloaded csfml, put the dll in the debug folder and it worked! I did the same for audio and window. Is this how it's supposed to be done?

Oh, and one other thing. I noticed that the examples that come with the 2.0 .NET release are just executables. There isn't actually any example code. And all of them crash immediately when I try to run them. I checked the 1.6 .NET release and they do have the source code. But the binaries that come with them also crash immediately. Since the 1.6 version has the code, I figured you probably intended to put the code in the 2.0 version, so I wanted to let you know. I don't know about the crashing though. I tried putting all the dlls in with the binaries, but it didn't work.

#pragma once

namespace SFMLWinForm {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;

    using namespace SFML::Audio;
    using namespace SFML::Window;
    using namespace SFML::Graphics;

    /// <summary>
    /// Summary for Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }

    private:
        RenderWindow^ window;
        Music^ music;
        Texture^ texture;
        Sprite^ sprite;
        SFML::Graphics::Font^ font;
        SFML::Graphics::Text^ text;

    private: System::Windows::Forms::Label^  lblWindow;
    private: System::Windows::Forms::Button^  btnQuit;
    private: System::Windows::Forms::Button^  btnStart;
    private: System::Windows::Forms::Timer^  tmrSFML;
    private: System::ComponentModel::IContainer^  components;

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>


#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->components = (gcnew System::ComponentModel::Container());
            this->lblWindow = (gcnew System::Windows::Forms::Label());
            this->btnQuit = (gcnew System::Windows::Forms::Button());
            this->btnStart = (gcnew System::Windows::Forms::Button());
            this->tmrSFML = (gcnew System::Windows::Forms::Timer(this->components));
            this->SuspendLayout();
            //
            // lblWindow
            //
            this->lblWindow->Location = System::Drawing::Point(12, 9);
            this->lblWindow->Name = L"lblWindow";
            this->lblWindow->Size = System::Drawing::Size(760, 515);
            this->lblWindow->TabIndex = 2;
            this->lblWindow->Text = L"Label Window";
            //
            // btnQuit
            //
            this->btnQuit->DialogResult = System::Windows::Forms::DialogResult::Cancel;
            this->btnQuit->Location = System::Drawing::Point(697, 527);
            this->btnQuit->Name = L"btnQuit";
            this->btnQuit->Size = System::Drawing::Size(75, 23);
            this->btnQuit->TabIndex = 1;
            this->btnQuit->Text = L"Quit";
            this->btnQuit->UseVisualStyleBackColor = true;
            this->btnQuit->Click += gcnew System::EventHandler(this, &Form1::btnQuit_Click);
            //
            // btnStart
            //
            this->btnStart->Location = System::Drawing::Point(15, 527);
            this->btnStart->Name = L"btnStart";
            this->btnStart->Size = System::Drawing::Size(75, 23);
            this->btnStart->TabIndex = 0;
            this->btnStart->Text = L"Start";
            this->btnStart->UseVisualStyleBackColor = true;
            this->btnStart->Click += gcnew System::EventHandler(this, &Form1::btnStart_Click);
            //
            // tmrSFML
            //
            this->tmrSFML->Interval = 1;
            this->tmrSFML->Tick += gcnew System::EventHandler(this, &Form1::tmrSFML_Tick);
            //
            // Form1
            //
            this->AcceptButton = this->btnStart;
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->CancelButton = this->btnQuit;
            this->ClientSize = System::Drawing::Size(784, 562);
            this->Controls->Add(this->btnStart);
            this->Controls->Add(this->btnQuit);
            this->Controls->Add(this->lblWindow);
            this->Name = L"Form1";
            this->Text = L"SFML";
            this->ResumeLayout(false);

        }
#pragma endregion

    private:System::Void btnQuit_Click(System::Object^  sender, System::EventArgs^  e)
            {
                window->Close(); // For separate SFML window
                this->Close();
            }

    private:System::Void OnClose(System::Object^  sender, System::EventArgs^  e)
            {
                // For separate SFML window close
                ((RenderWindow^)sender)->Close();
            }

    private:System::Void btnStart_Click(System::Object^  sender, System::EventArgs^  e)
            {
                static bool runOnce = false;
                if (runOnce) return;
                runOnce = true;

                // Creates a separate window (in addition to Form1) for rendering SFML
                //window = gcnew RenderWindow(VideoMode(800, 600), "SFML Window");
                //window->Closed += gcnew EventHandler(this, &Form1::OnClose); // For separate SFML window close

                // Uses lblWindow (a label) as render window instead of separate window
                window = gcnew RenderWindow(lblWindow->Handle);

                music = gcnew Music("../media/music.ogg");
                music->Play();
                music->Loop = true;

                texture = gcnew Texture("../media/cute_image.jpg");
                sprite = gcnew Sprite(texture);

                font = gcnew SFML::Graphics::Font("../media/arial.ttf");
                text = gcnew SFML::Graphics::Text("WHY DO I EXIST ?", font, 50);
                text->Position = Vector2f(8, 335);
                text->Color = SFML::Graphics::Color::Black;

                tmrSFML->Enabled = true;
            }

    private:System::Void tmrSFML_Tick(System::Object^  sender, System::EventArgs^  e)
            {
                // Process events
                window->DispatchEvents();

                // Animate sprite and text
                float speed = 1;
                static float i = speed;
                static float j = speed;
                if (sprite->Position.X + texture->Size.X + 1 > window->Size.X) i = -speed;
                if (sprite->Position.X - 1 < 0) i = speed;
                if (sprite->Position.Y + texture->Size.Y + 1 > window->Size.Y) j = -speed;
                if (sprite->Position.Y - 1 < 0) j = speed;
                sprite->Position += Vector2f(i, j);
                text->Position += Vector2f(i, j);

                // Clear screen
                window->Clear();

                // Draw the sprite
                window->Draw(sprite);

                // Draw the string
                window->Draw(text);

                // Update the window
                window->Display();
            }

    };
}
 

[attachment deleted by admin]

9
Thanks Andrei15193,
When you said, "You can't have an "unmanaged" type inside a "managed" one", I assume you were being literal, referring to having an unmanaged class as a member of a managed class? Can you not even have pointers to unmanaged classes? And I assume this has to do with garbage collection, etc, because I know you can mix them, as long as you know which are handled by what. That's part of the purpose of using the ^ operator instead of *, as I understand it.

Anyway, I just noticed that in the thread I linked in my first post, the author said he was using .NET and there is a .NET version of SFML-2.0. I downloaded it to take a look, but it only included the dll files sfmlnet-audio-2.dll, sfmlnet-graphics-2.dll and sfmlnet-windows-2.dll. Don't I need different .lib and .pdb files too, as well as debug versions for compilation?

10
SFML-2.0 for C++
Win 7 Pro x64
Visual Studio 2010 and 11 Beta (CLI IntelliSense!)

Like the subject says, I'd like to add SFML views to a Windows form. I've played with the Win32 examples, but the designer in Visual Studio is very nice and I'd like to use it.

The most obvious way to use the designer is to make a Windows Forms program, which puts it under CLI managed code. But if there's a way to use the designer with the example Win32 code, that would be fine as well.

I've looked around the forums, but I've found very few threads talking about this, and those I've found were incomplete and 2-3 years old.

http://en.sfml-dev.org/forums/index.php?topic=1666.0 <-- This is what I've tried to use, though I decided to make a new thread instead of resurrecting one that is three years old.

My test Windows Forms project has the same settings added as the working Win32 example (include path, lib path, dependencies: sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;).

I attempted modifying my form's constructor:

public ref class MyForm : public System::Windows::Forms::Form
{
public:
        MyForm(void) : renderView(NULL) // <-- init pointer
        {
                InitializeComponent();
                HWND ptr = (HWND)renderWindow->Handle.ToPointer(); // Get the Label's handle (renderWindow is a Label)
                renderView = new sf::RenderWindow(ptr); // Pass it to the sf::RenderWindow
                renderWindow->Paint += gcnew PaintEventHandler(this, &MyForm::MyForm_Paint);
        }
        [more code...]

The line "renderView = new sf::RenderWindow(ptr);" generates linker errors:

1>WindowsForms.obj : error LNK2028: unresolved token (0A00000E) "private: virtual bool __clrcall sf::RenderWindow::activate(bool)" (?activate@RenderWindow@sf@@$$FEAM_N_N@Z) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::RenderTarget'}''(void)" (???__E??_SRenderWindow@sf@@6BRenderTarget@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2028: unresolved token (0A00000F) "public: virtual class sf::Vector2<unsigned int> __clrcall sf::RenderWindow::getSize(void)const " (?getSize@RenderWindow@sf@@$$FUBM?AV?$Vector2@I@2@XZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::RenderTarget'}''(void)" (???__E??_SRenderWindow@sf@@6BRenderTarget@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2028: unresolved token (0A000010) "protected: virtual void __clrcall sf::RenderWindow::onResize(void)" (?onResize@RenderWindow@sf@@$$FMAMXXZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::Window'}''(void)" (???__E??_SRenderWindow@sf@@6BWindow@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2028: unresolved token (0A000011) "protected: virtual void __clrcall sf::RenderWindow::onCreate(void)" (?onCreate@RenderWindow@sf@@$$FMAMXXZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::Window'}''(void)" (???__E??_SRenderWindow@sf@@6BWindow@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2028: unresolved token (0A000017) "public: virtual __clrcall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@$$FUAM@XZ) referenced in function "public: virtual void * __clrcall sf::RenderWindow::`vector deleting destructor'(unsigned int)" (??_ERenderWindow@sf@@$$FUAMPAXI@Z)
1>WindowsForms.obj : error LNK2028: unresolved token (0A000042) "public: __clrcall sf::RenderWindow::RenderWindow(struct HWND__ *,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@$$FQAM@PAUHWND__@@ABUContextSettings@1@@Z) referenced in function "public: __clrcall WindowsForms::MyForm::MyForm(void)" (??0MyForm@WindowsForms@@$$FQ$AAM@XZ)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "public: virtual __clrcall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@$$FUAM@XZ) referenced in function "public: virtual void * __clrcall sf::RenderWindow::`vector deleting destructor'(unsigned int)" (??_ERenderWindow@sf@@$$FUAMPAXI@Z)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "public: __clrcall sf::RenderWindow::RenderWindow(struct HWND__ *,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@$$FQAM@PAUHWND__@@ABUContextSettings@1@@Z) referenced in function "public: __clrcall WindowsForms::MyForm::MyForm(void)" (??0MyForm@WindowsForms@@$$FQ$AAM@XZ)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "protected: virtual void __clrcall sf::RenderWindow::onResize(void)" (?onResize@RenderWindow@sf@@$$FMAMXXZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::Window'}''(void)" (???__E??_SRenderWindow@sf@@6BWindow@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "protected: virtual void __clrcall sf::RenderWindow::onCreate(void)" (?onCreate@RenderWindow@sf@@$$FMAMXXZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::Window'}''(void)" (???__E??_SRenderWindow@sf@@6BWindow@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "private: virtual bool __clrcall sf::RenderWindow::activate(bool)" (?activate@RenderWindow@sf@@$$FEAM_N_N@Z) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::RenderTarget'}''(void)" (???__E??_SRenderWindow@sf@@6BRenderTarget@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>WindowsForms.obj : error LNK2019: unresolved external symbol "public: virtual class sf::Vector2<unsigned int> __clrcall sf::RenderWindow::getSize(void)const " (?getSize@RenderWindow@sf@@$$FUBM?AV?$Vector2@I@2@XZ) referenced in function "void __clrcall `dynamic initializer for 'const sf::RenderWindow::`local vftable'{for `sf::RenderTarget'}''(void)" (???__E??_SRenderWindow@sf@@6BRenderTarget@1@@@@YMXXZ@?A0x679daca2@@$$FYMXXZ)
1>D:\Zytrex-Development\VisualStudio\WindowsForms\Debug\WindowsForms.exe : fatal error LNK1120: 12 unresolved externals

In the thread I've tried to work from (the link I posted), it sounded like the guy got his to work. Unfortunately, he didn't mention anything about his project settings, so I don't know what I'm missing that would get rid of the linker errors.

11
Opened as issue 215 by malpert... that's me.  :)

12
Graphics / Better Line Thickness and OpenGL
« on: April 28, 2012, 08:15:25 am »
So I've spent a few hours on the forums and experimenting. It seems that in SFML2, the general consensus is that if you want to draw lines, pass a vertex array to draw(). And if you want to draw lines with thickness, use rotated rectangles.

I think using rotated rectangles is bad for several reasons.
  • If someone is drawing a large graph (which is what I'm doing), then using vertex arrays makes it very easy. But if I want these lines to have thickness, then I have to come up with a completely different method of drawing them since I can no longer simply pass my vertex array to draw().
  • To draw a rotated rectangle to represent a line with thickness (assuming you're drawing a line between two points) requires a call to atan2 (to get the angle) and sqrt (to get the distance between points which will be the length of the rectangle). You also have to adjust the position of the rectangle slightly so the the starting point is not on the corner of the rectangle, but rather the middle of one end.
  • Let's look at the large graph drawing case again. Most likely, the graph is stored as nodes with adjacency lists of some sort. In other words, there are no edge objects at all. So to have the lines drawn with thickness, there are two things the programmer can do: (1) The programmer can create and store somewhere edge objects for every pair of connected nodes so that these edge objects (rotated rectangles) are ready for drawing (angle and size are set upon creation and updated whenever a node is moved). (2) Create all the edges temporarily during the draw. The first way requires keeping track of more objects while the second way is slower because the size and angle of the rectangles must be calculated for all pairs of nodes every loop even if the nodes haven't moved.
If the draw() function could take a vertex array and a thickness, that would make things much cleaner and faster.

Here is what I've been using (ht = half thickness; n1/n2 = node 1/2)
float dx = n2->x - n1->x;
float dy = n2->y - n1->y;
float rot = atan2(dy, dx) * RADTODEG;
rect.setSize(sf::Vector2f(std::sqrt(std::abs(dx)*std::abs(dx) + std::abs(dy)*std::abs(dy)), ht*2));
rect.setOrigin(0, ht);
rect.setPosition(n1->x, n1->y);
rect.setRotation(rot);

This code must be run whenever a node in an edge is moved (which is a lot since I'm building a graph editor for creating a navigation mesh).

It just seems strange that if a user wants a line with adjustable thickness (a pretty reasonable request), that this graphics package makes them basically hack it out themselves.

Finally, OpenGL has function calls for drawing lines with thickness:
glLineWidth(width);
glBegin(GL_LINES);
glVertex2i(x1, y1);
glVertex2i(x2, y2);
glEnd();

I figure somewhere you're calling these OpenGL functions when you draw vertex arrays. So why not just allow thickness as well? I've read several threads where people discuss problems with how their particular implementation of lines with thickness behave (since everybody does it themselves, all slightly differently). But OpenGL's documentation suggests glLineWidth plays very nicely in different situations, including with and without anti-aliasing: http://www.opengl.org/sdk/docs/man/xhtml/glLineWidth.xml

13
When you say "this is how the OS behaves," are you saying that the OS is refusing to display the window?

Either way, it seems like if the currently set size for an SFML window is such that no window will appear at all, then the most reasonable thing to do is to shrink it to a size so that the window will at least appear. Yes, the programmer may be upset that the window is not the size they expected, but hopefully noticing that the window exactly fits the width and/or height of their monitor will be a pretty big hint as to what happened. But for no window to appear at all, that's just baffling.

14
I've also noticed that if the size of the RenderWindow is set too high that the window simply does not show up. It was very confusing for a good ten minutes because I was doing most of my development on my desktop, then switched to my laptop when I was out and about: "It was just working! What happened!?!?"

While it's true that it's difficult to work with a window larger than your screen, if the window at least shows up, you can resize it. But if the window does not show up at all, it results in the astonishment of the programmer. So I'm gonna have to call this a bug.

15
Window / Re: Disabling Alt/control/shift
« on: April 25, 2012, 08:58:43 am »
I'm creating a visual graph editor. The user can drag with the mouse to create selection boxes to select nodes. Holding Shift allows the user to add to the current selection while holding Alt allows the user to subtract from the current selection. This is the same was selection works in Photoshop and many other programs with the drag-select interface. However, as others have pointed out, when you release the Alt key, the program loses focus. The user has to click on it somewhere to make it active again.

I saw someone talked about this way back in 2008 and pointed to possible solutions. However, this was the newest and first thread in the search results for this topic, so I'm posting here.
http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms646360(VS.85).aspx

Pages: [1]