I am making a thread for my Ray-Casting engine that paints one column of the screen. However for some reason, the thread cannot execute any paint commands.
[CODE]
long WINAPI Thread(long lParam) {
//This part is just doing some calculations for the engine.
y = -30 + (DegreeChange * lParam);
long info = lParam;
distance1 = Distance(PlayerAngle + y, PlayerX, PlayerY, &BitmapColumn, &MidPoint);
distance1 = distance1 * cos(y*PI/180);
degrees = atan(64.0/distance1) / PI * 180;
height = tan(degrees*PI/180) * DistanceToProjection;
// These are the paint commands
SelectObject(bufferDC, GrayPen);
MoveToEx(bufferDC, info, 0, NULL);
LineTo(bufferDC, info, MidPoint - height);
SelectObject(Image, Texture);
StretchBlt(bufferDC, info, MidPoint - height, 1, height * 2, Image, BitmapColumn - 1, 0, 1, 64, SRCCOPY);
SelectObject(bufferDC, BluePen);
MoveToEx(bufferDC, info, MidPoint + height, NULL);
LineTo(bufferDC, info, (200 * SizeMult));
}
BufferDC is a MemDC, it is global.
Image is the same.
SizeMult is a constant. (Global)