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:
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:
MakeCurrent will get called with false:
So MakeCurrent returns true, because current context was not "myContext"
This returns to SetActive function:
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:
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);
}*/
}