hello everyone,
I’m having an issue with my Aspect Ratio. It’s not so much that the Aspect Ratio is messed up; I fixed that. The weird thing is that after I added the Aspect Ratio correction through glOrtho(), all my present models (Cubes, mostly) became see-through.
At first I thought it was a culling issue, so I tried turning it off and even flip which side had to be culled. But that didn’t fix it either.
Then I went and checked my Depth Buffer. I turned it off and I thought it was fixed. Untill I turned the view around; The right and back faces were still see-through.
I am unable to post any links at the moment, so I won’t be able to show any visuals.
here’s my code (Delphi2010):
procedure GLContext(HandleObject: TPanel);
var
DC: HDC;
RC: HGLRC;
begin
DC := GetDC(HandleObject.Handle); // Actually, you can use any windowed control here
setupPixelFormat(DC);
RC := wglCreateContext(DC); // makes OpenGL window out of DC
wglMakeCurrent(DC, RC);
GLInit(HandleObject.Width, HandleObject.Height); // initialize OpenGL
end;
procedure GLContext(HandleObject: TForm);
var
DC: HDC;
RC: HGLRC;
begin
DC := GetDC(HandleObject.Handle); // Actually, you can use any windowed control here
setupPixelFormat(DC);
RC := wglCreateContext(DC); // makes OpenGL window out of DC
wglMakeCurrent(DC, RC);
GLInit(HandleObject.Width, HandleObject.Height); // initialize OpenGL
end;
procedure GLInit(PortWidth, PortHeight: Integer);
begin
Aspect := PortWidth/PortHeight;
glViewPort(0, 0, PortWidth, portHeight);
// set viewing projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-Aspect, Aspect, -1, 1, -1, 1);
glFrustum(-0.1, 0.1, -0.1, 0.1, 0.3, 1000);
// position viewer
glMatrixMode(GL_MODELVIEW);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glDepthRange(0.0, 1.0);
end;
So now I wonder. What could cause this? I’m hoping anyone here can help me out as I’ve been struggling with the issue for several days now to no avail. Even Google has failed me, or I have lost the skills to Google Search decently.