raduprv/Eternal-Lands

Map Editor: Weird tint on scene when using the 3d object browser

Closed this issue · 5 comments

Weird tint on scene when using the 3d object browser

Steps to reproduce:

  1. Open map editor
  2. Hit CTRL + b to open the 3D object browser
  3. Select the first entry Trees & Plants
  4. Select Trees with Leaves
  5. Navigate to the last page of items using the scrollbar button
  6. When you go to the last page of items, there is a tint to the scene

I tried to track the bug and I was able to identify something that "fixes it".
Removing glEnable(GL_COLOR_MATERIAL) and glDisable(GL_COLOR_MATERIAL) in the draw_3d_object related code seems to fix the bug, or at least change the behavior.

I'm not familiar enough with either OpenGL or the map editor code to be sure this is the root cause.
And that this will not cause any other potential issues elsewhere.
Could someone take a look?

P.S.: I have a branch I'm using to test with my changes brunoramoslu/Eternal-Lands@30b54fd

I'm confused.

I'm not all that good with OpenGL either. But glColorMaterial() is never called in the entire code, so I don't understand how calling glEnable(GL_COLOR_MATERIAL) can have any effect whatsoever. O wait, as per the man page of glColorMaterial():

 The initial value is GL_AMBIENT_AND_DIFFUSE. 

But then I don't understand why the scene is coloured with the UI color, when draw_3d_object() resets the color to white (note how the file names are drawn in white). Or why the effect only seems to happen when a single object is drawn in the browser window.

I suppose the calls to glEnable/glDisable(GL_COLOR_MATERIAL) might as well be removed. Maybe. But I can't say I really understand what's going on.

Ok, I figured out what was going on, should be fixed in 1d3ab40. See the commit message for details if interested.

Nice, I'll take a look at it tonight.
Thanks.

It seems to be working, and I did not find any weird issues, or side effects.
I opened some existing maps and saw no problems.

Alright, as this seems to be fixed, I'm closing the issue.