Extension problem (narrowed)

I have been playing around with the extension wrapper and I feel like I am missing something. When I add the following code to Alpha.hs: foreign import stdcall unsafe "dynamic" dyn_glBlendEquationEXTbogus :: Graphics.Rendering.OpenGL.GL.Extensions.Invoker (GLenum -> IO ()) myBlendEquation2 :: GLenum -> IO () myBlendEquation2 val = do ptr <- getProcAddress "EXT" "glBlendEquationEXT" putStr ("Address of glBlendEquationEXT: " ++ (show ptr) ++ "\n") (dyn_glBlendEquationEXTbogus ptr) val things work ok (I replace the action in blendEquation by a print so that blending is enabled without glBlendEquation to be called through the HOpenGL wrapper, and then I call myBlendEquation2 in the keyboard callback to toggle between equations). If I just move that code unchanged into PerFragment.hs, modifying it so that the functions are exported, and importing it explicitely in Alpha.hs, I get an access violation upon calling myBlendEquation2. Am I missing a GHC flag or functionnality to guide the loading of dynamic bits of code ? How does the program know which dll to load ? Yann P.S. The code of my wrapper is a bit different from the one in HsOpenGLExt.h, I was wary of the unsafePerformIO in there, I hope the difference is irrelevent. If it is, tell me why. (I know there is a loss of generality, but for the momment I am trying to just get blendEquation to work)

Yann Morvan wrote:
I have been playing around with the extension wrapper and I feel like I am missing something. [...]
Me too... :-( Some months ago the extension mechanism definitely worked on WinDoze, but I haven't tried this for a long time. Is there anybody on this list with a GHC from HEAD on WinDoze who can comment on this issue? I'll try this for myself, but I'm currently quite busy with my "real" job, so don't hold your breath for this...
I was wary of the unsafePerformIO in there, I hope the difference is irrelevent. If it is, tell me why. [...]
The unsafePerformIO is a performance hack, ensuring that for any extension entry is only queried once, not for any call. Technically this is a bit incorrect, because queries for an extension entry might depend on the current OpenGL context (of which there could be many), but unless you use a multihead configuration I'm not aware of any driver actually returning different addresses in different contexts. Perhaps I'll revise this hack some day... Nevertheless, this doesn't seem to be the cause of your problem, because you use getProcAddress correctly. Cheers, S.
participants (2)
-
Sven Panne
-
Yann Morvan