problems with opengl

problems with opengl

Hi,

i have a subroutine contained inside a module that is supposed to get the X,Y,Z world coordinates given X,Y window coordinates but the compiler complains about the following errors:

Error: There is no matching specific subroutine for this generic subroutine call.   [GLREADPIXELS]
call glReadPixels(x, y, 1_glsizei, 1_glsizei, GL_DEPTH_COMPONENT, GL_FLOAT, winz)
-----^

rror: There is no matching specific subroutine for this generic subroutine call.   [GLGETINTEGERV]
call glGetIntegerv(GL_VIEWPORT, viewport)
-----^

Error: There is no matching specific function for this generic function reference.   [GLUUNPROJECT]
res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)
------^

Here is the code:

subroutine GetXYZfromXY ( x, y)

integer(kind=glcint), intent(in) :: x, y

integer(kind=glcint) res

real(kind=glfloat) winx, winy
real(kind=glfloat) winz
real(kind=glfloat) objx, objy, objz
real(kind=glfloat), dimension(16) :: modelMatrix, projMatrix
real(kind=glcint), dimension(4) :: viewport


winx=x
winy=y
winz=1.0_glfloat

call glReadPixels(x, y, 1_glsizei, 1_glsizei, GL_DEPTH_COMPONENT, GL_FLOAT, winz)

call glGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix)
call glGetFloatv(GL_PROJECTION_MATRIX, projMatrix)
call glGetIntegerv(GL_VIEWPORT, viewport)

res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)

return
end subroutine GetXYZfromXY

What is wrong? Did i miss something? Perhaps a wrong declared variable?

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I changed glfloat to gldouble and viewport from real to integer, now i just get the error for the glReadPixels call, i think i find out the problem but dont know how to solve it :(

glReadPixels is supposed to give me the depth (window Z coordinate) of a pixel and write it on the winz variable wich is a gldouble, but in the OpenGL reference i just read it is supposed to be a glvoid type variable. How should i handle this?

call glReadPixels(x, y, 1_glsizei, 1_glsizei, GL_DEPTH_COMPONENT, GL_FLOAT, winz)

glReadPixels from Opengl reference:

void glReadPixels(
  GLint x,         
  GLint y,         
  GLsizei width,   
  GLsizei height,  
  GLenum format,   
  GLenum type,     
  GLvoid *pixels  <----THIS
)
 

solved!

congratulations
but solved how ? (dare to share !)
and please see again my question of july 16 on page 4
davinci

Hi,

Well, i think i forgot to say i was using the f90gl libraries. I checked the documentation and find out this: "procedures that take an argument of type glvoid, wich can be one of several types have a specific routine for each of the supported types plus TYPE(GLCPTR), but are accessed through the generic name." Thus i looked in the file: interf.f90 at f90glgl and found:

f9y1glreadpixels

This is the specific subroutine for the type GL_FLOAT which i needed.

Here is the code:

subroutine GetXYZfromXY ( x, y)

integer(kind=glcint), intent(in out) :: x, y

integer(kind=glcint) res

real(kind=gldouble) winx, winy
real(kind=gldouble) winz, clipz, worldz
real(kind=gldouble) objx, objy, objz
real(kind=gldouble), dimension(16) :: modelMatrix, projMatrix
integer(kind=glcint), dimension(4) :: viewport

winx=x
winy=y

call f9y1glreadpixels(x, y, 1_glsizei, 1_glsizei, GL_DEPTH_COMPONENT, GL_FLOAT, winz)

call glGetIntegerv(GL_VIEWPORT, viewport)
call glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix)
call glGetDoublev(GL_PROJECTION_MATRIX, projMatrix)

res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)

return
end subroutine GetXYZfromXY

Beware, it gives me wrong numbers, i'm still testing it. If it works for you please let me know what you did.

Regards

Leave a Comment

Please sign in to add a comment. Not a member? Join today