raduprv / Eternal-Lands

http://www.eternal-lands.com
Other
157 stars 57 forks source link

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

Closed brunoramoslu closed 2 years ago

brunoramoslu commented 2 years ago

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@30b54fd40128e18d592c5cafde525cab31d3dc7b

gvissers commented 2 years ago

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.

gvissers commented 2 years ago

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

brunoramoslu commented 2 years ago

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

brunoramoslu commented 2 years ago

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.

gvissers commented 2 years ago

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