Adding glOrtho() makes models transparent.

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.

I managed to fix it through some more unconventional means; I just divided the xScale of my models by ‘Aspect’ and the dimensions are now the same as after ‘glOrtho()’.

Please check “glFrontFace()” function to set the right value for your 3D Models

Thanks for the reply, tdname; But even setting it to GL_CW or GL_CCW doesn’t fix the issue.
I still can’t post any images either, because I’m getting an error whenever I try to post one.

Why are you still using glFrustum() aswell as glOrtho()?
What happens if you eliminate the glFrustum()?

When I turn off flFrustum() and turn on glOrtho() I get a black screen full of nothing. So that’s a strange issue aswel.
I truly have no idea where to turn with this other than simpy dividing the xScale with the Aspect.
it looks like I can finally add URLs and Images to my posts. Here’s a few examples:
//—[With Ortho and Depth Buffer on]—\

//—[With Ortho on and Depth Buffer off]—\
//–[FRONT

//–[BACK

Are those rectangles supposed to look like cubes?

I would try using less extreme vaues in glFrustum:
e.g.
glFrustum(-1,1,-1,1, 1,100);
and not call glOthro() to see what results.

some tips:

have you searched on something like: “opengl model inside out”

some probable causes I think of are:
(1) inconsistent winding of triangles (related to where the model(s) came from)
(2) how are you moving your “camera” around: say from the front view to back view. an inappropriate transform here on the projection matrix could be a cause