Board index » delphi » Generating and Deleting textures in Delphi/OpenGL

Generating and Deleting textures in Delphi/OpenGL

In my projects I have been using glGenTextures to get a texture id to refer
to. The program works fine until I come to exit and want to destroy the
texture to release memory. In the opengl.pas file the glGenTextures and
glDeleteTextures functions are not defined so I have defined them myself as
procedure glGenTextures(n: glsizei; var textures: gluint); stdcall; external
'opengl32';
procedure glDeleteTextures(n: glsizei; const textures: gluint); stdcall;
external 'opengl32';

As I said it's all fine until I try to delete the texture with a call to
glDeleteTextures(1, myid);
    when the program crashes with the message "EAccessViolation in
NVOPENGL.DLL" (I have a NVidia Graphics card). The C/C++ syntax for this
function as given by the MSDN library
(http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/...
/glfunc01_6vqr.asp) is
void glDeleteTextures(
  GLsizei n,
  const GLuint *textures
);
    Do I need to pass the address of the id not the id itself or is
something else wrong?

Hugh Waite

 

Re:Generating and Deleting textures in Delphi/OpenGL


Try this:

glGenTextures: procedure(n: GLsizei; textures: PGLuint); stdcall; external
'opengl32';
glDeleteTextures: procedure(n: GLsizei; const textures: PGLuint); stdcall;
external 'opengl32';

Jason A.

Quote
"Hugh Waite" <H...@hughwaite.freeserve.co.uk> wrote in message

news:aclc78$igq$1@news6.svr.pol.co.uk...
Quote
> In my projects I have been using glGenTextures to get a texture id to
refer
> to. The program works fine until I come to exit and want to destroy the
> texture to release memory. In the opengl.pas file the glGenTextures and
> glDeleteTextures functions are not defined so I have defined them myself
as
> procedure glGenTextures(n: glsizei; var textures: gluint); stdcall;
external
> 'opengl32';
> procedure glDeleteTextures(n: glsizei; const textures: gluint); stdcall;
> external 'opengl32';

> As I said it's all fine until I try to delete the texture with a call to
> glDeleteTextures(1, myid);
>     when the program crashes with the message "EAccessViolation in
> NVOPENGL.DLL" (I have a NVidia Graphics card). The C/C++ syntax for this
> function as given by the MSDN library

(http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/...

- Show quoted text -

Quote
> /glfunc01_6vqr.asp) is
> void glDeleteTextures(
>   GLsizei n,
>   const GLuint *textures
> );
>     Do I need to pass the address of the id not the id itself or is
> something else wrong?

> Hugh Waite

Other Threads