Archived

This topic is now archived and is closed to further replies.

Sir Eibwen

Problems linking with OpenGL

Recommended Posts

Sir Eibwen    122
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?

Share this post


Link to post
Share on other sites
vNistelrooy    140
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!"

Share this post


Link to post
Share on other sites
Sir Eibwen    122
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.

Share this post


Link to post
Share on other sites