Issue overlaying two arms for robot manipulator

Hello anybody,

I have a (hopefully) very simple question to ask.

I have an assignment were I have to build a 3 joint (2 arm) robot manipulator, I’ve done all coding and all the maths etc works fine. I’m using fltk to provide all the opengl libraries I need. Each arm is drawn into a seperate window.

When I try to view the final product in an opengl window I can only see 1 arm (not both, due to seperate windows… because each arm has to have different glrotates and gltranslates performed on it).

If anyone can help me to ‘overlay’ these two windows ontop of each other it would be great. I assume this is relatively simple stuff, my opengl knowledge is very low.

Thanks in advance


p.s I have attached my cpp code (in txt format) for your viewing pleasure…

Me again,

I tried to click on my txt file, thats handy.

If you need the cpp i can email…

thanks again


instead of rendering into two separate windows, either render both arms to the same window (saving the modelview matrix between rendering each arm), or use a separate viewport to split the screen (like you see on Playstation with multiplayers)


I have got both windows running in the kind of playstation mode at the moment, i’m pretty novice but my code firstly transforms an identity matrix then draws…

void arm_box::draw()
if (!valid()) {

glDepthRange(0.0f, 1.0f);

gl_font(FL_HELVETICA_BOLD, 16 );


with drawing done here…

void drawbase() {

glColor3ub(0,0,255); v3f(v0); v3f(v1); v3f(v2); v3f(v3); //BOTTOM OF BASE

glColor3ub(0,0,255); v3f(v4); v3f(v5); v3f(v6); v3f(v7); //TOP OF BASE

… and so on for all the vertices, how do i save the ‘modelview’ matrix in this case?

p.s the main code continuously calls redraw()

use either glpushmatrix with glpopmatrix, or use your own matrix (16 floats) to save the modelview matrix:

glGetFloatv(GL_MODELVIEW_MATRIX, @save)

and you can restore with

glLoadMatrixf (@save)

Using the latter is more flexible, So the program flow may go something like this:

Save modelview
draw arm in viewport 1
restore modelview
draw arm 2 in viewport 2
restore modelview

…what this leads upto is the fact that you should already know what the modelview matrix should be at anyone time. After all you did create it. Therefore you can be more efficient by not having to save the modelview matrix at the start of every frame if you use a variable to track what the value is supposed to be. Instead every frame begins with a glLoadMatrix. In this way you are applying your ‘camera’ to the scene.

The next thing is to remove the glloadidentity from the start of the arm_box::draw method.
This resets the ‘camera’ back to the default. That’s OK as long as you always want to draw to a known and fixed position right infront of the camera. However, should you wish to add a moving camera to the scene and pan,zoom and strafe then this will not work. The draw code should just use the camera as is - ie leave the modelview matrix intact.