Advertisement
Advertisement
| 09.15.2008 at 05:12PM PDT, ID: 23733731 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: |
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#define DEGREES_TO_RADIANS 3.14159/180.0
static GLfloat spin = 0.0;
GLfloat x, y;
void square()
{
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(-y, x);
glVertex2f(-x, -y);
glVertex2f(y,-x);
glEnd();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
square();
glutSwapBuffers ();
}
void spinDisplay () // ORIGINAL FUNCTION
{
spin = spin + 2.5;
if (spin > 360.0) spin = spin - 360.0;
x = 25.0 * cos(DEGREES_TO_RADIANS * spin);
y = 25.0 * sin(DEGREES_TO_RADIANS * spin);
glutPostRedisplay();
}
void timer_func(int n) // NEW FUNCTION
{
// Update the object positions, etc.
glutPostRedisplay();
//glutTimerFunc(n, timer_func, n);
glutTimerFunc(5, timer_func, 5);
}
void myinit ()
{
glClearColor(0.0, 0.0, 0.0, 1.0);
glColor3f(1.0, 0.0, 1.0);
glShadeModel(GL_FLAT);
}
void mouse(int btn, int state, int x, int y)
{
if (btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
glutIdleFunc(spinDisplay);
if (btn == GLUT_MIDDLE_BUTTON && state==GLUT_DOWN)
glutIdleFunc(NULL);
}
void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w,
50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0);
else
glOrtho (-50.0*(GLfloat)w/(GLfloat)h,
50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
}
/* main loop
* open window with initial window size, title bar,
* RGBA display mode, and handle input events
*/
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("double buffered");
myinit ();
glutDisplayFunc(display);
glutReshapeFunc (myReshape);
glutIdleFunc (spinDisplay);
glutMouseFunc (mouse);
glutMainLoop();
}
|
| Answered By: | mitsujin |
| Expert Since: | 08/25/2008 |
| Accepted Solutions: | 1 |
| Computer Expertise: | Intermediate |
| Education: | Edith Cowan University, Bachelor's Degree |