-2

I'm building a school project with OpenGl using glut, and I work both on my notebook (when not in home) and on my desktop. Both were fine, but all of a sudden, when I compile the code on my desktop, everything is white, while THE SAME CODE, runs fine on my notebook! I need it working on my desktop, as it is much easier to work in it when I'm at my home.

Screenshots:

Notebook: http://imageshack.us/a/img580/9522/f9yx.jpg

Desktop: http://imageshack.us/a/img821/8189/r51l.jpg

Code: pastebin(dot)com/keVyt55q

  • 3
    Without seeing the code, nobody will be able to help you. – derhass Aug 16 '13 at 19:35
  • 1
    I think this might not be a code problem, because it works completely fine in one machine... – Felipe Ribeiro R. Magalhaes Aug 16 '13 at 19:40
  • 2
    That observation does in no way eliminate the possibility of bugs. There are thousands of ways to achieve such behavior. Sure, it does not have to be an issue of your code, could be a problem with the drivers, etc. But how should we know? – derhass Aug 16 '13 at 19:46
  • 1
    Added the code. Sorry for the (dot), I can't post more than two links because of my low reputation ¬¬. – Felipe Ribeiro R. Magalhaes Aug 16 '13 at 19:54
  • 1
    Why are people voting down my question? Seriously, you guys have nothing better to do? It's a pain in the *** to post things here with this low reputation that I have, can't put images, more links, etc. and you still vote down my question... – Felipe Ribeiro R. Magalhaes Aug 16 '13 at 23:53

1 Answers1

3

Well, here's the problem:

 GLfloat especularidade[COORDHOMO] = {10.0, 10.0, 10.0, 1.0};//<------here
 GLint especMaterial = 6000;

 glMaterialfv(GL_FRONT, GL_SPECULAR, especularidade);
 /* Define a concentração do brilho sobre os objetos */
 glMateriali(GL_FRONT, GL_SHININESS, especMaterial);

specular color is the same as every other color. Every component is supposed to be within 0.0..1.0 range if you use floats. Also it is possible that shininess is also too high, it is supposed to be within 0..128.0 range, and I'd definitely use float there glMaterialf(GL_FRONT, GL_SHININESS, 25.0) or something.

Either your notebook or your desktop computer has non-compliant OpenGL driver. Fixed-function OPenGL is supposed to clamp results of lighting calculations to 0.0..1.0 range (which is the reason why fixed-function textured opengl scene might appear dim). Your desktop computer doesn't do that. Hence the bright white scene.

P.S. It is also strongly recommended to use english names for functions and variables. Well, at least if you want to get help with your code later.

SigTerm
  • 26,089
  • 6
  • 66
  • 115
  • I do not think that is the only problem. I tracked down the order in which vertex colors are assigned versus when GL_COLOR_MATERIAL is enabled, and `inicializa (...)` should actually be called AFTER setting up the lighting, because otherwise `glColor (...)` should not be tracking material color. I think the desktop has a compliant driver, and the notebook does not. – Andon M. Coleman Aug 16 '13 at 20:45
  • @AndonM.Coleman: You're free to write your own answer. If I remember correctly, OpenGL shouldn't have "overbrightening" of any kind. It shouldn't be possible, but it happens in his example. The first thing that comes to mind is specular going nuts. When you write shaders, you can get similar effect if you set specular power too low, or specular color too high. Hard to tell which one is the reason of this particular problem, though... – SigTerm Aug 16 '13 at 20:52
  • @AndonM.Coleman that doesn't really matter; you draw the image after setting up the lighting. Generating the lists shouldn't have an effect on that. Otherwise this would mean that to change the lighting you'd have to recreate the lists. SigTerm is right, your specular is borked. – PeterT Aug 16 '13 at 20:55
  • Yeah, you're right. I have not used display lists in >10 years. I forgot how they worked for a minute; I thought that `glBegin (...)` / `glEnd (...)` pairs used the state machine at the time of compilation for some reason. – Andon M. Coleman Aug 16 '13 at 21:11
  • 1
    Thanks, this fixed my problem. I know english names is better, but this project is being built on top of a source our teacher gave us, and these names were chosen by him, and it would be too much work changing every var name ;) Thanks once more guys! – Felipe Ribeiro R. Magalhaes Aug 16 '13 at 22:41