Index: ddraw/glRenderer.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2016 William Feely
|
| 3 | +// Copyright (C) 2012-2017 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -600,6 +600,7 @@ |
601 | 601 | LONG_PTR winstyle, winstyleex;
|
602 | 602 | BOOL restart_cmd = FALSE;
|
603 | 603 | __int64 shaderid;
|
| 604 | + BltVertex *vertex;
|
604 | 605 | if (!inner) EnterCriticalSection(&This->cs);
|
605 | 606 | switch (cmd->Generic.opcode)
|
606 | 607 | {
|
— | — | @@ -908,7 +909,7 @@ |
909 | 910 | tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
|
910 | 911 | tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
|
911 | 912 | tmp_cmd.SetAttrib.count = 0;
|
912 | | - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
| 913 | + vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
913 | 914 | append_attrib_cmd(This, &tmp_cmd.SetAttrib, 0, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &vertex->x,
|
914 | 915 | TRUE, sizeof(MIN_STORAGE_CMD));
|
915 | 916 | if (!(cmd->Blt.cmd.flags & DDBLT_COLORFILL))
|
— | — | @@ -1168,7 +1169,7 @@ |
1169 | 1170 | tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
|
1170 | 1171 | tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
|
1171 | 1172 | tmp_cmd.SetAttrib.count = 0;
|
1172 | | - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
| 1173 | + vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
1173 | 1174 | append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[PROG_PAL256].pos, 2, GL_FLOAT, GL_FALSE,
|
1174 | 1175 | sizeof(BltVertex), &vertex->x, TRUE, sizeof(MIN_STORAGE_CMD));
|
1175 | 1176 | append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[PROG_PAL256].texcoord, 2, GL_FLOAT, GL_FALSE,
|
— | — | @@ -1303,7 +1304,7 @@ |
1304 | 1305 | tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
|
1305 | 1306 | tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
|
1306 | 1307 | tmp_cmd.SetAttrib.count = 0;
|
1307 | | - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
| 1308 | + vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
|
1308 | 1309 | append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[shaderid].pos, 2, GL_FLOAT, GL_FALSE,
|
1309 | 1310 | sizeof(BltVertex), &vertex->x, TRUE, sizeof(MIN_STORAGE_CMD));
|
1310 | 1311 | append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[shaderid].pos, 2, GL_FLOAT, GL_FALSE,
|
— | — | @@ -1322,36 +1323,77 @@ |
1323 | 1324 | glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
1324 | 1325 | }
|
1325 | 1326 | // Set viewport to window buffer
|
1326 | | - #error do viewport
|
| 1327 | + glUtil_SetViewport(This->util, viewport[0], viewport[1], viewport[2], viewport[3]);
|
| 1328 | + if (This->state.viewport.x != viewport[0] || This->state.viewport.y != viewport[1] ||
|
| 1329 | + (This->state.viewport.width != viewport[2]) || (This->state.viewport.hieght != viewport[3]))
|
| 1330 | + {
|
| 1331 | + tmp_cmd.SetViewport.opcode = OP_SETVIEWPORT;
|
| 1332 | + tmp_cmd.SetViewport.size = sizeof(SetViewportCmd) - 8;
|
| 1333 | + tmp_cmd.SetViewport.viewport.x = viewport[0];
|
| 1334 | + tmp_cmd.SetViewport.viewport.y = viewport[1];
|
| 1335 | + tmp_cmd.SetViewport.viewport.width = viewport[2];
|
| 1336 | + tmp_cmd.SetViewport.viewport.hieght = viewport[3];
|
| 1337 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
| 1338 | + }
|
1327 | 1339 | // Generate vertices
|
1328 | 1340 | if (This->ddInterface->GetFullscreen())
|
1329 | 1341 | {
|
1330 | | - This->bltvertices[0].x = This->bltvertices[2].x = (float)sizes[0];
|
| 1342 | + This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)sizes[0];
|
1331 | 1343 | This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
|
1332 | | - This->bltvertices[2].y = This->bltvertices[3].y = (float)sizes[1];
|
| 1344 | + This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)sizes[1];
|
1333 | 1345 | }
|
1334 | 1346 | else
|
1335 | 1347 | {
|
1336 | | - This->bltvertices[0].x = This->bltvertices[2].x = (float)texture->bigwidth;
|
| 1348 | + This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)cmd->DrawScreen.texture->bigwidth;
|
1337 | 1349 | This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
|
1338 | | - This->bltvertices[2].y = This->bltvertices[3].y = (float)texture->bigheight;
|
| 1350 | + This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)cmd->DrawScreen.texture->bigheight;
|
1339 | 1351 | }
|
1340 | 1352 | if ((This->ddInterface->GetBPP() == 8) && (dxglcfg.scalingfilter) &&
|
1341 | 1353 | ((cmd->DrawScreen.texture->bigwidth != (view[1] - view[0])) ||
|
1342 | 1354 | (cmd->DrawScreen.texture->bigheight != (view[3] - view[2]))))
|
1343 | 1355 | {
|
1344 | | - #error do texcoord for backbuffer
|
| 1356 | + This->bltvertices[0].s = This->bltvertices[2].s =
|
| 1357 | + (GLfloat)cmd->DrawScreen.texture->bigwidth / (GLfloat)This->backbuffer->bigwidth;
|
| 1358 | + This->bltvertices[0].t = This->bltvertices[1].t =
|
| 1359 | + (GLfloat)cmd->DrawScreen.texture->bigheight / (GLfloat)This->backbuffer->bigheight;
|
| 1360 | + This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.0f;
|
1345 | 1361 | }
|
1346 | 1362 | else
|
1347 | 1363 | {
|
1348 | | - This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
|
1349 | | - This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
|
| 1364 | + This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.0f;
|
| 1365 | + This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.0f;
|
1350 | 1366 | }
|
1351 | | - // Write 2D Vertex command and check buffers
|
| 1367 | + // Create command and check buffers
|
| 1368 | + Vertex2DCmd cmdout;
|
| 1369 | + cmdout.opcode = OP_VERTEX2D;
|
| 1370 | + cmdout.size = sizeof(Vertex2DCmd) - 8;
|
| 1371 | + cmdout.count = 4;
|
| 1372 | + cmdout.indexcount = 6;
|
| 1373 | + cmdout.flags = 0;
|
| 1374 | + CheckCmdBuffer(This, cmdout.size + 8, 0, 4 * sizeof(BltVertex), 6 * sizeof(WORD));
|
1352 | 1375 | // Write vertices to VBO
|
| 1376 | + cmdout.offset = This->state.cmd->write_ptr_vertex;
|
| 1377 | + cmdout.indexoffset = This->state.cmd->write_ptr_index;
|
| 1378 | + memcpy(This->state.cmd->vertices->pointer + This->state.cmd->write_ptr_vertex,
|
| 1379 | + tmp_cmd.BltVertex_STORAGE.vertex, 4 * sizeof(BltVertex));
|
| 1380 | + memcpy(This->state.cmd->indices->pointer + This->state.cmd->write_ptr_index,
|
| 1381 | + indexbase, 6 * sizeof(WORD));
|
| 1382 | + This->state.cmd->write_ptr_vertex += 4 * sizeof(BltVertex);
|
| 1383 | + This->state.cmd->write_ptr_index += 6 * sizeof(WORD);
|
| 1384 | + // Write command to buffer
|
| 1385 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, &cmdout, cmdout.size + 8);
|
| 1386 | + This->state.cmd->write_ptr_cmd_modify = This->state.cmd->write_ptr_cmd;
|
| 1387 | + This->state.cmd->write_ptr_cmd += (cmdout.size + 8);
|
1353 | 1388 | // Set swap interval
|
| 1389 | + tmp_cmd.SetSwap.opcode = OP_SETSWAP;
|
| 1390 | + tmp_cmd.SetSwap.size = sizeof(GLint);
|
| 1391 | + tmp_cmd.SetSwap.interval = cmd->DrawScreen.vsync;
|
| 1392 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
1354 | 1393 | // Swap buffers
|
1355 | | - error = DDERR_CURRENTLYNOTAVAIL;
|
| 1394 | + tmp_cmd.SwapBuffers.opcode = OP_SWAPBUFFERS;
|
| 1395 | + tmp_cmd.SwapBuffers.size = 0;
|
| 1396 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, TRUE);
|
| 1397 | + error = DD_OK;
|
1356 | 1398 | break;
|
1357 | 1399 | case OP_INITD3D: // Initialize renderer for Direct3D rendering.
|
1358 | 1400 | // Set initial viewport
|