Mar 10
25
Next: 11. OpenGL Lighting
If you have worked with vectors before, you will know already that
scaling is simply stretching an object a certain amount.
Say we have an object, but we want it twice the height, we will
have to scale (stretch) it to twice the current height, along the y axis.
I am using:
glScalef(2, 0.5, 1);
in my display function.
If you look at the scale function on its own it takes:
The amount you want to stretch it on the:
x axis
y axis
z axis
In that order.
So I am stretching my cube, 2 times along the x axis, 0.5 times along the
y axis, and 1 time on the z axis.
So it will come out, twice as long, half as high, and the same depth.
And that is all there is to scaling, it is one of the very basic commands
in OpenGL.
If there are any problems with this code, please email me at swiftless@gmail.com
|
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. |
#include <GL/gl.h> #include <GL/glut.h> GLfloat angle = 0.0; void cube (void) { void display (void) { void reshape (int w, int h) { int main (int argc, char **argv) {
|
Related posts:
- 8. OpenGL Double Buffering
- 7. OpenGL Rotation and Translation (Version 2.0)
- 30. OpenGL Circle Drawing
- 9. OpenGL Blending
- 6. OpenGL Cube (Version 2.0)
Next: 11. OpenGL Lighting