Re: OpenGl again.
- Posted by Paul Martin <twilight at WCC.NET> Apr 14, 1999
- 414 views
Hello Ralf >Paul, everybody wants good working OpenGL routines, but the kind of information you provide is limited. That is because the information it returns is limited. >Most memory addresses are dynamically assigned and have little meaning to others. You should at least bring the crash down to >one statement, and then, try to vary the values going to that statement. Unfortunately, I've traced it down to a GLUT (a dll) routine "glutMainLoop()" that is similar to "WinMain()" in Win32lib.ew. GLUT then makes calls to two of my functions via call-backs, which is expected, and then bombs (not expected). In the demo program that is a ported from an example written in C, does not explicitly set the call backs that I'm not using to NULL. Could this be a problem? The reason I asked is because further research on the error I found that Windows is saying that the code attempts to call a function through a pointer that has never been explicitly initialized. I've attempted to set all of the ones that I do not use to NULL, and I've tried sending them to a "do nothing" function, and it still bombs. >Read some more documentation, and if everything fails, >post to an OpenGL group (if the error is really being caused by an OpenGL-DLL call) I have read tremendous amounts of information on OpenGl and GLUT. Frankly the authors of OpenGL and GLUT never thought of someone attempting to write a wrapper for it in Euphoria. So as it goes there is no information on the subject. Posting my problem to a OpenGL group occurred to me, but what are the odds that someone who writes software for OpenGl would be familar with Euphoria? >When the error is caused by exw.exe, Robert should be able to help you. I guess since I cannot prove the origins of the error, and he's busy with Euphoria 2.1, his help has been minimal. >When the error is caused by you own direct memory manipulation routines, just post the code or try to run if with safe.e rather >than with machine.e I have run my routines with safe.e and it does not report any errors. I use only use direct memory routines in two places; when I have to pass the command line parameters to GLUT, and when I have to pass a string to GLUT; the rest are direct calls. I use the following routines for that: >global sequence free_stuff >free_stuff={} > >----------------------------------------------------------------------------- >-- This routine handles the command line for glut and returns a sequence >-- that has a pointer to the address where the number of elements in the >-- command line are, and a pointer to an array that contain the actual >-- elements. >-- Thanks to Mathew Hounsell and Daniel Berstein for helping pointing me >-- in the right direction for this routine. >----------------------------------------------------------------------------- >global function handle_comm_line() >atom string, array_len, array_ad >integer len >sequence cmd >cmd = command_line() >cmd = cmd[2..length(cmd)] -- actually wants the name of the program >len = length(cmd) >array_ad = allocate ((len)*4) >free_stuff= append(free_stuff,array_ad) -- so I can free it later >for i = 1 to len do > string = allocate_string(cmd[i]) > free_stuff = append(free_stuff,string) > poke (string,cmd[i] & 0) > poke (array_ad+((i-1)*4), int_to_bytes(string)) >end for >array_len = allocate(4) >free_stuff = append(free_stuff,array_len) >poke (array_len, int_to_bytes(len)) >return {array_len, array_ad} >end function >---------------------------------------------------------------------------- >-- This is nifty routine that will free up all the memory that got >-- allocated. >---------------------------------------------------------------------------- >global procedure free_all() >for i=1 to length(free_stuff) do > free(free_stuff[i]) >end for >end procedure For the strings this is typical: >global function glutCreateWindow(sequence title) --(const char *title) > atom mem > mem = allocate_string(title) > poke(mem,title & 0) > return c_func( glut_CreateWindow,{mem}) > free(mem) >end function If you see errors, by all means point them out. Thanks Paul Martin