写了一个多线程的程序但是图片无法显示(附上代码)
#include <graphics.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <thread>
void drawThread()
{
printf("drawThread start\n");
initgraph(1280, 720);
IMAGE backGround;
loadimage(&backGround, "img/background.png");
putimage(0, 0, &backGround);
BeginBatchDraw();
while (true)
{
printf("fram start ");
DWORD startTime = GetTickCount();
cleardevice();
playerLeft.drawAnim(500, 500);
FlushBatchDraw();
DWORD endTime = GetTickCount();
DWORD runningTime = endTime - startTime;
if (runningTime < 20)
Sleep(20 - runningTime);
}
EndBatchDraw();
return;
}
void logicThread()
{
printf("logicThread start\n");
while (1)
{
}
return;
}
void messageThread()
{
printf("messageThread start\n");
while (1)
{
}
return;
}
int main()
{
std::thread first(drawThread);
std::thread second(logicThread);
std::thread third(messageThread);
first.detach();
second.detach();
third.detach();
while (true)
{
Sleep(60);
}
return 0;
}