Hello (...)
I decided to learn sfml and OpenGL together (instead of going with glut)
The OpenGL book I'm following shows how to use glut to set up things like double buffering. (How much it is handled automatically?)
I wrote the following program as a base on which I'd be applying everything I learn about OpenGL in near future. (changing the initialize() and draw() when necessary.)
Could anyone of you review it to see if anything else is necessary ?
#include<iostream>
#include<SFML/Window.hpp>
#include<GL/gl.h>
#include<GL/glu.h>
using namespace sf;
void draw(int x);
void initialize();
int main()
{
Window app(VideoMode(320,240,32),"Manasij");
app.UseVerticalSync(true);
initialize();
int x(0);
bool running(1);
while(running)
{
Event event;
while(app.GetEvent(event))
{
if(event.Type == Event::Closed)
running = false;
if(event.Type == Event::KeyPressed && event.Key.Code == Key::P) //Pause
std::cin.get();
}
draw(x++);
app.Display();
}
return 0;
}
void draw(int x)
{
glClear ( GL_COLOR_BUFFER_BIT );
glBegin(GL_POLYGON);
glVertex3i(40+x%100,200,0);
glVertex3i(80,200,0);
glVertex3i(80,100,0);
glEnd();
glFlush();
}
void initialize()
{
glClearColor ( 1.0, 1.0,1.0, 0.0 );
glColor3f(0.0f, 0.0f,0.0f);
glPointSize(1.0);
glMatrixMode ( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D ( 0.0, (GLdouble)320, 0.0, (GLdouble)240 );
}