So atm im using swapbuffers in this code to refresh it:
#include "graphics.h"
void drawGridOnX(int xtotal, int ytotal);
int levelcode[400][45][100];
void decodelevelAndDraw();
void main() {
initwindow(1600, 900,"Testscreen",0,0,true,true);
int gridposx = 0, gridposy = 0, diffx = 0, diffy = 0, xtotal=0, ytotal = 0,distanceFromMouse=50;
while (1) {
setbkcolor(9);
ytotal = 0;
diffx = mousex() - gridposx;
while (gridposx < mousex()&&diffx>=70) {
gridposx += 70;
}
while (gridposx > mousex()&&diffx<=-70 + distanceFromMouse) {
gridposx =gridposx-70;
}
diffy = mousey() - gridposy;
while (gridposy < mousey() && diffy >= 70) {
gridposy += 70;
}
while (gridposy > mousey() && diffy <= -70+distanceFromMouse) {
gridposy = gridposy - 70;
}
while (ytotal < 900) {
drawGridOnX(xtotal, ytotal);
ytotal += 70;
}
if (WM_LBUTTONDOWN) {
levelcode[gridposx/70][gridposy/70][0]=1;
printf("CLICK");
}
decodelevelAndDraw();
readimagefile("question.bmp", gridposx,gridposy, 70+gridposx, 70+gridposy);
printf("gridposx:%d\tgridposy:%d\ttitlenumberx:%d\ttitlenumbery%d",gridposx,gridposy,gridposx/70,gridposy/70);
swapbuffers();
cleardevice();
}
}
void drawGridOnX(int xtotal, int ytotal) {
while (xtotal < 1600) {
rectangle(xtotal, ytotal, 70 + xtotal, 70+ytotal);
xtotal += 70;
}
}
void decodelevelAndDraw() {
int x = 0, y = 0;
while (y != 12) {
while (x != 22) {
if (levelcode[x][y][1] == 1) {
readimagefile("question.bmp", x*70, y*70, 70 + x*70, 70 + y*70);
}
x++;
}
y++;
}
}
So im using it at the end of the drawing procedure followed by a clear device. That kinda works exept when playing animations or drawing something in the backround ( that gets deleted ). I dont understand how i should use it. I know its used for double buffering and its supposed to swap out the pregenerated next frame with the old one but everywhere i looked its explained poorly. How can i use swapbuffers effectively so that i can play animations and draw stuff in the backround ( like my programm is supposed to do when the player left clicks ) without it dissapearing?
Im using the librarys from this site http://winbgim.codecutter.org/