You could try SDL. Its easy to install if you use Linux or Dev C++ as you can install all the files through the package manager. You then neeed to link it to your project, which can be done by adding -lSDL switch. Heres some code to set up a buffer and plot some pixels with animation:
Code:
#include "SDL/SDL.h"
#include <math.h>
#define GRAPHICS_WIDTH 256
#define GRAPHICS_HEIGHT 256
#define BITDEPTH 32
#define DEG_TO_RAD 0.0174532925
#define FRAME_LIMIT 1000 / 30 //Limit the animation to 30 frames per second
SDL_Surface *screen = NULL;
SDL_Event event;
void WritePixel(int x, int y, Uint32 col)
{
Uint32 *pix;
pix=screen->pixels+(x+y*GRAPHICS_WIDTH)*4;
*pix=col;
}
int main()
{
if(SDL_Init(SDL_INIT_VIDEO) !=0)
return 1;
screen = SDL_SetVideoMode(GRAPHICS_WIDTH, GRAPHICS_HEIGHT, BITDEPTH, 0);
if(screen == NULL)
return 1;
int x;
int quit = 0;
int anim = 0;
unsigned timer;
//This is the main loop that runs until the program ends
while(!quit)
{
//Get the start time at the begining of each loop
timer = SDL_GetTicks();
SDL_FillRect(screen, NULL, 0);
for(x=0; x<GRAPHICS_WIDTH; x++)
WritePixel(x, 128+cos(x*DEG_TO_RAD+anim)*100, 0xFFFFFFFF);
if(SDL_Flip(screen)==-1)
return 1;
//This code checks for a keypress, which signals to end the program
while(SDL_PollEvent(&event))
if(event.type==SDL_KEYDOWN)
quit=1;
//Increment animation
if(++anim > 359) anim = 0;
//This delays the program so that it does not run too fast
timer = SDL_GetTicks()-timer;
if(timer < FRAME_LIMIT) SDL_Delay(FRAME_LIMIT-timer);
}
SDL_Quit();
return 0;
}