OpenGL glLightfv parameters
Having a few problems with OpenGL's glLightfv function,
I sent:
Code:
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient)
with LightAmbient being an array of float containing { 0.5, 0.5, 0.5, 1.0 }
(edit: these values correspond to x,y,z, alpha)
and I receive error message:
"Error 1 Overloaded method 'CsGL.OpenGL.OpenGL.glLightfv(uint, uint, float*)' has invalid arguments"
using csgl.dll from Lloyd Dupont <[email protected]>, 2001
ver 1.4.1.0
All samples over the internet make the use of the array fine... so I'm having a hard time find the problem on my arguments...
thanks for helping... :(
(edit: sry if not appropriate for this topic, please move to Games and Graphics Programming)
Re: OpenGL glLightfv parameters
bump, anyone?
Found something... I just realised that the expected parameter corresponds to a pointer. This means that to pass the array of floats, I need to declare my code as "unsafe" in order for it to work since .net hides memory management... (with the garbage collector)
SO, I'm sort of new with theses unsafe methods, any help?
Re: OpenGL glLightfv parameters
remove the f at the end each values when you assign the values in the array.
Re: OpenGL glLightfv parameters
Sorry, forgot to migrate line to vb... but no that's not quite the problem, any help with unsafe methods?
Re: OpenGL glLightfv parameters
Re: OpenGL glLightfv parameters
Did you declare your array like this?
VB Code:
dim LightAmbient(3) as Glfloat = { 0.5, 0.5, 0.5, 1.0 }
Re: OpenGL glLightfv parameters
Quote:
Originally Posted by Asgorath
Unsafe only in c#
Great, uh, please move thread to Games and Graphics Programming or C#...
(Sorry I really thought it was for .net in general, and I figured vbforums has more vb fans then c# fans, so I've posted the code as vb...)
:(
I'm pretty sure my declarations are ok, the only problem is either the "unsafe method" when I add the &variableforpointer,
or it's that I'm not supposed to send an array, but rather a single float... but as I said all samples containing this function work well with an array... so I'm lost over this...!
wait, I didn't see that GLFloat part, where is this object from CsGL? I only saw PFloat and that didn't work neither...
Re: OpenGL glLightfv parameters