Hi, so im pretty new to the whole c++ thing, im not sure if this is the codes fault or something i missed in gl/glut
anyway here it is
#include <glut.h>
#include "init_elements.h"
GLfloat spin=0.0;
GLshort xx = 10;
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_POINTS);
for (GLshort ii = 0; ii<=xx; ii++)
{
glVertex2f(ii,25);
}
glEnd();
glutSwapBuffers();
}
void step()
{
xx+=1 ;
if (xx==12)
{xx=0;}
glutPostRedisplay();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,512.0,512.0,0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void mouse(int button,int state,int x,int y)
{
switch(button)
{
case GLUT_LEFT_BUTTON:
if (state==GLUT_DOWN) break;
case GLUT_RIGHT_BUTTON: if (state==GLUT_DOWN) break;
}
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(512,512);
glutInitWindowPosition(100,100);
glutCreateWindow("Glut App");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMouseFunc(mouse);
glutMainLoop();
glutIdleFunc(step);
return 0;
}
it draws the first 10 pixels but it doesn’t redraw it into an animation, of sorts
basically just want a line to grow to the right, then reset and start again
i’ve also tried swapping the GLshort’s for int shorts
another thing, do i have to use GLshorts for this? or will normal int shorts work with the gl functions
sorry im pretty new to this c++ scene, its a lot more brainhurty than what i am used to
final note:
i canibalised this from an online example, just to use until i get used to the gl functions