rotating a user-defined shape

Actually there is a Library for doing Extrusions and other neat things in OpenGL. Its called GLE and you can find it here:
http://www.linas.org/gle/index.html

Writing your own simple extrusion function without capping would probably be easier than compiling and using the library, but it has some nice features.

:smiley: Everybody should read the Red Book, and then the Blue Book. Mine is from 1993…

OK I will try to write my own then.

Thanks!

OK I have my CapAndExtrude function made and it works.

Changed “zoom out” to glScalef(.1,.1,.1); and this works great as my rotation now seems as though it is happening about the centroid (no “orbiting”).

My initial display of my beam is face on, but still receeds to a vanishing point.

I think I want this initial presentation to be a true face-on view (showing cross-section only).

Any ideas as to why this is happening and how I can correct it?

Originally posted by mmsgl:
My initial display of my beam is face on, but still receeds to a vanishing point.

Hmm, not sure what you are saying, but this could be because of no depth sorting (enable the depth buffer). The extruded faces seem to be drawn on top of the cap…
With depth enabled, the OpenGL renderer determines if a polygon is in front or behind another polygon.

Just to clarify, depth testing works at the fragment level, which is much finer granularity than polygon level.

if you want to use depth testing:

 
glEnable(GL_DEPTH_TEST); //enable it
glDepthMask(GL_TRUE); //enable writing to depth buffer  

I’m not sure this is the problem though (you would have seen pretty bad artifacts without this).

Are you drawing your beam with its center at the center of the flange?

if you use the center of the flange as the center and render that at the world origin you should get a true cross section view (i.e. you won’t see that the cross section has any depth).

perhaps you can have a toggle button that switches the render mode from 3D Perspective to a true cross-section view (where you set the depth of the flange and webs to 0).

I have taken my origin (0,0,0) at the center of gravity of the 3D shape.

ie in the x-y plane, my origin is in the centre of the web both vertically and horizontally, and in the z direction it is half way down the length of the beam.

I think this correct because when I rotate it in any of the three directions there is no “wobble”, but a rotation that seems natural.

I know this must be very confusing, because I am not using the correct terminology yet as I still don’t know it.

If I understand you correctly however, this “receeding look” is because my shape has depth, and there is no way around this other than to make the depth = 0 if I want a true end view. I think I can do that.

I thought it might have something to do where the camera was positioned.

It probably does have something to do with where the camera is positioned. If your object is positioned so that the direction extrusion is parallel to the cameras forward vector and the object has a flat front you should see a flat view.

For example a cube with data points
(-1,-1,1),
(1,-1,1),
(1,1,1),
(-1,1,1),
(-1,-1,-1),
(1,-1,-1),
(1,1,-1),
(-1,1,-1)

appears to be a square if viewed with the camera at
(0,0,3) looking along the vector (0,0,-1).

Yeah, but the problem here is that he also has two ‘webs’ (is that the proper lingo mmsgl?) at both the top and bottom of the flange that are positioned not directly in front of the camera.

since the camera’s ‘forward’ vector isn’t perpendicular to the front faces of these objects you’ll notice their depth.

Yeah, but the problem here is that he also has two ‘webs’ (is that the proper lingo mmsgl?) at both the top and bottom of the flange that are positioned not directly in front of the camera.
You have it backwards, there are two flanges (top & bottom horizontal members) and 1 web (vertical member) :smiley:

since the camera’s ‘forward’ vector isn’t perpendicular to the front faces of these objects you’ll notice their depth.
I have been busy reading (and trying to absorb) some of the material in the “Redbook” you referenced me to.

Still not grasping camera’s ‘forward’ vector so I could see if it somehow relates to:

If your object is positioned so that the direction extrusion is parallel to the cameras forward vector and the object has a flat front you should see a flat view.

A camera’s orientation is defined by 2 vectors:
the ‘Look At’ vector and the up vector.

The look at vector (referred to by FireCat as the ‘forward’ vector) is the vector that points straight out of the lens.

The up vector is used to define the orientation of the camera’s object space coordinate system.

OK almost solved! :smiley:
I added a message box before this call:

…appears to be a square if viewed with the camera at
(0,0,3) looking along the vector (0,0,-1).
When I originally put this code together it was cut & paste from a number of samples, and it is only now that I have to start adjusting settings etc, that I am actually learning the individual functions.

It’s important to know how the OpenGL “camera” or “eye” works.
This is my definition:
Since the camera has no geometric data (triangles, materials, etc.) it cannot be translated or rotated. In OpenGL the camera is always (!!!) at the center of the global coordinate system.
When people say, “position the camera at 2,1,-3”, in OpenGL you really translate all the scene data to -2, -1, 3. The camera is not changed.
The GluLookAt function, for example, applies a rotation and a translation which will affect all the following geometric calls.
Without using GluLookAt() the camera is at 0,0,0 and is looking down the positiv z-axis.

The GluPerspective() or GluOrtho2D() functions affect the perspective view of the camera - like using the zoom on your photocamera.

I’ve read up on the gluPerspective function and decided none of the parameters were causing this “receeding view”.

I changed all the parameters anyways (individually) just in case, and other than changing the view angles, and distance from object, the “receeding view” remained.

I am posting my code in the hopes that someone can see what is happening and help me out.
(I’ve tried to figure it out myself, but I am honestly stuck)

The code below is complete and will build in an empty VC++ project.

edit
The code tags seems to have deleted all the blank lines between functions, etc.
It doesn’t look this confusing in my code editor.

#include <windows.h>					// must include this before GL/gl.h 
#include <GL/gl.h>						// OpenGL header file 
#include <GL/glu.h>						// OpenGL utilities header file 
#include <stdio.h>

#pragma comment(lib, "opengl32.lib")	// This is our basic software OpenGL library
#pragma comment(lib, "glu32.lib")		// This is our glu32 library

enum
{ 
	PAN = 1,							// pan state bit 
    ROTATE,								// rotate state bits 
    ZOOM								// zoom state bit 
};


HDC hDC;								// device context 
HPALETTE	hPalette	= 0;			// custom palette (if needed) 
GLfloat		trans[3];					// current translation 
GLfloat		rot[2];						// current rotation 
bool		keys[256];
GLfloat		zoom		= 0.0f;	


GLfloat Vertex[2][12];
GLfloat Length;

LONG WINAPI WindowProc(HWND, UINT, WPARAM, LPARAM);
HWND CreateOpenGLWindow(char* , int, int, int, int, BYTE, DWORD);
void init();
void display();
void reshape(int, int);
static void update(int, int, int, int, int);

static void GenerateCrossSection();
static void GenerateBeam3D();






int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
	LPSTR lpszCmdLine, int nCmdShow)
{
    HGLRC hRC;							// opengl context 
    HWND  hWnd;							// window 
    MSG   msg;							// message 
    DWORD buffer = PFD_DOUBLEBUFFER;	// buffering type 
    BYTE  color  = PFD_TYPE_RGBA;		// color type 

    hWnd = CreateOpenGLWindow("OpenGL", 0, 0, 256, 256, color, buffer);
    if (hWnd == NULL)
	exit(1);

    hDC = GetDC(hWnd);
    hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC, hRC);

    init();

    ShowWindow(hWnd, nCmdShow);

    while(GetMessage(&msg, hWnd, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
    }

    wglMakeCurrent(NULL, NULL);
	ReleaseDC(hWnd,hDC);  
	wglDeleteContext(hRC);
    DestroyWindow(hWnd);
    if (hPalette) DeleteObject(hPalette);

    return msg.wParam;
}

LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ 
    static PAINTSTRUCT ps;
    static GLuint    state   = 0;			// mouse state flag 
    static int omx, omy, mx, my;

    switch(uMsg)
	{
		case WM_PAINT:
			display();
			BeginPaint(hWnd, &ps);
			EndPaint(hWnd, &ps);
			return 0;
		case WM_CREATE:
			GenerateCrossSection();	
			return 0;
		case WM_SIZE:
			reshape(LOWORD(lParam), HIWORD(lParam));
			PostMessage(hWnd, WM_PAINT, 0, 0);
			return 0;
		case WM_CHAR:
			switch (wParam)
			{
				case 27:				// "ESC" key 
					PostQuitMessage(0);	// Quit
					break;
				case 65:				// "A" key
					zoom +=0.05f;		// Zoom In
					PostMessage(hWnd, WM_PAINT, 0, 0);			
					break;
				case 90:				// "Z" key
					zoom -=0.05f;		// Zoom Out   
					PostMessage(hWnd, WM_PAINT, 0, 0);
					break;
			}
			return 0;
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
			SetCapture(hWnd);
			mx = LOWORD(lParam);
			my = HIWORD(lParam);
			if (uMsg == WM_LBUTTONDOWN)
				state |= PAN;
			if (uMsg == WM_RBUTTONDOWN)
				state |= ROTATE;
			return 0;
		case WM_LBUTTONUP:
		case WM_RBUTTONUP:
			ReleaseCapture();
			state = 0;
			return 0;
		case WM_MOUSEMOVE:
			if (state)
			{
				omx = mx;
				omy = my;
				mx = LOWORD(lParam);
				my = HIWORD(lParam);
				if(mx & 1 << 15) mx -= (1 << 16);
				if(my & 1 << 15) my -= (1 << 16);
				update(state, omx, mx, omy, my);
				PostMessage(hWnd, WM_PAINT, 0, 0);
			}
			return 0;
		case WM_PALETTECHANGED:
		if (hWnd == (HWND)wParam)
			break;
		case WM_QUERYNEWPALETTE:
			if (hPalette)
			{
				UnrealizeObject(hPalette);
				SelectPalette(hDC, hPalette, FALSE);
				RealizePalette(hDC);
				return TRUE;
			}
			return FALSE;
		case WM_CLOSE:
			PostQuitMessage(0);
			return 0;
    }

    return DefWindowProc(hWnd, uMsg, wParam, lParam); 
} 



HWND
CreateOpenGLWindow(char* title, int x, int y, int width, int height, 
		   BYTE type, DWORD flags)
{
    int         n, pf;
    HWND        hWnd;
    WNDCLASS    wc;
    LOGPALETTE* lpPal;
    PIXELFORMATDESCRIPTOR pfd;
    static HINSTANCE hInstance = 0;

    if (!hInstance)
	{
		hInstance = GetModuleHandle(NULL);
		wc.style         = CS_OWNDC;
		wc.lpfnWndProc   = (WNDPROC)WindowProc;
		wc.cbClsExtra    = 0;
		wc.cbWndExtra    = 0;
		wc.hInstance     = hInstance;
		wc.hIcon         = LoadIcon(NULL, IDI_WINLOGO);
		wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = NULL;
		wc.lpszMenuName  = NULL;
		wc.lpszClassName = "OpenGL";

		if (!RegisterClass(&wc))
		{
			MessageBox(NULL, "RegisterClass() failed:  "
				"Cannot register window class.", "Error", MB_OK);
			return NULL;
		}
    }

    hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW |
			WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
			x, y, width, height, NULL, NULL, hInstance, NULL);

    if (hWnd == NULL)
	{
		MessageBox(NULL, "CreateWindow() failed:  Cannot create a window.",
			"Error", MB_OK);
		return NULL;
    }

    hDC = GetDC(hWnd);

    memset(&pfd, 0, sizeof(pfd));
    pfd.nSize        = sizeof(pfd);
    pfd.nVersion     = 1;
    pfd.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | flags;
    pfd.iPixelType   = type;
    pfd.cDepthBits   = 32;
    pfd.cColorBits   = 32;

    pf = ChoosePixelFormat(hDC, &pfd);
    if (pf == 0)
	{
		MessageBox(NULL, "ChoosePixelFormat() failed:  "
			"Cannot find a suitable pixel format.", "Error", MB_OK); 
		return 0;
    } 
 
    if (SetPixelFormat(hDC, pf, &pfd) == FALSE)
	{
		MessageBox(NULL, "SetPixelFormat() failed:  "
			"Cannot set format specified.", "Error", MB_OK);
		return 0;
    } 

    DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

	ReleaseDC(hWnd,hDC);
    return hWnd;
}    


void init()
{
	glEnable(GL_DEPTH_TEST);
}

void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glTranslatef(trans[0], trans[1], trans[2]);
	glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
    glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
	glScalef(.05,.05,.05);									// scale to 5%
	glTranslatef(0.0f, -0.0f, zoom);  

	GenerateBeam3D();                                       // my cap & extrude function
    
	glPopMatrix();
    glFlush();
    SwapBuffers(hDC);										// nop if singlebuffered
}

void reshape(int width, int height)
{

	glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
		MessageBox(NULL, "Pause!", "Debug", MB_OK);    
	gluPerspective(60.0, (float)width/height, 0.001, 100.0);
	glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0f, 0.0f, -3.0f);
}


static void update(int state, int ox, int nx, int oy, int ny)
{
    int dx = ox - nx;
    int dy = ny - oy;

    switch(state)
	{
		case PAN:
			trans[0] -= dx / 100.0f;
			trans[1] -= dy / 100.0f;
			break;
		case ROTATE:
			rot[0] += (dy * 180.0f) / 500.0f;
			rot[1] -= (dx * 180.0f) / 500.0f;
			#define clamp(x) x = x > 360.0f ? x-360.0f : x < -360.0f ? x+=360.0f : x
			clamp(rot[0]);
			clamp(rot[1]);
			break;
		case ZOOM:
			trans[2] -= (dx+dy) / 100.0f;
			break;
    }
}

static void GenerateCrossSection()
{
	Length=20;
	
	Vertex[0][ 0] =  7;	Vertex[1][ 0] =  9;
	Vertex[0][ 1] = -7;	Vertex[1][ 1] =  9;		
	Vertex[0][ 2] = -7;	Vertex[1][ 2] =  6;			
	Vertex[0][ 3] = -1;	Vertex[1][ 3] =  6;
	Vertex[0][ 4] = -1;	Vertex[1][ 4] = -6;		
	Vertex[0][ 5] = -7;	Vertex[1][ 5] = -6;
	Vertex[0][ 6] = -7;	Vertex[1][ 6] = -9;
	Vertex[0][ 7] =  7;	Vertex[1][ 7] = -9;		
	Vertex[0][ 8] =  7;	Vertex[1][ 8] = -6;			
	Vertex[0][ 9] =  1;	Vertex[1][ 9] = -6;
	Vertex[0][10] =  1;	Vertex[1][10] =  6;		
	Vertex[0][11] =  7;	Vertex[1][11] =  6;	
}

static void GenerateBeam3D()
{
	glBegin(GL_QUADS);
	//glBegin(GL_POLYGON);

		// Cap

			// front face
			glColor3f(0.0f,1.0f,0.0f);						// green		
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0],(Length/2));
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1],(Length/2));
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2],(Length/2));
			glVertex3f(Vertex[0][11],Vertex[1][11],(Length/2));		
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3],(Length/2));
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4],(Length/2));
			glVertex3f(Vertex[0][ 9],Vertex[1][ 9],(Length/2));
			glVertex3f(Vertex[0][10],Vertex[1][10],(Length/2));
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8],(Length/2));		
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5],(Length/2));
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6],(Length/2));
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7],(Length/2));
			
			// back face
			glColor3f(0.0f,1.0f,0.0f);						// green		
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0],-(Length/2));
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1],-(Length/2));
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2],-(Length/2));
			glVertex3f(Vertex[0][11],Vertex[1][11],-(Length/2));		
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3],-(Length/2));
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4],-(Length/2));
			glVertex3f(Vertex[0][ 9],Vertex[1][ 9],-(Length/2));
			glVertex3f(Vertex[0][10],Vertex[1][10],-(Length/2));
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8],-(Length/2));		
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5],-(Length/2));
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6],-(Length/2));
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7],-(Length/2));
		
		// extrude
			
			// top flange outside
			glColor3f(0.0f,0.0f,1.0f);						// blue
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0], (Length/2));
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0],-(Length/2));
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1],-(Length/2));
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1], (Length/2));		

			// top flange left side
			glColor3f(1.0f,1.0f,0.0f);						// yellow
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1], (Length/2));
			glVertex3f(Vertex[0][ 1],Vertex[1][ 1],-(Length/2));
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2],-(Length/2));
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2], (Length/2));				
			
			// top flange underside left
			glColor3f(1.0f,0.0f,1.0f);						// violet
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2], (Length/2));
			glVertex3f(Vertex[0][ 2],Vertex[1][ 2],-(Length/2));
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3],-(Length/2));
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3], (Length/2));				
			
			// web left side
			glColor3f(1.0f,0.5f,0.0f);						// orange
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3], (Length/2));
			glVertex3f(Vertex[0][ 3],Vertex[1][ 3],-(Length/2));
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4],-(Length/2));
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4], (Length/2));			
			
			// btm flange inside left
			glColor3f(1.0f,0.0f,1.0f);						// violet
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4], (Length/2));
			glVertex3f(Vertex[0][ 4],Vertex[1][ 4],-(Length/2));
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5],-(Length/2));
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5], (Length/2));			

			// btm flange left side
			glColor3f(1.0f,1.0f,0.0f);						// yellow
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5], (Length/2));
			glVertex3f(Vertex[0][ 5],Vertex[1][ 5],-(Length/2));
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6],-(Length/2));
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6], (Length/2));		

			// btm flange outside
			glColor3f(0.0f,0.0f,1.0f);						// blue
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6], (Length/2));
			glVertex3f(Vertex[0][ 6],Vertex[1][ 6],-(Length/2));
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7],-(Length/2));
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7], (Length/2));
			
			// btm flange right side
			glColor3f(1.0f,1.0f,0.0f);						// yellow
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7], (Length/2));
			glVertex3f(Vertex[0][ 7],Vertex[1][ 7],-(Length/2));
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8],-(Length/2));
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8], (Length/2));
			
			// btm flange inside right
			glColor3f(1.0f,0.0f,1.0f);						// violet
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8], (Length/2));
			glVertex3f(Vertex[0][ 8],Vertex[1][ 8],-(Length/2));
			glVertex3f(Vertex[0][ 9],Vertex[1][ 8],-(Length/2));
			glVertex3f(Vertex[0][ 9],Vertex[1][ 9], (Length/2));

			// web right side
			glColor3f(1.0f,0.5f,0.0f);						// orange
			glVertex3f(Vertex[0][ 9],Vertex[1][ 9], (Length/2));
			glVertex3f(Vertex[0][ 9],Vertex[1][ 9],-(Length/2));
			glVertex3f(Vertex[0][10],Vertex[1][10],-(Length/2));
			glVertex3f(Vertex[0][10],Vertex[1][10], (Length/2));

			// top flange inside right
			glColor3f(1.0f,0.0f,1.0f);						// violet
			glVertex3f(Vertex[0][10],Vertex[1][10], (Length/2));
			glVertex3f(Vertex[0][10],Vertex[1][10],-(Length/2));
			glVertex3f(Vertex[0][11],Vertex[1][11],-(Length/2));
			glVertex3f(Vertex[0][11],Vertex[1][11], (Length/2));

			// top flange right side
			glColor3f(1.0f,1.0f,0.0f);						// yellow
			glVertex3f(Vertex[0][11],Vertex[1][11], (Length/2));
			glVertex3f(Vertex[0][11],Vertex[1][11],-(Length/2));
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0],-(Length/2));
			glVertex3f(Vertex[0][ 0],Vertex[1][ 0], (Length/2));

    glEnd();
}

Originally posted by mmsgl:
I’ve read up on the gluPerspective function and decided none of the parameters were causing this “receeding view”.
Have you also looked at the gluOrtho2D function that def mentioned? The “receding” look you’ve described sounds exactly like perspective projection - the way we see things in the real world. To eliminate the perspective and get both ends of an extruded object to be the same size on the screen, use gluOrtho2D.

(I hope I didn’t just jump into the middle of this thread and miss the point completely :stuck_out_tongue: )

No I haven’t looked at gluOrtho2D function that both def and Aeluned suggested yet,
because I was trying to get gluPerspective to do the same thing as per FireCat12’s post.

I will have to do as Aeluned suggested and add a toggle button that switches the render mode from 3D to 2D. I was hoping I could get it to, (as it is being rotated in the y-z plane) at 90 degree points (ie front, top, rear, bottom views), display true views (no recedding lines).
I don’t think this would look natural though, plus I would have to somehow calculate when the rotation was at a 90 degree point.

And no you didn’t miss the point, you understood exactly my problem. :slight_smile:

Originally posted by mmsgl:
I was hoping I could get it to, (as it is being rotated in the y-z plane) at 90 degree points (ie front, top, rear, bottom views), display true views (no recedding lines).
Now I’m not sure what look you’re going for. What do you mean by “true” views? To me that means views like we have in the real world, where things do look smaller when they’re farther away, but you don’t want that.

Are you trying to do something like this picture , with ortho views from the top, side, etc to get accurate measurements, and another view to see what it really looks like in real life?

I know, it’s hard for me to choose the correct words to convey my meaning, especially because I don’t know the proper OpenGL lingo.

I am using the wrong words when i say “true-view”,
I should say “orthographic” view; so I would have
6 of these (front, top, rear, bottom, left-side, right-side), any other position of the object as it is rotated should be an isometric view.

The picture you referred me to, is much more sophisticated than my project, so it is hard for me to compare.

If you run my project, I think it will be clear where my problem is; the display opens with an orthographic front view (what I want), but only because I added a MessageBox to create a “pause” in the program execution. As soon as the MessageBox is dismissed, the display draws a front view again, but this time not orthographic anymore. When the right mouse button is held and the object it rotated I am getting the views as I want (isometric).

I appreciate your patience. :slight_smile:

Yep, orthographic is the correct term :wink:

For an orthographic projection you should use glOrtho instead of gluPerspective.

gluPerspective and glFrustum are for perspective rendering, glOrtho is for orthographic rendering. Don’t use gluOrtho2D, it is used for 2D rendering…

IT WORKS!!

glOrtho is what was required!

One small problem, the back end of a long “beam” is distorted.

I’m going to guess it has something to do with the setting of my far clipping plane.

I will investigate this.

Anyway, thanks for now!

Originally posted by mmsgl:
[b]IT WORKS!!

glOrtho is what was required!

One small problem, the back end of a long “beam” is distorted.

I’m going to guess it has something to do with the setting of my far clipping plane.

I will investigate this.

Anyway, thanks for now![/b]
Alright!

But there’s nothing you can do about the distortion. If the far end of the beam weren’t distorted, it’d be smaller than the near end :stuck_out_tongue: