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

Pages: [1] 2 3 4
1
Graphics / Textures missing in Ubuntu
« on: October 18, 2009, 10:33:58 am »
Actually it seems that you have bug in context activation/deactivation logic:
Every time when you deactivate an inactive context, the "threadContext" will get activated.

Way to test:
Code: [Select]
int main()
{
    // Create main window
    sf::RenderWindow Window(sf::VideoMode(500, 200), "SFML window");

    // Main window is now active
    {
        // Create context, which gets activated
        sf::Context context;

        // Activate the main window, this disables "context"
        Window.SetActive();

    }    // Context will get destroyed and deactivated

    // Main window is not active anymore
}


This is illogical, since user just activated main window.

Let's follow what happens when inactive context will get deactivated... First it cals Context::SetActive(false), which calls ContextGL::SetActive(false), which looks like this:
Code: [Select]

bool ContextGL::SetActive(bool active)
{
    if (MakeCurrent(active))
    {


MakeCurrent will get called with false:
Code: [Select]

bool ContextGLX::MakeCurrent(bool active)
{
    if (active)
    {
    ...
    }
    else
    {
        if (glXGetCurrentContext() == myContext)
            ...
        else
            return true;
    }
}

So MakeCurrent returns true, because current context was not "myContext"

This returns to SetActive function:
Code: [Select]

    if (MakeCurrent(active))   // <-- Just returned true
    {
        if (active && (threadContext == 0))
        {
            ...
        }
        else if (!active && (threadContext != NULL) && (threadContext != this))
        {
            // Activate the reference context for this thread to ensure
            // that there is always an active context for subsequent graphics operations
            threadContext->SetActive(true);
        }

The else-if branch is run, since active is false and thread context exists and it is not this.
So, now we just activated threadContext when we were deactivating an context that was not active. This sounds like a bug to me :)

Shouldn't that MakeCurrent return false when we are deactivating an inactive context? Then nothing would happen and the previously active context would stay active.

Edit: Just changing MakeCurrent to return false was not enough, also this had to be changed:
Code: [Select]
ContextGL::~ContextGL()
{
    if (threadContext == this)
    {
        threadContext = NULL;
    }
    /*else if (threadContext != NULL)
    {
        threadContext->SetActive(true);
    }*/
}

2
Graphics / Textures missing in Ubuntu
« on: October 18, 2009, 08:38:39 am »
I found one (possibly) illogical bit on window creation.
In src/SFML/Window/Window.cpp, line 133:
Code: [Select]
   // Make sure another context is bound, so that:
    // - the context creation can request OpenGL extensions if necessary
    // - myContext can safely be destroyed (it's no longer bound)
    Context context;

    // Recreate the context
    delete myContext;
    myContext = priv::ContextGL::New(myWindow, mode.BitsPerPixel, settings);

    // Perform common initializations
    Initialize();
}

Here you create another context so you can get OpenGL extensions data, as said in comments. But isn't it so that this temporary context will get destroyed - and thereby marked not active - when it goes out of scope. And after this there is no active context? Or is there?

I made a test to modify this code in following way:
Code: [Select]
   // Initialize window in it's own scope
    {
        // Make sure another context is bound, so that:
        // - the context creation can request OpenGL extensions if necessary
        // - myContext can safely be destroyed (it's no longer bound)
        Context context;

        // Recreate the context
        delete myContext;
        myContext = priv::ContextGL::New(myWindow, mode.BitsPerPixel, settings);

        // Perform common initializations
        Initialize();
    }

    // Activate context
    SetActive(true);
}


Now there is some context active when window initialization is done.
This modification fixes this problem what I am facing here in Ubuntu.

So, could it be that in Linux implementation when you call SetActive(false) to some context, all contexes will get deactivated?


Edit:
Actually it seems that "threadContext" (sfml/Window/ContextGL.cpp, line 131) will get activated when this happens.
So, there is an active context, but it is not the window that was created. That's why the SetActive(true) call on the end of the function was required.

3
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 08:14:32 pm »
Quote from: "Laurent"
So the context sharing stuff is broken... which doesn't really surprises me ;)

Hmm, but interesting thing is that that context sharing did work before that batch mode modification...

4
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 02:45:15 pm »
Quote from: "Laurent"
Maybe you can do a quick test: call glXGetCurrentContext() before loading your image

I tried this, it did return valid pointer.

5
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 02:23:49 pm »
It is integrated Intel GMA 950 (Samsung NC10 laptop)

6
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 12:59:19 pm »
Quote from: "Tank"
How does it look like? Do you only have crashes or graphical issues? If the latter applies to you, welcome to the club. :)

It is just black, nothing is displayed on screen, except some flickering.
But when I add "window.SetActive();" call just after RenderWindow was created it works perfectly. No issues at all.
(well, title bar is missing, but it is fixed by disabling that Compiz :) )

7
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 11:42:41 am »
Quote from: "Laurent"
Quote
Haven't tried samples, though my test code is a stripped down sample from here

Yep, but samples are always updated and tested according to the latest modifications, so this is the safest reference for tests ;)

I'll be damned, you are right :D
I tried OpenGL sample and it worked perfectly, did load image and all

The key difference was to call "Window::SetActive()" before loading textures.
Shouldn't this be automatic?  :wink:

Edit:
Just found out that for example pong sample does not work, since it does not have this SetActive call before loading textures.
It seems that in Windows context is activated by default and in Linux it is not activated. (or there is difference in image loading code)

8
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 10:48:21 am »
Quote from: "Laurent"
Thanks for your help :)

You're welcome :)
Let's see if I can help debugging this too

Quote from: "Laurent"
Do you have any error message in the console? Did you try a code without direct OpenGL calls? What about the SFML samples

Didn't get any error messages in console. Even debug version didn't print any errors.
I commented OpenGL calls from the source above, no change in behavior.
Haven't tried samples, though my test code is a stripped down sample from here: http://www.sfml-dev.org/documentation/1.5/

9
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 10:06:38 am »
I backtraced this in SVN, here's my findings:

1214-1220: Can't open window, prints this error
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Serial number of failed request:  30
  Current serial number in output stream:  33

Fixed by commenting this if-line in Graphics/Linux/ContextGLX.cpp
    //if (shared)
        SetActive(true);

Opens window, draws texture


1223-1234: Can't open window, prints same error as above, fixed by same modification.
Opens window, does not draw texture


1235-: Opens window, does not draw texture


So textures were broken in changes at revision 1221, following files were modified from 1220->1221:
Code: [Select]
U    build/vc2005/sfml-graphics.vcproj
U    build/vc2005/sfml-audio.vcproj
U    build/vc2008/sfml-graphics.vcproj
U    build/codeblocks/sfml-graphics.cbp
U    include/SFML/Graphics/Shape.hpp
U    include/SFML/Graphics/String.hpp
U    include/SFML/Graphics/Sprite.hpp
U    include/SFML/Graphics/RenderWindow.hpp
U    include/SFML/Graphics/Drawable.hpp
U    include/SFML/Graphics/Image.hpp
U    include/SFML/Graphics/RenderImage.hpp
U    include/SFML/Graphics/PostFX.hpp
A    include/SFML/Graphics/RenderQueue.hpp
U    include/SFML/Graphics/RenderTarget.hpp
U    include/SFML/Graphics.hpp
U    include/SFML/Window/Window.hpp
U    include/SFML/Config.hpp
U    CSFML/build/VC2008/csfml-graphics.def
U    CSFML/include/SFML/Graphics/RenderImage.h
U    CSFML/include/SFML/Graphics/RenderWindow.h
U    CSFML/src/SFML/Graphics/RenderWindow.cpp
U    CSFML/src/SFML/Graphics/RenderImage.cpp
U    samples/opengl/OpenGL.cpp
U    samples/window/Window.cpp
U    src/SFML/Graphics/Sprite.cpp
U    src/SFML/Graphics/String.cpp
A    src/SFML/Graphics/GeometryRendererIM.cpp
A    src/SFML/Graphics/GeometryRendererIM.hpp
A    src/SFML/Graphics/Batch.cpp
U    src/SFML/Graphics/Drawable.cpp
U    src/SFML/Graphics/Win32/RenderImageImplPBuffer.cpp
A    src/SFML/Graphics/GeometryRenderer.cpp
U    src/SFML/Graphics/Image.cpp
U    src/SFML/Graphics/RenderImage.cpp
U    src/SFML/Graphics/PostFX.cpp
A    src/SFML/Graphics/Batch.hpp
A    src/SFML/Graphics/GeometryRenderer.hpp
A    src/SFML/Graphics/GeometryRendererVBO.cpp
U    src/SFML/Graphics/FontLoader.cpp
A    src/SFML/Graphics/GeometryRendererVBO.hpp
U    src/SFML/Graphics/Shape.cpp
U    src/SFML/Graphics/RenderWindow.cpp
A    src/SFML/Graphics/GeometryRendererVA.cpp
A    src/SFML/Graphics/GeometryRendererVA.hpp
A    src/SFML/Graphics/RenderQueue.cpp
U    src/SFML/Graphics/RenderTarget.cpp
U    src/SFML/Window/Window.cpp
U    dotnet/samples/opengl/OpenGL.cs
U    dotnet/src/Graphics/RenderImage.cs
U    dotnet/src/Graphics/RenderTarget.cs
U    dotnet/src/Graphics/RenderWindow.cs


This seems to be related to that new batch mode?

10
Graphics / Textures missing in Ubuntu
« on: October 15, 2009, 08:21:28 am »
Hi
I tried latest SVN version of SFML2 in Ubuntu(9.4) and I can't get textures working.
Textures work fine if I use SFML 1.6 from SVN, so there seems to be something in SFML2 branch.

Here's working example:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
 
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(500, 200), "SFML window");
//sf::RenderWindow App(sf::VideoMode::GetDesktopMode(), "SFML window", sf::Style::Fullscreen);

// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("Logo.png"))
return EXIT_FAILURE;
sf::Sprite Sprite(Image);

// Main loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
if (Event.Type == sf::Event::KeyPressed)
App.Close();
}

// Clear screen
App.Clear();

// Draw white box
App.SetActive();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_QUADS);
{
glColor3f(1.0,1.0,1.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
}
glEnd();

// Draw the sprite
App.Draw(Sprite);

// Update the window
App.Display();
}

return EXIT_SUCCESS;
}


Only white box that I draw manually gets displayed. It is not even overlapped that 400x200 image, so it seems that image drawing is just totally skipped. Adding App.Flush() calls didn't change anything.

Title bar was also missing, but this was fixed by disabling Compiz, which didn't affect anything else.

Any idea what is happening?

11
Graphics / SFML 1.5 PostFX problem ( ATI vs. Nvidia )
« on: August 30, 2009, 04:15:34 am »
Just a hunch...
I would think that distance() function is to blame. It has to use sqrt to get the distance, which is quite power hungry function, so card manufacturers might have done some weird optimizations to it.

Try something like this instead:
Code: [Select]

texture framebuffer
vec2 centerXY
float offset

effect
{
   float len = dot(_in, centerXY) * offset;
   if ((len < 0.09f) && (len > 0.01f))
      _out = framebuffer(_in + (_in - centerXY) * len);  
   else
      _out = framebuffer(_in);
}


I replaced the distance function with dot product, which does basically the same, but does not use sqrt:
  dot = x*x + y*y
  distance = sqrt( x*x + y*y )

Since square root was not used, those lengths you compare against had to be changed too:
  0.3 * 0.3 = 0.09
  0.1 * 0.1 = 0.01

12
Network / Simple HTTP Server
« on: August 29, 2009, 05:13:23 am »
Quote from: "kkitsune"
Thanks a lot, It works now a lot better but now, my client is receiving strangely formated data...

I tried your code with firefox yesterday.
Your SplitGetReq is expecting only the first line of the data, but you were providing all data that browser sent to you.

So, just splitting that ReceivedStr from newline will fix it
Code: [Select]
size_t posStartPath = ReceivedStr.find_first_not_of(" ", 3);
size_t posEndPath = ReceivedStr.find_first_of("\n\r", 3);
SplitGetReq(ReceivedStr.substr(posStartPath,posEndPath-posStartPath), path, params);

13
Network / Simple HTTP Server
« on: August 28, 2009, 06:30:45 am »
Socket::Receive() is a blocking function if there is no more data, so something like this will let you send reply back to client:
Code: [Select]
while(Socket.Receive(Buffer, sizeof(Buffer), Size) == Socket::Done)
{
ReceivedStr.append(Buffer, Buffer + Size);

// Break out if received less data than buffer can hold
if (Size < sizeof(Buffer))
break;
}

14
Network / TCP Listening server doesn't get whats sent to it
« on: August 28, 2009, 05:28:00 am »
Hmm
The reason actually seems to be that you read different data than you send...

When you are sending packet let's say you send a string "hello". Which is 5 letters, so sent data will contain only those 5 letters.

But, when you are reading the data with sf::Packet the data is expected to be "\5hello".
When sf::Packet tries to read a string, the first item it reads is the length of the string. Which is number 5 in this case, then it proceeds to read 5 letters, if packet is long enough.
In your case, you sent data "hello", so the length of the string will be 104 (ascii value for letter 'h'). Since the packet doesn't contain enough data the reading will fail and string will be empty.

In short, use sf::Packet for sending if you are reading with sf::Packet, something like:
Code: [Select]
sf::Packet packet;
packet << data;
if (socket.Send(packet) != sf::Socket::Done)
   ... etc

15
Graphics / image tearing???
« on: August 28, 2009, 04:44:41 am »
That could just be scaling and those decimal coordinates you mentioned.
Try setting Image.SetSmooth(false); for images and see if it does anything. (if I remember correctly that was set to true by default)

Pages: [1] 2 3 4
anything