# glRotatef()

**URL:** <https://community.khronos.org/t/glrotatef/14062>\
**Category:** OpenGL: Basic Coding\
**Created:** [December 14, 2002, 11:48am UTC](https://community.khronos.org/t/glrotatef/14062 "2002-12-14T11:48:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![simmosn](https://community.khronos.org/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@simmosn](https://community.khronos.org/u/simmosn)\
**Post date:** [December 14, 2002, 11:48am UTC](https://community.khronos.org/t/glrotatef/14062/1 "2002-12-14T11:48:00Z")

</div>

when i use the following to rotate it works:  
glRotatef(45.0, 0.0, 0.0, 1.0);

however, when i rotate in any of the other axies, nothing. ie the following doesn’t do anything:  
glRotatef(0.0, 0.0, 45.0, 1.0),

---

<div class="post-metadata">

**Author:** ![Brian\_Jones](https://community.khronos.org/letter_avatar_proxy/v4/letter/b/41988e/32.png) [@Brian\_Jones](https://community.khronos.org/u/Brian_Jones)\
**Post date:** [December 14, 2002, 12:46pm UTC](https://community.khronos.org/t/glrotatef/14062/2 "2002-12-14T12:46:00Z")

</div>

> Originally posted by simmosn:  
> however, when i rotate in any of the other axies, nothing. ie the following doesn’t do anything:  
> glRotatef(0.0, 0.0, 45.0, 1.0),

The first argument specifies how many degree you want to rotate around an axis. The following three argument specifiy the x, y, z axis to rotate, respectively. In that statement, you’re rotating the y and z axis 0 degrees. Thats why you don’t see any change. Also, the last three parameters are clamped to the range of [0, 1].

---

<div class="post-metadata">

**Author:** ![honny](https://community.khronos.org/letter_avatar_proxy/v4/letter/h/b2d939/32.png) [@honny](https://community.khronos.org/u/honny)\
**Post date:** [December 14, 2002, 12:48pm UTC](https://community.khronos.org/t/glrotatef/14062/3 "2002-12-14T12:48:00Z")

</div>

your error is this i think :

glRotatef(angle,x,y,z);

the first parameter is the angle, the others are the axis on wich you want to rotate.

if u want to rotate set the axis to 1.0

//rotate 45 on x axis  
glRotatef(45.0, 1.0, 0.0, 0.0);

//rotate 45 on y axis  
glRotatef(45.0, 0.0, 1.0, 0.0);

//rotate 45 on z axis  
glRotatef(45.0, 0.0, 0.0, 1.0);

---

<div class="post-metadata">

**Author:** ![Brian\_Jones](https://community.khronos.org/letter_avatar_proxy/v4/letter/b/41988e/32.png) [@Brian\_Jones](https://community.khronos.org/u/Brian_Jones)\
**Post date:** [December 14, 2002, 12:51pm UTC](https://community.khronos.org/t/glrotatef/14062/4 "2002-12-14T12:51:00Z")

</div>

Do something like this:  
void Render()  
{

glClear(GL\_COLOR\_BUFFER\_BIT);  
glLoadIdentity();  
static float angle; // initializes angle to 0.0f

glRotatef(angle, 0.0f, 1.0f, 1.0f); // Rotate around the y and z axis.

glTranslatef(0.0f, 0.0f, -100.0f);

DrawSomeCube();

angle++;

if(angle \>= 360.0f)  
angle = 0.0f;

glFlush();  
}

---

<div class="post-metadata">

**Author:** ![simmosn](https://community.khronos.org/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@simmosn](https://community.khronos.org/u/simmosn)\
**Post date:** [December 14, 2002, 1:18pm UTC](https://community.khronos.org/t/glrotatef/14062/5 "2002-12-14T13:18:00Z")

</div>

thanks for your help. i was being a bit thick, but all part of the learning process

---

<div class="post-metadata">

**Author:** ![Thushar](https://community.khronos.org/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Thushar](https://community.khronos.org/u/Thushar)\
**Post date:** [February 5, 2021, 1:34pm UTC](https://community.khronos.org/t/glrotatef/14062/6 "2021-02-05T13:34:55Z")

</div>

Hello,  
I need to rotate in y axis from +15 degree to -15 degree  
how to do that  
gl.glRotatef(mAngleY, 0, 1, 0);
