Error

Some time raise message:
“access violation at 0xbff24dd5; read of adddress 0x81c4c000
66 65 8B 01 66 48 66 83 F8 01 77 21”.

But some time works fine.
(Delphi 3.0, OpenGL, no accelerator)

What’s wrong?

ive never seen that error before, but access violation errors usually mean your trying to use memory that hasnt been allocated. look carefully through your code. im sure you will find it.

Good Luck

Originally posted by Warrior:
[b]ive never seen that error before, but access violation errors usually mean your trying to use memory that hasnt been allocated. look carefully through your code. im sure you will find it.

Good Luck [/b]

I run another OpenGL examples which I found in internet. Some time the access viotation error riases in that applications too. It’s the internal OpenGL error, because the delphi error message did not like on this error. Maybe my OpenGL configuration wrong?

Possibly yes. the only advice i can give you is to check your code again and again until you find it. if you know how to use a debugger, use it to run through the code until you get the access violation error.

Tell me please, maybe I incorrectly initialize the OpenGL? Maybe the problem in this? Under debugger this error is not raising.
Help me. This fu…ing error will make me crazy!

**** My Initialization code on Delphi ****

DC:=GetDC(Handle);
FillChar(PFD, SizeOf(TPixelFormatDescriptor), 0);
with PFD do
begin
nSize := SizeOf(TPixelFormatDescriptor);
nVersion := 1;
dwFlags:=PFD_SUPPORT_OPENGL or PFD_DRAW_TO_WINDOW or PFD_DOUBLEBUFFER;
iPixelType := PFD_TYPE_RGBA;
cColorBits := 24;
cDepthBits:= 32;
iLayerType:= PFD_MAIN_PLANE;
end;

ChosenPixelFormat := ChoosePixelFormat(DC, @PFD);
if ChosenPixelFormat = 0 then
raise Exception.Create(‘ChoosePixelFormat failed!’);

SetPixelFormat(DC, ChosenPixelFormat, @PFD);

RC := wglCreateContext(DC);
wglMakeCurrent(DC, RC);
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
c[0]:=0.5; c[1]:=0.5; c[2]:=0.5;
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, @c);

glMatrixMode(GL_PROJECTION);
glLoadIdentity;

with Scene.Camera do
gluPerspective(FOV180/pi, Width/HeightXYRatio, 10, 10000);

glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_CULL_FACE);

glFlush;
SwapBuffers(DC);
wglMakeCurrent(0,0);
ReleaseDC(Handle,DC);

**** My Paint code ****

DC:=GetDC(Handle);
wglMakeCurrent(DC,RC);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
with Scene.Camera do
gluLookAt(pos[0], pos[1], pos[2],
target[0], target[1], target[2],
Camup[0], Camup[1], Camup[2]);

glBegin(GL_TRIANGLES);
glNormal3f(…); glVertex3f(…);
glNormal3f(…); glVertex3f(…);
glNormal3f(…); glVertex3f(…);

glEnd;
glFlush;
SwapBuffers(DC);
wglMakeCurrent(0,0);
ReleaseDC(Handle,DC);


What wrong? I do not understand. Help me PLZZZZZZZZZZZZZZZZZZZZZ.

I didn’t look at the code real closely, so there might be someplace else causing the problem, but one thing I did notice is that you didn’t use DescribePixelFormat. Try using that between your ChoosePixelFormat and SetPixelFormat.