So I made a code that shows a simple rectangle. How do I make it move using data structures? :)
CODE:
#include "Glut_Setup.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;
float P1= -5;
float P2= 2;
float P3= 5;
float P4= -2;
struct first{
float x, y, z;
}A;
struct second{
float x, y, z;
}S;
void GameScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
void show(struct first, second);
{
glPushMatrix();
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(P2, P1, 0);
glVertex3f(P2, P3, 0);
glVertex3f(P4, P3, 0);
glVertex3f(P4, P1, 0);
glEnd();
glPopMatrix();
}
glutSwapBuffers();
}
void Keys(unsigned char key, int x, int y)
{
switch(key)
{
}
}
void SpecialKeys(int key, int x, int y)
{
switch(key)
{
}
}
void Timer(int value)
{
glutTimerFunc(50, Timer, value);
glutPostRedisplay();
}
void changeSize(int w, int h)
{
float ratio = 1.0 * w / h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45, ratio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 30.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
void main(int argc, char **argv)
{
srand(time(NULL));
GLUTInit(&argc, argv);
}
Do you know what a data structure is?