First I’ll describe what I’m trying to do, then what code I’m attempting to do this with, and finally what’s not working (based on what I’m doing in code)
What I’m trying to do:
I’m trying to first render a closed line loop (later the same coordinates will be used for a texture map) in orthographic mode (using glOrtho) so that I can save raster images of diamond tiles. These renderings will be saved as bitmaps and later used in an isometric game (actually dimetric since the angle is to be at 26.565 and not 30 degrees because I want rise/run == 1/2). Essentially what I’m trying to do is create a simple 3D tile renderer for isometric games.
The code (my code that is not working):
[b]// using JOGL - init
gl.glViewport(0, 0, width, height); // 100 x 100 for now
gl.glOrtho(-2, 2, -2, 2, -2, 2);
// drawing section
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// not sure why the following gives perfect w == 1/2*h
// since it should be 26.565, rotated about x
gl.glRotated( 29.699999999999996, 1.0, 0.0, 0.0);
gl.glRotated(-45.0, 0.0, 1.0, 0.0); // rotate about y
// optional for panning (diamond shape appears to move up/down
gl.glTranslated(-pan, pan, -pan);
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(1.0, 0.0, 0.0);
gl.glVertex3d(1.0, 0.0, 1.0);
gl.glVertex3d(0.0, 0.0, 1.0);
// zoom is rounded to avoid binary representational issues
// this is in the event handling section
pan -= .1;
pan = (int)(pan * 100 + 0.5) / 100.0;[/b]
- What’s not working:
Before performing any translations, the diamond shape is perfect in that it’s rise/run is 1/2. The diamond shape can be used and perfectly tiled. If however I translate, the perfectly rendered diamond is no longer perfect. The following picture shows the perfect render and the same geometry after two translations.
It’s kind of hard to see but if you zoom to the images (zoom without antialiasing in your favorite image software) you’ll see that the pixels are not lining up to a rise/run of 1/2 after a translation (the first one is fine but it’s without any sort of panning).
I’m confused because that sort of distortion shouldn’t be happening in orthogonal view (according to my limited world of understanding in OpenGL). If you have any suggestions as to how I can correct this so that no matter if I zoom in/out or if I translate (pan) left/right/up/down the pixels show the same rise/run, I would be eternally grateful!