DXGL r692 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r691‎ | r692 | r693 >
Date:03:22, 11 January 2017
Author:admin
Status:new
Tags:
Comment:
More progress on new renderer frontend.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2012-2016 William Feely
 3+// Copyright (C) 2012-2017 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -600,6 +600,7 @@
601601 LONG_PTR winstyle, winstyleex;
602602 BOOL restart_cmd = FALSE;
603603 __int64 shaderid;
 604+ BltVertex *vertex;
604605 if (!inner) EnterCriticalSection(&This->cs);
605606 switch (cmd->Generic.opcode)
606607 {
@@ -908,7 +909,7 @@
909910 tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
910911 tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
911912 tmp_cmd.SetAttrib.count = 0;
912 - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
 913+ vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
913914 append_attrib_cmd(This, &tmp_cmd.SetAttrib, 0, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &vertex->x,
914915 TRUE, sizeof(MIN_STORAGE_CMD));
915916 if (!(cmd->Blt.cmd.flags & DDBLT_COLORFILL))
@@ -1168,7 +1169,7 @@
11691170 tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
11701171 tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
11711172 tmp_cmd.SetAttrib.count = 0;
1172 - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
 1173+ vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
11731174 append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[PROG_PAL256].pos, 2, GL_FLOAT, GL_FALSE,
11741175 sizeof(BltVertex), &vertex->x, TRUE, sizeof(MIN_STORAGE_CMD));
11751176 append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[PROG_PAL256].texcoord, 2, GL_FLOAT, GL_FALSE,
@@ -1303,7 +1304,7 @@
13041305 tmp_cmd.SetAttrib.opcode = OP_SETATTRIB;
13051306 tmp_cmd.SetAttrib.size = sizeof(SetAttribCmdBase) - 8;
13061307 tmp_cmd.SetAttrib.count = 0;
1307 - BltVertex *vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
 1308+ vertex = (BltVertex*)This->state.cmd->write_ptr_vertex;
13081309 append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[shaderid].pos, 2, GL_FLOAT, GL_FALSE,
13091310 sizeof(BltVertex), &vertex->x, TRUE, sizeof(MIN_STORAGE_CMD));
13101311 append_attrib_cmd(This, &tmp_cmd.SetAttrib, This->shaders->shaders[shaderid].pos, 2, GL_FLOAT, GL_FALSE,
@@ -1322,36 +1323,77 @@
13231324 glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
13241325 }
13251326 // 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+ }
13271339 // Generate vertices
13281340 if (This->ddInterface->GetFullscreen())
13291341 {
1330 - This->bltvertices[0].x = This->bltvertices[2].x = (float)sizes[0];
 1342+ This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)sizes[0];
13311343 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];
13331345 }
13341346 else
13351347 {
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;
13371349 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;
13391351 }
13401352 if ((This->ddInterface->GetBPP() == 8) && (dxglcfg.scalingfilter) &&
13411353 ((cmd->DrawScreen.texture->bigwidth != (view[1] - view[0])) ||
13421354 (cmd->DrawScreen.texture->bigheight != (view[3] - view[2]))))
13431355 {
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;
13451361 }
13461362 else
13471363 {
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;
13501366 }
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));
13521375 // 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);
13531388 // 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);
13541393 // 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;
13561398 break;
13571399 case OP_INITD3D: // Initialize renderer for Direct3D rendering.
13581400 // Set initial viewport