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.


Topics - panithadrum

Pages: [1] 2 3
1
Graphics / Can't render in a thread
« on: November 06, 2015, 08:10:20 am »
Hi guys!

I'm using SFML v2.3, Mingw32 v4.9.2 and Windows 10.

I'm trying to render in a thread, and runtime errors keep coming no matter what I do (Failed to activate the window's context). Here's the code I'm using.

#include <future>
#include <SFML/Graphics.hpp>

int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
    window.setVerticalSyncEnabled(true);

    // run the program as long as the window is open
    while (window.isOpen()) {

        // handle events
        {
            sf::Event event;
            while (window.pollEvent(event)) {
                // "close requested" event: we close the window
                if (event.type == sf::Event::Closed) {
                    window.close();
                }
            }
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        window.setActive(false);
        std::async(std::launch::async, [&]() {
            window.draw(sf::CircleShape(20));
        }).wait();

        // end the current frame
        window.display();
    }

    return 0;
}

Am I missing something? Thanks.

2
Network / Control during upload & download
« on: February 23, 2011, 12:31:31 pm »
I wonder if you will be working on this soon... to get the transfer speed is a function I would really like to work with!

Greetings.

3
SFML projects / Flat - 2D model editor (wip)
« on: December 16, 2010, 04:52:45 pm »
Flat - 2D model editor

Introduction
I am developing a 2D model editor for my games. It is intended to be used in topdown games (although, it could be used for any kind of 2D animations). I used Qt for the window handling and numerous widgets, and SFML for the rendering (the timeline and model view widgets).

It used a primitive version of what I am creating now for animations, so you will get the idea behind my work.

At the moment you can just animate a single dot, but skeleton creation and animation is half finished. There is no download link at the moment. I will post new youtube videos when I am releasing new things.

Features
Before 19-12-2010:
    - Timeline:
      - Create keyframe
         - Move keyframe
         - Delete keyframe

    - Animation editor:
      - Change bone's position

    - Skeleton/skin editor
      - Empty, with a single bone

    - Settings
      - Project settings

    - File   
      - Empty
[/i]
23/12/2010:
    - Skeleton/skin editor:
      - Load new skin
      - Skeleton with multiple bones

[/i]
Planned:
    - Skeleton/skin editor:
      - Change skin properties

    - Animation editor
      Properly animate the multiple bones (with the skin properties)

    - File
          
      - New/open/save as/save project files

    - Timeline
      - Copy/cut/paste keyframes

[/i]

4
Graphics / Can't draw with OpenGL in sf::RenderImage
« on: November 09, 2010, 10:52:02 am »
I am doing the same code on a RenderWindow and a RenderImage, but looks that the RenderImage is not working for me.
That's the code using a RenderWindow
Code: [Select]
int main()
{
// Window
sf::RenderWindow window;
window.Create(sf::VideoMode(800, 600), "What?");

// Setup OpenGL
glClearColor(1.f, 0.f, 0.f, 1.f);
glClearDepth(1.f);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDepthFunc(GL_LEQUAL);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 3000.f);
glMatrixMode(GL_MODELVIEW);
// Clear
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Setup camera
glLoadIdentity();
glTranslatef(0.f, 0.f, -100.f);
// Draw something
glColor4f(0.f, 0.f, 1.f, 1.f);
glBegin(GL_POLYGON);
{
glVertex2f(-10.f, -10.f);
glVertex2f(-10.f, 10.f);

glVertex2f(10.f, 10.f);
glVertex2f(10.f, -10.f);
}
glEnd();

// Display and wait
window.Display();
while(window.IsOpened())
{
sf::Event event;
while(window.GetEvent(event))
{
if(event.Type == sf::Event::Closed) window.Close();
}
}
}

and the output

Uploaded with ImageShack.us

This is the code for the RenderImage
Code: [Select]
int main()
{
// Render image
sf::RenderImage image;
image.Create(800, 600);

// Setup OpenGL
glClearColor(1.f, 0.f, 0.f, 1.f);
glClearDepth(1.f);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glDepthFunc(GL_LEQUAL);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 3000.f);
glMatrixMode(GL_MODELVIEW);
// Clear
glClearColor(1.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Setup camera
glLoadIdentity();
glTranslatef(0.f, 0.f, -100.f);
// Draw something
glColor4f(0.f, 0.f, 1.f, 1.f);
glBegin(GL_POLYGON);
{
glVertex2f(-10.f, -10.f);
glVertex2f(-10.f, 10.f);

glVertex2f(10.f, 10.f);
glVertex2f(10.f, -10.f);
}
glEnd();

// Image
image.Display();
image.GetImage().SaveToFile("image.png");
}

and the output image.png

Uploaded with ImageShack.us

I am using W7x64 with VS2010. Am I forgetting something? glClear works, but not the polygon itself.

5
General discussions / Best practices using CMake
« on: October 17, 2010, 09:52:43 pm »
I used now CMake for a while, and I wonder where should I build the SFML binaries so its temporary folders and projects doesn't disturb the main SFML folder.

I am currently bulding the binaries in SFML2/projects/vc2010-debug, SFML2/projects/vc2010-release.

What is your chosen binary folder?

6
General / Crash destroying a context
« on: October 10, 2010, 05:37:23 pm »
I am using SFML2 (last revision, shared libraries), W7 Home and Visual Studio 2010. I created the project with CMake.

It works fine until the window (or context) is out of scope (when it destroys the GL context). I get this:

Uploaded with ImageShack.us

The problems appears within this code:
Code: [Select]
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow Window;
// Or sf::Context Context;
}


I don't know if this is related to some other problems in the forum.

7
Graphics / QSfmlWidget
« on: September 25, 2010, 02:42:21 pm »
Hello. I am using the QSfmlWidget provided by Laurent, and I have the following problem:

I would like to be able to change the context settings while my widget is running, so when I do sf::RenderWindow::Create(winId()) the widget stops displaying new content, and the console shows the following:
Quote
Failed to set pixel format for device context -- cannot create OenGL context (by the way, there is a spelling error in that sentence :P)
Failed to activate the window's context (this is repeated every frame)


What should I do? Maybe some kind of close function? (I tried to call sf::RenderWindow::Close before,  but still getting this error).

8
Graphics / [Solved] Linker error with static colors
« on: September 16, 2010, 08:47:31 pm »
I don't know why, everything works fine, but when I refer to one of the static predefined colors, I get this link error:
Code: [Select]
error LNK2001: símbolo externo "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B) sin resolver

I am using RenderWindow's and the entire graphic library, so I don't know what's going on.

I tried to rebuild the library many times, but no success!

9
Graphics / const View & RenderWindow::GetView() const
« on: September 09, 2010, 01:50:53 am »
Why returning a const reference? I think it could be useful to return just a reference, so you can store it somewhere and modify it.

In the tutorials you assume you have a View & RenderWindow::GetView() function.

10
General / [Fixed] Copying dlls
« on: September 08, 2010, 06:25:53 pm »
I am silly always copying SFML (among other libraries) dll's to my project directories. Is there a way to say all my executables to look to my SFML directory for the dll's?

I thought putting the dll's directory in the PATH environment (Windows) would work, but looks like it won't.

11
Feature requests / OpenGL coordinates
« on: September 07, 2010, 09:14:37 pm »
Since SFML is prepared to work along OpenGL, and I am mixing OpenGL with SFML, I wonder if SFML coordinates could be like OpenGL are.

(Yes, I repeated two words three times :P)

12
SFML website / Coloured text inside "code" quotes
« on: August 18, 2010, 03:57:34 pm »
I would like to see coloured text when I put or read some code here in the forum. It would be very pleasant. What do you think, Laurent?

13
SFML wiki / [Sources] Rich text
« on: August 10, 2010, 09:00:40 pm »
sfe::RichText Allows the user to draw paragraphs of text with mixed styles and colors.

The source code is found in this git repository: https://github.com/Skyrpex/RichText.

You are invited to contribute using the issue tracker.

Have fun!

14
SFML wiki / [Sources] Richt text
« on: August 10, 2010, 09:00:30 pm »
Link to the wiki

sf::RichText is an expansion I've just made. The point is to have something like sf::Text but with the power of having differente styles in it.

Be careful, '\n' characters are not supported. You can use it, but you will see visual errors! (try it)

Please, report errors here! Thanks!

15
Graphics / Strange behavior (RenderWindow::GetEvent)
« on: August 10, 2010, 03:17:37 pm »
Hi, I wanted to track the events with a function like this, and then I realized that I keep getting sf::Event::KeyReleased events infinitely until the window receives another type of event. This is the code:

Code: [Select]
bool GetEvent(sf::RenderWindow &window, sf::Event &event)
{
bool b = window.GetEvent(event);
// Here you will get this event infinitely before you receive another type of event (like moving the mouse)
if(event.Type == sf::Event::KeyReleased) std::cout << "key released" << std::endl;
return b;
}

int main()
{
sf::RenderWindow window;
window.Create(sf::VideoMode(800, 600), "Bug?");
sf::Event event;
while(window.IsOpened())
{
while(GetEvent(window, event))
{
switch(event.Type)
{
// Close the window
case sf::Event::Closed:
window.Close();
break;
// Check for the key released event. Here it works fine!
case sf::Event::KeyReleased:
std::cout << "=========== KEY RELEASED ===========" << std::endl;
break;
}
}
}
}


I haven't tried with sf::Window. It's my fault?

EDIT:
Somehow, it's fixed if you change the function so it resets the event, like this:
Code: [Select]
bool GetEvent(sf::RenderWindow &window, sf::Event &event)
{
// Add this to "reset" the event
event.Type = sf::Event::Count;

bool b = window.GetEvent(event);

if(event.Type == sf::Event::KeyReleased) std::cout << "key released" << std::endl;
return b;
}

Pages: [1] 2 3