Problems linking with OpenGL

Started by
1 comment, last by Sir Eibwen 19 years, 10 months ago
Unaware that glColor*ub would allow colors to be entered in hex, I wrote a simple function to convert hex to floats: void glColor3fRGB(int r,int g,int b) { glColor3f((float) r/255,(float) g/255,(float) b/255); } Which worked as expected within the source, but when linked it always rendered the object green. Since learning of glColor4ub, I wrote another seemingly simple function to be able to convert alpha in percent to hex: void glColor4uba(int r,int g,int b,float alpha) { glColor4ub(r,g,b,alpha*255); } Which also worked when included within the source itself, but when linked, all my alpha''d objects were no longer rendered. I''m curious as to whether this is a GL problem, or perhaps something else?
Advertisement
quote:Original post by Sir Eibwen
I''m curious as to whether this is a GL problem, or perhaps something else?


No it isn''t a OpenGL problem.
This should have been posted in the OpenGL forum.


"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
quote:Original post by CPPMaster Poppet
No it isn''t a OpenGL problem.
This should have been posted in the OpenGL forum.


Unless I''m mistaken that''s a contradiction. Either I''ve an OpenGL problem, which is doubtful as the functions work as coded within the source, or a programming problem, or perhaps something else entirely -- hence the thread.

Though to my knowledge I''ve linked the function properly:

test.c -- program source
function.c -- function source
test.h -- header file containing function declaration (included in test.c)

$ cc -c function.c
$ cc test.c function.o -o test -lglut

It compiles without warnings, but it renders as described above.

This topic is closed to new replies.

Advertisement