| Index: ddraw/glRenderer.cpp |
| — | — | @@ -601,6 +601,9 @@ |
| 602 | 602 | BOOL restart_cmd = FALSE;
|
| 603 | 603 | __int64 shaderid;
|
| 604 | 604 | BltVertex *vertex;
|
| | 605 | + BOOL flip;
|
| | 606 | + if (wait) flip = TRUE;
|
| | 607 | + else flip = FALSE;
|
| 605 | 608 | if (!inner) EnterCriticalSection(&This->cs);
|
| 606 | 609 | switch (cmd->Generic.opcode)
|
| 607 | 610 | {
|
| — | — | @@ -1397,20 +1400,64 @@ |
| 1398 | 1401 | break;
|
| 1399 | 1402 | case OP_INITD3D: // Initialize renderer for Direct3D rendering.
|
| 1400 | 1403 | // Set initial viewport
|
| | 1404 | + tmp_cmd.SetD3DViewport.opcode = OP_SETD3DVIEWPORT;
|
| | 1405 | + tmp_cmd.SetD3DViewport.size = sizeof(SetD3DViewportCmd) - 8;
|
| | 1406 | + tmp_cmd.SetD3DViewport.viewport.dwX = 0;
|
| | 1407 | + tmp_cmd.SetD3DViewport.viewport.dwY = 0;
|
| | 1408 | + tmp_cmd.SetD3DViewport.viewport.dwWidth = cmd->InitD3D.x;
|
| | 1409 | + tmp_cmd.SetD3DViewport.viewport.dwHeight = cmd->InitD3D.y;
|
| | 1410 | + tmp_cmd.SetD3DViewport.viewport.dvMinZ = 0.0f;
|
| | 1411 | + tmp_cmd.SetD3DViewport.viewport.dvMaxZ = 1.0f;
|
| | 1412 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
| 1401 | 1413 | // Initialize texture stages 0 through 7
|
| | 1414 | + tmp_cmd.InitTextureStage.opcode = OP_INITTEXTURESTAGE;
|
| | 1415 | + tmp_cmd.InitTextureStage.size = sizeof(InitTextureStageCmd) - 8 + (7 * sizeof(DWORD));
|
| | 1416 | + tmp_cmd.InitTextureStage.count = 8;
|
| | 1417 | + for (i = 0; i < 8; i++)
|
| | 1418 | + tmp_cmd.InitTextureStage.stage[i] = i;
|
| | 1419 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
| 1402 | 1420 | // Post InitD3D command
|
| 1403 | | - error = DDERR_CURRENTLYNOTAVAIL;
|
| | 1421 | + CheckCmdBuffer(This, cmd->InitD3D.size + 8, 0, 0, 0);
|
| | 1422 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->InitD3D.size + 8);
|
| | 1423 | + This->state.cmd->write_ptr_cmd += (cmd->InitD3D.size + 8);
|
| | 1424 | + error = DD_OK;
|
| 1404 | 1425 | break;
|
| 1405 | 1426 | case OP_CLEAR: // Clears full renderbuffer or one or more rects.
|
| 1406 | 1427 | // Size should hold number of rects plus each rect, or 0 for screen.
|
| 1407 | | - error = DDERR_CURRENTLYNOTAVAIL;
|
| | 1428 | + CheckCmdBuffer(This, cmd->Clear.size + 8, 0, 0, 0);
|
| | 1429 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->Clear.size + 8);
|
| | 1430 | + This->state.cmd->write_ptr_cmd += (cmd->Clear.size + 8);
|
| | 1431 | + error = DD_OK;
|
| 1408 | 1432 | break;
|
| 1409 | 1433 | case OP_FLUSH: // Probably should consider retiring this one. Flip buffers if called
|
| 1410 | 1434 | // to ensure the renderer gets flushed.
|
| | 1435 | + CheckCmdBuffer(This, cmd->Flush.size + 8, 0, 0, 0);
|
| | 1436 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->Flush.size + 8);
|
| | 1437 | + This->state.cmd->write_ptr_cmd += (cmd->Flush.size + 8);
|
| 1411 | 1438 | error = DDERR_CURRENTLYNOTAVAIL;
|
| | 1439 | + flip = TRUE;
|
| 1412 | 1440 | break;
|
| 1413 | 1441 | case OP_DRAWPRIMITIVES: // Add primitives to the render buffer, check and adjust buffer
|
| 1414 | 1442 | // state.
|
| | 1443 | +
|
| | 1444 | + /*Description of old DrawPrimitives:
|
| | 1445 | + check for zbuffer on target
|
| | 1446 | + check if transformed
|
| | 1447 | + if no vertex positions fail
|
| | 1448 | + AND shaderstate with 0xFFFA3FF87FFFFFFFi64
|
| | 1449 | + AND all texstage ids with 0xFFE7FFFFFFFFFFFFi64
|
| | 1450 | + Set bit 51 of texture id for each texture stage in vertices
|
| | 1451 | + add number of textures to shaderstate bits 31-33
|
| | 1452 | + If more than 0 textures used set bit 34 of shaderstate
|
| | 1453 | + Set bits 46-48 of shaderstate to number of blendweights
|
| | 1454 | + Set bit 50 of shaderstate if vertices are pre-transformed
|
| | 1455 | + Set bit 35 of shaderstate if diffuse color is in vertices
|
| | 1456 | + Set bit 36 of shaderstate if specular color is in vertices
|
| | 1457 | + Set bit 37 of shaderstate if vertices have normals
|
| | 1458 | + Set shader program
|
| | 1459 | + Tell renderer to set depth compare mode, depth test, and depth write
|
| | 1460 | +
|
| | 1461 | + */
|
| 1415 | 1462 | error = DDERR_CURRENTLYNOTAVAIL;
|
| 1416 | 1463 | break;
|
| 1417 | 1464 | case OP_UPDATECLIPPER: // Add pre-processed vertices to update the clipper.
|
| — | — | @@ -1473,6 +1520,9 @@ |
| 1474 | 1521 | case OP_VERTEX2D:
|
| 1475 | 1522 | error = DDERR_CURRENTLYNOTAVAIL;
|
| 1476 | 1523 | break;
|
| | 1524 | + case OP_SETD3DDEPTHMODE:
|
| | 1525 | + error = DDERR_CURRENTLYNOTAVAIL;
|
| | 1526 | + break;
|
| 1477 | 1527 | case OP_SETDEPTHTEST:
|
| 1478 | 1528 | error = DDERR_CURRENTLYNOTAVAIL;
|
| 1479 | 1529 | break;
|
| — | — | @@ -3742,10 +3792,8 @@ |
| 3743 | 3793 | if (vertices[7].data) This->shaderstate3d.stateid |= (1i64 << 37);
|
| 3744 | 3794 | ShaderManager_SetShader(This->shaders,This->shaderstate3d.stateid,This->shaderstate3d.texstageid,2);
|
| 3745 | 3795 | glRenderer__SetDepthComp(This);
|
| 3746 | | - if(This->renderstate[D3DRENDERSTATE_ZENABLE]) glUtil_DepthTest(This->util, TRUE);
|
| 3747 | | - else glUtil_DepthTest(This->util, FALSE);
|
| 3748 | | - if (This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) glUtil_DepthWrite(This->util, TRUE);
|
| 3749 | | - else glUtil_DepthWrite(This->util, FALSE);
|
| | 3796 | + glUtil_DepthTest(This->util, This->renderstate[D3DRENDERSTATE_ZENABLE]);
|
| | 3797 | + glUtil_DepthWrite(This->util, This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]);
|
| 3750 | 3798 | _GENSHADER *prog = &This->shaders->gen3d->current_genshader->shader;
|
| 3751 | 3799 | glUtil_EnableArray(This->util, prog->attribs[0], TRUE);
|
| 3752 | 3800 | This->ext->glVertexAttribPointer(prog->attribs[0],3,GL_FLOAT,GL_FALSE,vertices[0].stride,vertices[0].data);
|
| Index: ddraw/glRenderer.h |
| — | — | @@ -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
|
| — | — | @@ -98,12 +98,13 @@ |
| 99 | 99 | #define OP_SETRENDERTARGET 31
|
| 100 | 100 | #define OP_SETVIEWPORT 32
|
| 101 | 101 | #define OP_VERTEX2D 33
|
| 102 | | -#define OP_SETDEPTHTEST 34
|
| 103 | | -#define OP_SETFRONTBUFFERBITS 35
|
| 104 | | -#define OP_SETSWAP 36
|
| 105 | | -#define OP_SWAPBUFFERS 37
|
| 106 | | -#define OP_SETUNIFORM 38
|
| 107 | | -#define OP_SETATTRIB 39
|
| | 102 | +#define OP_SETD3DDEPTHMODE 34
|
| | 103 | +#define OP_SETDEPTHTEST 35
|
| | 104 | +#define OP_SETFRONTBUFFERBITS 36
|
| | 105 | +#define OP_SETSWAP 37
|
| | 106 | +#define OP_SWAPBUFFERS 38
|
| | 107 | +#define OP_SETUNIFORM 39
|
| | 108 | +#define OP_SETATTRIB 40
|
| 108 | 109 |
|
| 109 | 110 | extern const DWORD renderstate_default[153];
|
| 110 | 111 | extern const TEXTURESTAGE texstagedefault0;
|
| Index: ddraw/glUtil.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
|
| — | — | @@ -329,20 +329,26 @@ |
| 330 | 330 | }
|
| 331 | 331 | }
|
| 332 | 332 |
|
| 333 | | -void glUtil_DepthWrite(glUtil *This, BOOL enabled)
|
| | 333 | +void glUtil_DepthWrite(glUtil *This, DWORD enabled)
|
| 334 | 334 | {
|
| 335 | | - if (enabled != This->depthwrite)
|
| | 335 | + BOOL enabled_bool;
|
| | 336 | + if (enabled) enabled_bool = TRUE;
|
| | 337 | + else enabled_bool = FALSE;
|
| | 338 | + if (enabled_bool != This->depthwrite)
|
| 336 | 339 | {
|
| 337 | | - This->depthwrite = enabled;
|
| | 340 | + This->depthwrite = enabled_bool;
|
| 338 | 341 | if (This->depthwrite) glDepthMask(GL_TRUE);
|
| 339 | 342 | else glDepthMask(GL_FALSE);
|
| 340 | 343 | }
|
| 341 | 344 | }
|
| 342 | | -void glUtil_DepthTest(glUtil *This, BOOL enabled)
|
| | 345 | +void glUtil_DepthTest(glUtil *This, DWORD enabled)
|
| 343 | 346 | {
|
| 344 | | - if (enabled != This->depthtest)
|
| | 347 | + BOOL enabled_bool;
|
| | 348 | + if (enabled) enabled_bool = TRUE;
|
| | 349 | + else enabled_bool = FALSE;
|
| | 350 | + if (enabled_bool != This->depthtest)
|
| 345 | 351 | {
|
| 346 | | - This->depthtest = enabled;
|
| | 352 | + This->depthtest = enabled_bool;
|
| 347 | 353 | if (This->depthtest) glEnable(GL_DEPTH_TEST);
|
| 348 | 354 | else glDisable(GL_DEPTH_TEST);
|
| 349 | 355 | }
|
| Index: ddraw/glUtil.h |
| — | — | @@ -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
|
| — | — | @@ -40,8 +40,8 @@ |
| 41 | 41 | GLenum glUtil_SetFBO(glUtil *This, FBO *fbo);
|
| 42 | 42 | GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, GLint level, GLint zlevel, BOOL stencil);
|
| 43 | 43 | void glUtil_SetDepthComp(glUtil *This, GLenum comp);
|
| 44 | | -void glUtil_DepthWrite(glUtil *This, BOOL enabled);
|
| 45 | | -void glUtil_DepthTest(glUtil *This, BOOL enabled);
|
| | 44 | +void glUtil_DepthWrite(glUtil *This, DWORD enabled);
|
| | 45 | +void glUtil_DepthTest(glUtil *This, DWORD enabled);
|
| 46 | 46 | void glUtil_SetScissor(glUtil *This, BOOL enabled, GLint x, GLint y, GLsizei width, GLsizei height);
|
| 47 | 47 | void glUtil_SetMatrix(glUtil *This, GLenum mode, GLfloat *mat1, GLfloat *mat2, BOOL *dirty);
|
| 48 | 48 | void glUtil_MatrixMode(glUtil *This, GLenum mode);
|
| Index: ddraw/struct_command.h |
| — | — | @@ -1,5 +1,5 @@ |
| 2 | 2 | // DXGL
|
| 3 | | -// Copyright (C) 2016 William Feely
|
| | 3 | +// Copyright (C) 2016-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
|
| — | — | @@ -267,6 +267,11 @@ |
| 268 | 268 | size_t offset;
|
| 269 | 269 | size_t indexoffset;
|
| 270 | 270 | } Vertex2DCmd;
|
| | 271 | +typedef struct SetD3DDepthModeCmd
|
| | 272 | +{
|
| | 273 | + DWORD opcode;
|
| | 274 | + DWORD size;
|
| | 275 | +} SetD3DDepthModeCmd;
|
| 271 | 276 | typedef struct SetDepthTestCmd
|
| 272 | 277 | {
|
| 273 | 278 | DWORD opcode;
|
| — | — | @@ -398,6 +403,7 @@ |
| 399 | 404 | SetRenderTargetCmd SetRenderTarget;
|
| 400 | 405 | SetViewportCmd SetViewport;
|
| 401 | 406 | Vertex2DCmd Vertex2D;
|
| | 407 | + SetD3DDepthModeCmd SetD3DDepthMode;
|
| 402 | 408 | SetDepthTestCmd SetDepthTest;
|
| 403 | 409 | SetFrontBufferBitsCmd SetFrontBufferBits;
|
| 404 | 410 | SetSwapCmd SetSwap;
|