PDA

View Full Version : how can I make solid and wire frame cube ?



alex2
04-06-2011, 08:27 AM
how can I make solid AND wire frame cube ?

mobeen
04-06-2011, 08:29 AM
if u can use glut call glutSolidCube(1) for solid and glutWireCube(1) for wire unitcube

McLeary
04-06-2011, 08:31 AM
If you wanna draw your entire scene in wireframe you can use



glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );


before your draw calls.

alex2
04-06-2011, 08:47 AM
Hm... I am fighting with cube - left side must be always in the same place and right side can go up or down like in train or like in arm - my previous subject - so now I have found that code - two cubes, one has got angle 45 degrees and second - 45 degrees:


glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glutWireCube (1.0);
glPopMatrix();

glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (-45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glutWireCube (1.0);
glPopMatrix();


Result: http://img101.imageshack.us/i/75891671.jpg/ - this is what I need - figure < but it must be also solid so I have changed code:



glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef(0.02, 1, 0.02);
glutSolidCube(50);
glPopMatrix();

glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (-45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef(0.02, 1, 0.02);
glutSolidCube(50);
glPopMatrix();


but the final result is: http://img225.imageshack.us/i/57953116.jpg/
left side first cube is in one place, and left side second cube is in different place - why ? It is figure X and I want figure < like previous.

mobeen
04-06-2011, 09:02 AM
What do u get if u just replace the glutWireCube to glutSolidCube in the first code like this.


glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glutSolidCube (1.0);
glPopMatrix();

glPushMatrix();
glTranslatef(0, 0, -70.0f);
glTranslatef (-1.0, 0.0, 0.0);
glRotatef (-45, 0.0, 0.0, 1.0);
glTranslatef (1.0, 0.0, 0.0);
glPushMatrix();
glScalef (2.0, 0.4, 1.0);
glutSolidCube (1.0);
glPopMatrix();

alex2
04-06-2011, 09:50 AM
Interesting - I have got that what I wanted - figure <, but when I have changed:


glutSolidCube (1.0);


to



glutSolidCube (50.0);


I have got figure X - what can I do ?

McLeary
04-06-2011, 10:05 AM
Why 50.0 instead of 1.0?

alex2
04-06-2011, 10:16 AM
I can stay glutSolidCube (1.0);
and use glScalef (15.0, 0.4, 1.0); - but the result is the same - bad