how to paint, translate and scale a cube

Hello everybody I’m working with a program written in C and I need. now I’ve used the function glutsolidcube which draws a cube centered in the point (0,0,0). I need to translate this cube and to scale it. How can I do that?
thank you all

You can use matrices to do that.
OpenGL has bulit-in matrix stack and couple of functions to manipulate it, but they are deprecated for now.
(It’s still good idea to learn some deprecated stuff, it will give You understanding of basic rendering pipeline)
read some tutorials:
nehe(outdated, but still useful):

Alfonse Reiheart started writing some up to date tutorials,
(they are not finished Yet, but basics like rotations and translations should be complete):

I need an example, I don’t have to study openGL but I just need it to build, to traslate and to scale a cube in another project.
thank you all

The functions you would need would be glTranslatef ( and glScalef ( However, understanding how these work would be beneficial to your understanding of how OpenGL works. I’m not quite sure why you don’t need to know about OpenGL if you’re currently writing a program in it, but if you’re determined, then you can just use those 2 functions.

Oh yeah, kowal: Out of curiosity, which functions are deprecated? And which functions have replaced them?

In OpenGL 3.0+ all fixed-pipeline stuff is deprecated.
This includes glTranslatef, glScalef, glRotatef, etc. The whole matrix stack, and many more (read the spec)

They are still available in compatibility profile, but if You wish to stay in core,
You should write your own matrix-manipulation routines, (or use third-party lib) and pass matrices as attributes to shaders.

Wait, but if you write your own matrix-manipulation routines, then isn’t that slower (less hardware support)? Or is glMultMatrix() not deprecated?

glMultMatrix is deprecated. Even before, it was done on the CPU by the driver.

Hm, interesting, I didn’t know that. I’ll switch to my own matrix functions now – although I checked the spec and just about all the OpenGL code I use is deprecated :smiley:

As a side note though, if matrix calculations are done outside of OpenGL, then should they be loaded in with glLoadMatrix(), or should all the vertices rendered be manually modified by the modelview and projection matrices?

Your matrices should be loaded as attributes (or uniforms, it depends) into the vertex shader.
In vertex shader You transform vertex position by projection and modelviev matrices.

In OpenGL 2.1 shaders (I do not remember GLSL version) there was special function to do this: ftransform (now also deprecated)
(matrices loaded by OpenGL matrix stack)