- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I am using Compaq Visual Fortran 6.6C and the library f90gl (OPENGL). I would like to save pictures using the glReadPixels function. But I do not know how to declare the argument "pixels" of this function. I looked in openglglinterf.f90 and found the following function:
interface
subroutine f9y0glreadpixels(x,y,width,height,format,xtype,pixels,length)
use opengl_kinds
integer(kind=glint) ,intent(in) :: x, y
integer(kind=glsizei) ,intent(in) :: width, height
integer(kind=glenum) ,intent(in) :: format, xtype
integer(kind=glint), dimension(*), intent(out) :: pixels
integer(kind=glint) ,intent(in) :: length
end subroutine f9y0glreadpixels
end interface
But when I try to declare the same way the variable "pixels" in my program, the compiler tells me :
K:OpenGLEssaiGLEssaiGL.f90(69) : Error: This array name is invalid in this context. [IMAGE]
integer(kind=glint), dimension(*), intent(out) :: image
------------------------------------------------------------------^
K:OpenGLEssaiGLEssaiGL.f90(69) : Error: The assumed-size array must be a dummy argument. [IMAGE]
integer(kind=glint), dimension(*), intent(out) :: image
This is an excerpt of my code :
SUBROUTINE simulation()
USE opengl_gl
USE opengl_glut
integer(kind=glint), dimension(*), intent(out) :: image
INTEGER(KIND=GLint) :: x0,y0
INTEGER(KIND=GLsizei) :: l,h
x0=0
y0=0
l=100
h=100
...
...
CALL f9y0glReadPixels(x0,y0,l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END SUBROUTINE simulation
Does someone have a solution ?
Thank you
Vincent
I am using Compaq Visual Fortran 6.6C and the library f90gl (OPENGL). I would like to save pictures using the glReadPixels function. But I do not know how to declare the argument "pixels" of this function. I looked in openglglinterf.f90 and found the following function:
interface
subroutine f9y0glreadpixels(x,y,width,height,format,xtype,pixels,length)
use opengl_kinds
integer(kind=glint) ,intent(in) :: x, y
integer(kind=glsizei) ,intent(in) :: width, height
integer(kind=glenum) ,intent(in) :: format, xtype
integer(kind=glint), dimension(*), intent(out) :: pixels
integer(kind=glint) ,intent(in) :: length
end subroutine f9y0glreadpixels
end interface
But when I try to declare the same way the variable "pixels" in my program, the compiler tells me :
K:OpenGLEssaiGLEssaiGL.f90(69) : Error: This array name is invalid in this context. [IMAGE]
integer(kind=glint), dimension(*), intent(out) :: image
------------------------------------------------------------------^
K:OpenGLEssaiGLEssaiGL.f90(69) : Error: The assumed-size array must be a dummy argument. [IMAGE]
integer(kind=glint), dimension(*), intent(out) :: image
This is an excerpt of my code :
SUBROUTINE simulation()
USE opengl_gl
USE opengl_glut
integer(kind=glint), dimension(*), intent(out) :: image
INTEGER(KIND=GLint) :: x0,y0
INTEGER(KIND=GLsizei) :: l,h
x0=0
y0=0
l=100
h=100
...
...
CALL f9y0glReadPixels(x0,y0,l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END SUBROUTINE simulation
Does someone have a solution ?
Thank you
Vincent
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler needs to know the size of the array image and so you cannot use an assumed size array ( one declared with a dimension of *) unlessthe array is passed to the routine as an argument ( being present in a common block might work as well - someone else can advise you on that if needed) and the size is set at some stage further up the call tree.
I suspect you will probably want to use an allocatable array (unless all your images are the same size)anduse the allocate statement to set its size once you know it and before calling the opengl function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your response. I succeeded to declare this array and to use the glReadPixels and glDrawPixels functions (see code below).
In fact, my goal is to replace the Quickwin library in my programs with the OpenGL+GLUT libraries. But GLUT seems less powerful. For example, it seems that the user is obliged to manage the redrawing of the window when another window application is recovering the GLUT window. That is why I am interested in glReadPixels and glDrawPixels functions. Does someone has some experience and advices about this problem ?
INTEGER(KIND=GLint) :: x0,y0
INTEGER(KIND=GLsizei), parameter :: l=800
INTEGER(KIND=GLsizei), parameter :: h=600
integer(kind=GLubyte), dimension(0:l*h*3) :: image
INTEGER(4) erreur
SUBROUTINE clavier(touche, x, y)
USE opengl_gl
USE opengl_glut
CHARACTER touche
INTEGER(KIND=GLint) :: x,y
IF (touche.EQ.'A') THEN
x0=0
y0=0
CALL glReadPixels(x0,y0,l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END IF
IF (touche.EQ.'Q') THEN
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glDrawPixels(l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END IF
END SUBROUTINE clavier
In fact, my goal is to replace the Quickwin library in my programs with the OpenGL+GLUT libraries. But GLUT seems less powerful. For example, it seems that the user is obliged to manage the redrawing of the window when another window application is recovering the GLUT window. That is why I am interested in glReadPixels and glDrawPixels functions. Does someone has some experience and advices about this problem ?
INTEGER(KIND=GLint) :: x0,y0
INTEGER(KIND=GLsizei), parameter :: l=800
INTEGER(KIND=GLsizei), parameter :: h=600
integer(kind=GLubyte), dimension(0:l*h*3) :: image
INTEGER(4) erreur
SUBROUTINE clavier(touche, x, y)
USE opengl_gl
USE opengl_glut
CHARACTER touche
INTEGER(KIND=GLint) :: x,y
IF (touche.EQ.'A') THEN
x0=0
y0=0
CALL glReadPixels(x0,y0,l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END IF
IF (touche.EQ.'Q') THEN
CALL glClear(GL_COLOR_BUFFER_BIT)
CALL glDrawPixels(l,h,GL_RGB,GL_UNSIGNED_BYTE,image);
END IF
END SUBROUTINE clavier

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page