Re: Help with Pointers

new topic     » goto parent     » topic index » view thread      » older message » newer message

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..

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu