Re: Help with Pointers
- Posted by petelomax 5 days ago
- 133 views
I take it you haven't looked at the glLight() routine that comes with Phix in demo\pGUI\opengl.e, so here are the relevant bits:
-- (not that I can guarantee this works in all cases...) xglLightf = define_c_proc(opengl32,"glLightf",{C_UINT,C_UINT,C_FLOAT}), xglLightfv = define_c_proc(opengl32,"glLightfv",{C_INT,C_INT,C_PTR}), procedure gl_pokef32(atom dest, sequence data) for i=1 to length(data) do poke(dest,atom_to_float32(data[i])) dest += 4 end for end procedure constant gl_vector_buffer = allocate(128) global procedure glLight(integer light, integer pname, object params) if atom(params) then c_proc(xglLightf,{light,pname,params}) else gl_pokef32(gl_vector_buffer,params) c_proc(xglLightfv,{light,pname,gl_vector_buffer}) end if end procedure
ChatGPT was allocating a buffer but leaving it with whatever garbage was in it.
You should probably also be asking ChatGPT to make things OpenGL ES 2.0 compatible,
since that at least stands a slim chance of running in a web browser or Android/iOS,
whereas 1.1 aka the fixed function pipeline quite definitely does not.
Then again, I thought about converting this very program to ES 2.0 manually several
years ago, but shelved it, and am quietly patting myself on the back now that I've
seen what ChatGPT has output, so that may well be a step too far..