Advertisement

Newbie Questions

Started by December 16, 2004 03:14 PM
4 comments, last by BangorRipper 19 years, 11 months ago
Hi guys, a couple of simple ones for you:- 1. is there any way that i can change how far back i can place my models without them suddenly dissapearing as the point of my game is that they come closer and closer but i want them to start pretty far back. 2. how can i make it so that my models dont really get so small even when i put them in the distance, i want them to start pretty far away and i want them to come really close but i dont want them to be too small when they are in the distance if its possible. thanks everyone :)
I can answer your first question, but I'm not sure of what you mean in the second one.
To set the distance of the far-clipping plane (is this the right name?) you have to change the last value passed to gluPerspective() in your initialization code.

About the big/small models: if they're too small for you, it means they're too far away.
If they were closer they would appear larger (that's what perspective is all about).
Advertisement
thanks for the reply, much appreciated. i would like it if the models were not so small when they are in the distance, maybe if they could keep their size wherever they are in the distance, see i'm making a space invaders game and it looks silly when the aliens are really really small in the distance.
thanks everyone
If you don't want the enemies to be bigger or smaller as you get nearer and farther than essentially you don't want perspective mode. What you want is 2D mode, or Ortho mode in OpenGL.
Well my game is 3d so does that mean i have to use ortho? is it quite easy to change? where will i implement it? sorry but i am a newbie :(
inserted the following into my code and now the models have dissappeared!!! :(
//GL11.glOrtho(0.0f,Display.getDisplayMode().getWidth(),Display.getDisplayMode().getHeight(),0.0f,-1.0f,1.0f);

private void initGL() {
GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping
GL11.glShadeModel(GL11.GL_SMOOTH); // Enable Smooth Shading
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
GL11.glClearDepth(1.0); // Depth Buffer Setup
GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
GL11.glLoadIdentity(); // Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(45.0f,(float) Display.getDisplayMode().getWidth() /
(float) Display.getDisplayMode().getHeight(),0.1f,100.0f);

// ortho view
//GL11.glOrtho(0.0f,Display.getDisplayMode().getWidth(),Display.getDisplayMode().getHeight(),0.0f,-1.0f,1.0f);

GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix

// Really Nice Perspective Calculations
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}

This topic is closed to new replies.

Advertisement