Feeble minded newbie invades the real forum, got to do it.

if i draw any object with a
glTranslationf(0.0f,0.0f,xxx);
where the xxx is greater than 1.0f it just vanishes and i cant see it.

im useing BorlandC++ with the VCL library, so the syntax is a little weird for some people to look at.

thanks in advance for any help.

//---------------------------------------------------------------------------
#ifndef OpenGLUnitH
#define OpenGLUnitH
//---------------------------------------------------------------------------
#include <vcl\Classes.hpp>
#include <vcl\Controls.hpp>
#include <vcl\StdCtrls.hpp>
#include <vcl\Forms.hpp>
#include <gl\gl.h>
#include <gl\glu.h>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall FormResize(TObject *Sender);

private: // User declarations
HDC hdc;
HGLRC hrc;
int PixelFormat;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void __fastcall IdleLoop(TObject*, bool&);
void __fastcall RenderGLScene();
void __fastcall SetPixelFormatDescriptor();
void __fastcall SetupRC();
void __fastcall setPixelFormatDescriptor();
};
//---------------------------------------------------------------------------
extern TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

//---------------------------------------------------------------------------
#include <vcl/vcl.h>
#pragma hdrstop
#include “OpenGLUnit.h”
#include “float.h”
#include <gl\gl.h>
#include <gl\glu.h>
//---------------------------------------------------------------------------
#pragma resource ".dfm"
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent
Owner)
: TForm(Owner)
{
Application->OnIdle = IdleLoop;
_control87(MCW_EM, MCW_EM);
}
//---------------------------------------------------------------------------
float rquad;
//---------------------------------------------------------------------------
void __fastcall TForm1::IdleLoop(TObject
, bool& done)
{
done = false;
TForm1::RenderGLScene();
SwapBuffers(hdc);
}

void __fastcall TForm1::RenderGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-1.0f);
glBegin(GL_QUADS);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,1.0f,0.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(1.0f,1.0f,0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glColor3f(0.1f,0.3f,0.5f);
glVertex3f(-1.0f,-1.0f,0.0f);
glEnd();
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
hdc = GetDC(Handle);
SetPixelFormatDescriptor();
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
SetupRC();
}
void __fastcall TForm1::SetupRC()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ReleaseDC(hdc, NULL);
wglMakeCurrent(hdc, NULL);
wglDeleteContext(hrc);
}
void __fastcall TForm1::SetPixelFormatDescriptor()
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};
PixelFormat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, PixelFormat, &pfd);
}
void __fastcall TForm1::FormResize(TObject *Sender)
{
glViewport(0, 0, ClientWidth, ClientHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,ClientWidth/ClientHeight,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glDepthMask(GL_TRUE);
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
}

I think this is your problem:

glClearDepth(1.0f);

Make 1.0f a larger number.

Nope, that value gets clamped to 1 if it is higher than 1.

well, you use a identity matrix as modelview matrix, so the camera is at the origin of world coordinate, facing -z direction. with glTranslate(0.0, 0.0, +xxx), you move the object to the +z direction, thus behind the camera, so you can not see anything. maybe with 0<z<1.0, the object is not totally clipped by the view frustum, so you can still see it.

sorry, typo, it is a -#, im trying (0.0f,0.0f,-5.0f)

ive rearranged my code, still have the same problem.