19 this->pixels =
nullptr;
20 this->render =
nullptr;
27 this->hdc = GetDC(hWnd);
28 this->hdcMem = CreateCompatibleDC(this->hdc);
33 this->height = height;
35 this->pixels =
new unsigned long[this->width * this->height];
47 this->pixels =
nullptr;
52 this->render =
new Render(pixels, this->height, this->width);
57 this->pixels =
nullptr;
63 GVector position(1000, 0, 0, 1);
72 this->pixels =
nullptr;
74 this->render =
nullptr;
89 this->pixels =
nullptr;
91 this->render =
nullptr;
95 void Scene::InitBitmap()
97 this->sBmInfo.bmiHeader.biSize =
sizeof(BITMAPINFO);
98 this->sBmInfo.bmiHeader.biWidth = this->width;
99 this->sBmInfo.bmiHeader.biHeight = -this->height;
100 this->sBmInfo.bmiHeader.biPlanes = 1;
101 this->sBmInfo.bmiHeader.biBitCount = 32;
102 this->sBmInfo.bmiHeader.biCompression = BI_RGB;
103 this->sBmInfo.bmiHeader.biSizeImage = 0;
104 this->sBmInfo.bmiHeader.biXPelsPerMeter = 0;
105 this->sBmInfo.bmiHeader.biYPelsPerMeter = 0;
106 this->sBmInfo.bmiHeader.biClrUsed = 0;
107 this->sBmInfo.bmiHeader.biClrImportant = 0;
109 this->sBmInfo.bmiColors[0].rgbBlue = 0;
110 this->sBmInfo.bmiColors[0].rgbGreen = 0;
111 this->sBmInfo.bmiColors[0].rgbRed = 0;
112 this->sBmInfo.bmiColors[0].rgbReserved = 0;
114 this->sBmp = CreateDIBSection(
115 this->hdc, &this->sBmInfo, DIB_RGB_COLORS, (
void**)&pixels, NULL, 0
122 WCHAR fps_buf[11] = { 0 };
123 LARGE_INTEGER sta, fin, frq;
124 QueryPerformanceCounter(&sta);
126 #pragma omp parallel for 127 for (
int i = 0; i < this->width; i++)
129 for (
int j = 0; j < this->height; j++)
131 this->pixels[j*this->width + i] = 0x00586bab;
135 #pragma omp parallel for 136 for (
int i = 0; i < 3; i++)
138 for (
int j = 0; j < this->height; j++)
140 this->pixels[j*this->width + i] = 0x00a0aacf;
148 SelectObject(this->hdcMem, this->sBmp);
149 BitBlt(this->hdc, X, Y, this->width, this->height, this->hdcMem, 0, 0, SRCCOPY);
151 QueryPerformanceCounter(&fin);
152 QueryPerformanceFrequency(&frq);
154 long double dif =
long double(fin.QuadPart - sta.QuadPart) / frq.QuadPart;
157 wsprintf(fps_buf, TEXT(
" FPS: %d"), fps);
158 TextOut(this->hdc, this->X + 25, this->height - 50, (LPCWSTR)fps_buf, 11);
164 nbrick->
color = color;
166 #pragma omp parallel for 167 for (
int vertexIndex = 0; vertexIndex < nbrick->
vertexCount(); vertexIndex++)
171 int nX = v.
X + 1. - nbrick->
center.
X + X;
172 int nY = v.
Y + 1. - nbrick->
center.
Y + Y;
173 int nZ = v.
Z + 1. - nbrick->
center.
Z + Z;
175 nbrick->
vertex[vertexIndex].X = nX;
176 nbrick->
vertex[vertexIndex].Y = nY;
177 nbrick->
vertex[vertexIndex].Z = nZ;
188 int xCenter = this->width / 2;
189 int yCenter = this->height / 2;
199 this->
slight.
X += this->width / 2;
200 this->
slight.
Y += this->height / 2;
202 for (
int brickIndex = 0; brickIndex < this->
bricks->
objects.size(); brickIndex++)
205 #pragma omp parallel for 206 for (
int vertexIndex = 0; vertexIndex < nbrick->
vertexCount(); vertexIndex++)
209 tmpVertex = tmpVertex * view;
210 tmpVertex.
X = tmpVertex.
X + xCenter;
211 tmpVertex.
Y = tmpVertex.
Y + yCenter;
213 nbrick->
svertex[vertexIndex] = tmpVertex;
216 #pragma omp parallel for 217 for (
int faceIndex = 0; faceIndex < nbrick->
facesCount(); faceIndex++)
219 for (
int i = 0; i < 3; i++)
223 nbrick->
sVNormal[faceIndex][i] = tmpN;
void run(Composite *bricks, Camera cam, Vertex light)
Define vertex consisting 3 double coordinates.
void AddBrick(Brick brick, int X, int Y, int Z, COLORREF color)
vector< vector< Normal > > VNormal
vector< vector< Normal > > sVNormal
vector< Brick * > objects