annotate Engine/Graphics/RenderD3D11.cpp @ 2575:a76d408c5132 tip

DrawTranslucent -> DrawTextureGrayShade Removed old texture drawing stuff
author a.parshin
date Wed, 09 Mar 2016 01:39:52 +0200
parents dd36326a9994
children
rev   line source
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
1 #include <d3dcompiler.h>
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
2 #include <comdef.h> // _com_error
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
3
2541
a902abdfc7f2 1. Renamed class Game to class Engine.
a.parshin
parents: 2536
diff changeset
4 #include "Engine/Engine.h"
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
5 #include "RenderD3D11.h"
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
6 #include "Texture.h"
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
7 #include "Sprites.h"
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
8
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
9 #define ErrorD3D(x)\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
10 {\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
11 HRESULT hr = x;\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
12 if (FAILED(hr))\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
13 {\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
14 _com_error com_error(hr);\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
15 Error("HRESULT = %08X\n%S", hr, com_error.ErrorMessage());\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
16 }\
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
17 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
18
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
19
2526
b1c516bf1102 IRender c-tor
a.parshin
parents: 2525
diff changeset
20 RenderD3D11::RenderD3D11(): IRender() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
21 RenderD3D11::~RenderD3D11() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
22
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
23
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
24 bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
25 ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
26
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
27
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
28 void RenderD3D11::ClearBlack() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
29 void RenderD3D11::SaveWinnersCertificate(const char *a1) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
30 void RenderD3D11::_49FD3A_fullscreen() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
31 bool RenderD3D11::InitializeFullscreen() {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
32 void RenderD3D11::CreateZBuffer() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
33 void RenderD3D11::Release() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
34 void RenderD3D11::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
35 void RenderD3D11::SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
36 bool RenderD3D11::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
37 void RenderD3D11::GetTargetPixelFormat(DDPIXELFORMAT *pOut) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
38 void RenderD3D11::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
39 void RenderD3D11::UnlockBackBuffer() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
40 void RenderD3D11::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
41 void RenderD3D11::UnlockFrontBuffer() {__debugbreak();}
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
42 void RenderD3D11::RestoreFrontBuffer() {}
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
43 void RenderD3D11::RestoreBackBuffer() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
44 void RenderD3D11::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
45 void RenderD3D11::BltBackToFontFast(int a2, int a3, RECT *a4) {__debugbreak();}
2526
b1c516bf1102 IRender c-tor
a.parshin
parents: 2525
diff changeset
46 void RenderD3D11::BeginSceneD3D() {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
47 unsigned int RenderD3D11::GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
48 void RenderD3D11::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
49 void RenderD3D11::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) {__debugbreak();}
2574
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
50 void RenderD3D11::DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture_MM7 *pTex, int uPackedID, unsigned int uColor, int a8) {__debugbreak();}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
51 void RenderD3D11::MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
52 void RenderD3D11::MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
53 void RenderD3D11::DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
54 void RenderD3D11::DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
55 void RenderD3D11::_4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
56 void RenderD3D11::TransformBillboardsAndSetPalettesODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
57 void RenderD3D11::DrawBillboardList_BLV() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
58 void RenderD3D11::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
59 void RenderD3D11::ScreenFade(unsigned int color, float t) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
60 void RenderD3D11::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) {__debugbreak();}
2574
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
61 void RenderD3D11::ZBuffer_Fill_2(signed int a2, signed int a3, struct Image *pTexture, int a5) {__debugbreak();}
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
62 void RenderD3D11::ZDrawTextureAlpha(float u, float v, struct Image *pTexture, int zVal) {__debugbreak();}
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
63 void RenderD3D11::BlendTextures(unsigned int a2, unsigned int a3, struct Image *a4, struct Texture_MM7 *a5, int t, int start_opacity, int end_opacity) {__debugbreak();}
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
64 void RenderD3D11::_4A65CC(unsigned int x, unsigned int y, struct Texture_MM7 *a4, struct Texture_MM7 *a5, int a6, int a7, int a8) {__debugbreak();}
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
65 void RenderD3D11::DrawTransparentRedShade(float u, float v, struct Image *a4) {__debugbreak();}
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
66 void RenderD3D11::DrawTransparentGreenShade(float u, float v, struct Image *pTexture) {__debugbreak();}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
67 void RenderD3D11::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) {__debugbreak();}
2575
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2574
diff changeset
68 void RenderD3D11::DrawMasked(float u, float v, struct Image *pTexture, unsigned int, unsigned __int16 mask) {__debugbreak();}
2574
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
69 void RenderD3D11::DrawTextureCustomHeight(float u, float v, class Image *img, int height) {__debugbreak();}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
70 void RenderD3D11::FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
71 void RenderD3D11::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) {__debugbreak();}
2575
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2574
diff changeset
72 void RenderD3D11::DrawTextureGrayShade(float a2, float a3, struct Image *a4) {__debugbreak();}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
73 void RenderD3D11::DrawBuildingsD3D() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
74 void RenderD3D11::DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
75 void RenderD3D11::DrawOutdoorSkyD3D() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
76 void RenderD3D11::DrawOutdoorSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
77 void RenderD3D11::DrawIndoorSkyPolygon(signed int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
78 void RenderD3D11::PrepareDecorationsRenderList_ODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
79 void RenderD3D11::DrawSpriteObjects_ODM() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
80 void RenderD3D11::RenderTerrainD3D() {__debugbreak();}
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
81 bool RenderD3D11::AreRenderSurfacesOk() {return true;}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
82 void RenderD3D11::SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
83 void RenderD3D11::SavePCXScreenshot() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
84 int RenderD3D11::_46À6ÀÑ_GetActorsInViewport(int pDepth) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
85 void RenderD3D11::BeginLightmaps() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
86 void RenderD3D11::EndLightmaps() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
87 void RenderD3D11::BeginLightmaps2() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
88 void RenderD3D11::EndLightmaps2() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
89 bool RenderD3D11::DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias) {__debugbreak(); return 0;}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
90 void RenderD3D11::BeginDecals() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
91 void RenderD3D11::EndDecals() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
92 void RenderD3D11::DrawDecal(struct Decal *pDecal, float z_bias) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
93 void RenderD3D11::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
94 void RenderD3D11::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
95 void RenderD3D11::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
96 void RenderD3D11::am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
97 void RenderD3D11::am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode) {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
98
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
99 void RenderD3D11::Sub01() {__debugbreak();}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
100
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
101
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
102
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
103
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
104 void RenderD3D11::PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size) {}
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
105
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
106 void RenderD3D11::SetUIClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
107 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
108 ui_clip_rect.left = uX;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
109 ui_clip_rect.top = uY;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
110 ui_clip_rect.right = uZ;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
111 ui_clip_rect.bottom = uW;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
112 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
113
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
114 void RenderD3D11::ResetUIClipRect()
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
115 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
116 ui_clip_rect.left = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
117 ui_clip_rect.top = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
118 ui_clip_rect.right = window->GetWidth();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
119 ui_clip_rect.bottom = window->GetHeight();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
120 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
121
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
122 void RenderD3D11::PresentBlackScreen()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
123 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
124 ClearTarget(0xFF000000);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
125 ErrorD3D(pSwapChain->Present(0, 0));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
126 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
127
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
128 void RenderD3D11::BeginScene() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
129 void RenderD3D11::EndScene() {}
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
130
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
131 void RenderD3D11::ClearTarget(unsigned int uColor)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
132 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
133 float clear_color[] =
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
134 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
135 ((uColor & 0x00FF0000) >> 16) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
136 ((uColor & 0x0000FF00) >> 8) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
137 ((uColor & 0x000000FF) >> 0) / 255.0f,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
138 ((uColor & 0xFF000000) >> 24) / 255.0f
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
139 };
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
140 d3dc->ClearRenderTargetView(primary_srv, clear_color);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
141 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
142
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
143 void RenderD3D11::ClearZBuffer(int, int)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
144 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
145 d3dc->ClearDepthStencilView(default_depth_srv, D3D11_CLEAR_DEPTH, 1.0f, 0);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
146 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
147
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
148
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
149
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
150
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
151 void RenderD3D11::DrawTextureAlphaNew(float u, float v, Image *img)
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
152 {
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
153 __debugbreak();
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
154 }
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
155
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
156
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
157 void RenderD3D11::DrawTextureNew(float u, float v, Image *tex)
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
158 {
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
159 __debugbreak();
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
160 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
161
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
162 void RenderD3D11::DrawText(signed int uX, signed int uY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
163 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
164 auto srv = PrepareFontTexture(pFontPixels, uCharWidth, uCharHeight, pFontPalette, uFaceColor, uShadowColor);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
165 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
166 DrawTexture((float)uX / window->GetWidth(), (float)uY / window->GetHeight(), uCharWidth, uCharHeight, srv, ui_blend_alpha);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
167 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
168 srv->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
169 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
170
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
171 void RenderD3D11::DrawTextAlpha(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
172 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
173 auto srv = PrepareFontTexture(font_pixels, a5, uFontHeight, pPalette);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
174 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
175 DrawTexture((float)x / window->GetWidth(), (float)y / window->GetHeight(), a5, uFontHeight, srv, ui_blend_alpha);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
176 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
177 srv->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
178 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
179
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
180 void RenderD3D11::DrawTexture(float u, float v, int texture_width, int texture_height, ID3D11ShaderResourceView *srv, ID3D11BlendState *blend)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
181 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
182 bool clipping = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
183 if (ui_clip_rect.left != 0 || ui_clip_rect.top != 0
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
184 || ui_clip_rect.right != window->GetWidth() || ui_clip_rect.bottom != window->GetHeight())
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
185 clipping = true;
2521
a.parshin
parents: 2518
diff changeset
186
a.parshin
parents: 2518
diff changeset
187 float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
188 d3dc->OMSetRenderTargets(1, &primary_srv, default_depth_srv);
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
189 d3dc->OMSetBlendState(blend, blendFactor, 0xFFFFFFFF);
2521
a.parshin
parents: 2518
diff changeset
190 d3dc->OMSetDepthStencilState(ui_depthstencil, 1);
a.parshin
parents: 2518
diff changeset
191
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
192 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
193 struct cb_fast
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
194 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
195 float pos_x;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
196 float pos_y;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
197 float size_x;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
198 float size_y;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
199 };
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
200
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
201 D3D11_MAPPED_SUBRESOURCE map;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
202 d3dc->Map(ui_cb_fast, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
203 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
204 cb_fast data;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
205 {
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
206 data.pos_x = u;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
207 data.pos_y = v;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
208 data.size_x = (float)texture_width / window->GetWidth();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
209 data.size_y = (float)texture_height / window->GetHeight();
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
210 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
211 memcpy(map.pData, &data, sizeof(data));
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
212 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
213 d3dc->Unmap(ui_cb_fast, 0);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
214 }
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
215
2521
a.parshin
parents: 2518
diff changeset
216 d3dc->VSSetShader(ui_vs, nullptr, 0);
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
217 d3dc->VSSetConstantBuffers(0, 1, &ui_cb_fast);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
218
2521
a.parshin
parents: 2518
diff changeset
219 d3dc->PSSetShader(ui_ps, nullptr, 0);
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
220 d3dc->PSSetConstantBuffers(0, 1, &ui_cb_fast);
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
221 d3dc->PSSetShaderResources(0, 1, &srv);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
222
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
223 if (clipping)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
224 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
225 d3dc->RSSetState(ui_rasterizer);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
226 d3dc->RSSetScissorRects(1, &ui_clip_rect);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
227 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
228 //d3dc->RSSetViewports(1, &ui_viewport);
2521
a.parshin
parents: 2518
diff changeset
229
a.parshin
parents: 2518
diff changeset
230 uint uOffset = 0;
a.parshin
parents: 2518
diff changeset
231 uint uStride = 4 * sizeof(float);
a.parshin
parents: 2518
diff changeset
232 d3dc->IASetVertexBuffers(0, 1, &ui_vb, &uStride, &uOffset);
a.parshin
parents: 2518
diff changeset
233 d3dc->IASetInputLayout(ui_layout);
a.parshin
parents: 2518
diff changeset
234 d3dc->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
a.parshin
parents: 2518
diff changeset
235
a.parshin
parents: 2518
diff changeset
236 d3dc->Draw(6, 0);
a.parshin
parents: 2518
diff changeset
237
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
238 if (clipping)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
239 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
240 d3dc->RSSetState(default_rasterizer);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
241 //d3dc->RSSetScissorRects(0, nullptr);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
242 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
243 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
244
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
245
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
246
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
247 void RenderD3D11::Present()
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
248 {
2521
a.parshin
parents: 2518
diff changeset
249 pSwapChain->Present(0, 0);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
250 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
251
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
252 bool RenderD3D11::IsGammaSupported()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
253 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
254 return false;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
255 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
256
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
257 struct
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
258 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
259 unsigned char restore_resolution;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
260 unsigned char _saved_screen_bpp;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
261 unsigned short _saved_screen_width;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
262 unsigned short _saved_screen_height;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
263 } on_exit;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
264
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
265 void ChangeResolution(int new_width, int new_height, int new_bpp)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
266 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
267 if (!on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
268 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
269 on_exit.restore_resolution = true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
270
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
271 auto hdc = GetDC(nullptr);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
272 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
273 on_exit._saved_screen_width = GetDeviceCaps(hdc, HORZRES);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
274 on_exit._saved_screen_height = GetDeviceCaps(hdc, VERTRES);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
275 on_exit._saved_screen_bpp = GetDeviceCaps(hdc, BITSPIXEL);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
276 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
277 ReleaseDC(nullptr, hdc);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
278 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
279
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
280 DEVMODEA dm;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
281 dm.dmSize = sizeof(dm);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
282 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
283 dm.dmBitsPerPel = new_bpp;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
284 dm.dmPelsWidth = new_width;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
285 dm.dmPelsHeight = new_height;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
286
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
287 if (ChangeDisplaySettingsA(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
288 Error("ChangeDisplaySettingsA");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
289 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
290
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
291 __declspec(noreturn) void ExitApp()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
292 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
293 if (on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
294 ChangeResolution(on_exit._saved_screen_width, on_exit._saved_screen_height, on_exit._saved_screen_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
295
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
296 ExitProcess(0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
297 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
298
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
299
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
300
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
301 bool RenderD3D11::SwitchToWindow()
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
302 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
303 if (on_exit.restore_resolution)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
304 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
305 on_exit.restore_resolution = false;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
306 ChangeResolution(on_exit._saved_screen_width, on_exit._saved_screen_height, on_exit._saved_screen_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
307 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
308 return true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
309 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
310
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
311
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
312
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
313
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
314 bool RenderD3D11::Initialize(OSWindow *window)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
315 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
316 this->window = window;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
317
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
318 auto d3d_lib = LoadLibraryW(L"d3d11.dll");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
319 if (!d3d_lib)
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
320 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
321 Error("d3d11.dll is missing");
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
322 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
323 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
324
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
325
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
326 DXGI_SWAP_CHAIN_DESC swapChainDesc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
327 memset(&swapChainDesc, 0, sizeof(swapChainDesc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
328 swapChainDesc.BufferDesc.Width = window->GetWidth();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
329 swapChainDesc.BufferDesc.Height = window->GetHeight();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
330 //swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
331 //swapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
332 swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
333 //swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
334 //swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
335 swapChainDesc.SampleDesc.Count = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
336 //swapChainDesc.SampleDesc.Quality = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
337 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
338 swapChainDesc.BufferCount = 2;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
339 swapChainDesc.OutputWindow = window->GetApiHandle();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
340 swapChainDesc.Windowed = true;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
341 //swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
342 //swapChainDesc.Flags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
343
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
344
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
345 D3D_FEATURE_LEVEL requested_feature_level = D3D_FEATURE_LEVEL_11_0,
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
346 received_feature_level;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
347
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
348 unsigned int device_flags = 0;//D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
349 #ifndef NODEBUG
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
350 device_flags |= D3D11_CREATE_DEVICE_DEBUG;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
351 #endif
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
352
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
353 HRESULT (__stdcall *dll_D3D11CreateDeviceAndSwapChain)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
354 dll_D3D11CreateDeviceAndSwapChain = (decltype(dll_D3D11CreateDeviceAndSwapChain))GetProcAddress(d3d_lib, "D3D11CreateDeviceAndSwapChain");
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
355 ErrorD3D(dll_D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, device_flags, nullptr, 0, D3D11_SDK_VERSION, &swapChainDesc, &pSwapChain, &d3dd, &received_feature_level, &d3dc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
356
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
357 if (received_feature_level < D3D_FEATURE_LEVEL_10_0)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
358 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
359 MessageBoxA(nullptr, "Received Direct3D 9 or lower", "", 0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
360 __debugbreak();
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
361 }
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
362 /*if (fullscreen)
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
363 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
364 extern void ChangeResolution(int new_dith, int new_height, int new_bpp);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
365 ChangeResolution(target_window->GetWidth(), target_window->GetHeight(), 32);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
366
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
367 target_window->SetPosition(0, 0);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
368 target_window->SetTopmost(true);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
369 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
370 ErrorD3D(pSwapChain->SetFullscreenState(fullscreen, nullptr));*/
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
371
2508
491f0babd563 use_music_folder
Ritor1
parents: 2506
diff changeset
372
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
373 ID3D11Texture2D *pSwapChainSurface;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
374 {
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
375 ErrorD3D(pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void **)&pSwapChainSurface));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
376 ErrorD3D(d3dd->CreateRenderTargetView(pSwapChainSurface, nullptr, &primary_srv));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
377 }
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
378 pSwapChainSurface->Release();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
379
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
380
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
381 D3D11_TEXTURE2D_DESC z_desc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
382 memset(&z_desc, 0, sizeof(z_desc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
383 z_desc.Width = window->GetWidth();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
384 z_desc.Height = window->GetHeight();
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
385 z_desc.MipLevels = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
386 z_desc.ArraySize = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
387 z_desc.Format = DXGI_FORMAT_D32_FLOAT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
388 z_desc.SampleDesc.Count = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
389 //z_desc.SampleDesc.Quality = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
390 //z_desc.Usage = D3D11_USAGE_DEFAULT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
391 z_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
392 //z_desc.CPUAccessFlags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
393 //z_desc.MiscFlags = 0;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
394
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
395 ID3D11Texture2D *depth_surface;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
396 ErrorD3D(d3dd->CreateTexture2D(&z_desc, nullptr, &depth_surface));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
397
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
398 D3D11_DEPTH_STENCIL_VIEW_DESC depth_srv_desc;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
399 memset(&depth_srv_desc, 0, sizeof(depth_srv_desc));
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
400 depth_srv_desc.Format = DXGI_FORMAT_D32_FLOAT;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
401 depth_srv_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
402 //depth_srv_desc.Texture2D.MipSlice = 0;
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
403 ErrorD3D(d3dd->CreateDepthStencilView(depth_surface, &depth_srv_desc, &default_depth_srv));
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
404
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
405 d3dc->OMSetRenderTargets(1, &primary_srv, default_depth_srv);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
406 d3dc->ClearDepthStencilView(default_depth_srv, D3D11_CLEAR_DEPTH, 1.0f, 0);
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
407
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
408
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
409
2521
a.parshin
parents: 2518
diff changeset
410 D3D11_RASTERIZER_DESC default_rasterizer_desc;
a.parshin
parents: 2518
diff changeset
411 memset(&default_rasterizer_desc, 0, sizeof(default_rasterizer_desc));
a.parshin
parents: 2518
diff changeset
412 default_rasterizer_desc.FillMode = D3D11_FILL_SOLID;
a.parshin
parents: 2518
diff changeset
413 default_rasterizer_desc.CullMode = D3D11_CULL_NONE;
a.parshin
parents: 2518
diff changeset
414 //default_rasterizer_desc.FrontCounterClockwise = false;
a.parshin
parents: 2518
diff changeset
415 //default_rasterizer_desc.DepthBias = 0;
a.parshin
parents: 2518
diff changeset
416 //default_rasterizer_desc.DepthBiasClamp = 0.0f;
a.parshin
parents: 2518
diff changeset
417 //default_rasterizer_desc.SlopeScaledDepthBias = 0.0f;
a.parshin
parents: 2518
diff changeset
418 //default_rasterizer_desc.DepthClipEnable = true;
a.parshin
parents: 2518
diff changeset
419 //default_rasterizer_desc.ScissorEnable = false;
a.parshin
parents: 2518
diff changeset
420 //default_rasterizer_desc.MultisampleEnable = false;
a.parshin
parents: 2518
diff changeset
421 //default_rasterizer_desc.AntialiasedLineEnable = false;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
422
2521
a.parshin
parents: 2518
diff changeset
423 ErrorD3D(d3dd->CreateRasterizerState(&default_rasterizer_desc, &default_rasterizer));
a.parshin
parents: 2518
diff changeset
424 d3dc->RSSetState(default_rasterizer);
a.parshin
parents: 2518
diff changeset
425
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
426
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
427
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
428 D3D11_RASTERIZER_DESC ui_rasterizer_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
429 memset(&ui_rasterizer_desc, 0, sizeof(ui_rasterizer_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
430 ui_rasterizer_desc.FillMode = D3D11_FILL_SOLID;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
431 ui_rasterizer_desc.CullMode = D3D11_CULL_NONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
432 //ui_rasterizer_desc.FrontCounterClockwise = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
433 //ui_rasterizer_desc.DepthBias = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
434 //ui_rasterizer_desc.DepthBiasClamp = 0.0f;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
435 //ui_rasterizer_desc.SlopeScaledDepthBias = 0.0f;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
436 //ui_rasterizer_desc.DepthClipEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
437 ui_rasterizer_desc.ScissorEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
438 //ui_rasterizer_desc.MultisampleEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
439 //ui_rasterizer_desc.AntialiasedLineEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
440
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
441 ErrorD3D(d3dd->CreateRasterizerState(&ui_rasterizer_desc, &ui_rasterizer));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
442
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
443
2521
a.parshin
parents: 2518
diff changeset
444 default_depthstencil = nullptr;
a.parshin
parents: 2518
diff changeset
445 default_blend = nullptr;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
446
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
447
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
448
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
449 D3D11_VIEWPORT viewport;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
450 memset(&viewport, 0, sizeof(viewport));
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
451 viewport.TopLeftX = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
452 viewport.TopLeftY = 0;
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
453 viewport.Width = window->GetWidth();
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
454 viewport.Height = window->GetHeight();
2521
a.parshin
parents: 2518
diff changeset
455 viewport.MinDepth = 0;
2496
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
456 viewport.MaxDepth = 1;
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
457 d3dc->RSSetViewports(1, &viewport);
5abd8fc8f1c6 for ITEM_ARTIFACT_LADYS_ESCORT
Ritor1
parents:
diff changeset
458
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
459 ResetUIClipRect();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
460
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
461
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
462 D3D11_INPUT_ELEMENT_DESC layout_desc[] =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
463 {
2521
a.parshin
parents: 2518
diff changeset
464 { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
a.parshin
parents: 2518
diff changeset
465 //{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
466 };
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
467 CompileShader(d3dd, L"data/shaders/UI.hlsl", layout_desc, 1/*2*/, &ui_vs, &ui_ps, &ui_layout);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
468
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
469 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
470 uint uVertexSize = 4 * sizeof(float);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
471
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
472 float ui_mesh[] =
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
473 {
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
474 1, 1, 0, 0, // pos
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
475 1, 1, 1, 0, // pos + size.x
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
476 1, 1, 0, 1, // pos + size.y
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
477
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
478 1, 1, 0, 1, // pos + size.y
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
479 1, 1, 1, 0, // pos + size.x
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
480 1, 1, 1, 1 // pos + size.xy
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
481 /*-1, 1, 0.1, 1,
2521
a.parshin
parents: 2518
diff changeset
482 1, 1, 0.1, 1,
a.parshin
parents: 2518
diff changeset
483 -1, -1, 0.1, 1,
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
484
2521
a.parshin
parents: 2518
diff changeset
485 -1, -1, 0.1, 1,
a.parshin
parents: 2518
diff changeset
486 1, 1, 0.1, 1,
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
487 1, -1, 0.1, 1*/
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
488 };
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
489
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
490 D3D11_BUFFER_DESC vbdesc;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
491 vbdesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
492 vbdesc.ByteWidth = 6 * uVertexSize;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
493 vbdesc.CPUAccessFlags = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
494 vbdesc.MiscFlags = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
495 vbdesc.StructureByteStride = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
496 vbdesc.Usage = D3D11_USAGE_DEFAULT;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
497
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
498 D3D11_SUBRESOURCE_DATA vbdata;
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
499 vbdata.pSysMem = ui_mesh;
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
500 vbdata.SysMemPitch = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
501 vbdata.SysMemSlicePitch = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
502
2521
a.parshin
parents: 2518
diff changeset
503 d3dd->CreateBuffer(&vbdesc, &vbdata, &ui_vb);
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
504 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
505
2523
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
506 D3D11_BUFFER_DESC ui_cb_fast_desc;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
507 ZeroMemory(&ui_cb_fast_desc, sizeof(ui_cb_fast_desc));
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
508 // TODO: Fix Bug Prone size
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
509 ui_cb_fast_desc.ByteWidth = 1 * 4 * sizeof(float);
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
510 ui_cb_fast_desc.Usage = D3D11_USAGE_DYNAMIC;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
511 ui_cb_fast_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
512 ui_cb_fast_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
513 ui_cb_fast_desc.MiscFlags = 0;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
514 ui_cb_fast_desc.StructureByteStride = 0;
c532d5242055 Hello from Direct3D 11 :)
a.parshin
parents: 2521
diff changeset
515 d3dd->CreateBuffer(&ui_cb_fast_desc, nullptr, &ui_cb_fast);
2521
a.parshin
parents: 2518
diff changeset
516
a.parshin
parents: 2518
diff changeset
517 D3D11_DEPTH_STENCIL_DESC ui_depthstencil_desc;
a.parshin
parents: 2518
diff changeset
518 ui_depthstencil_desc.DepthEnable = true;
a.parshin
parents: 2518
diff changeset
519 ui_depthstencil_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
a.parshin
parents: 2518
diff changeset
520 ui_depthstencil_desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
521 ui_depthstencil_desc.StencilEnable = false;
a.parshin
parents: 2518
diff changeset
522 ui_depthstencil_desc.StencilReadMask = 0xFF;
a.parshin
parents: 2518
diff changeset
523 ui_depthstencil_desc.StencilWriteMask = 0xFF;
a.parshin
parents: 2518
diff changeset
524 // Stencil operations if pixel is front-facing
a.parshin
parents: 2518
diff changeset
525 ui_depthstencil_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
526 ui_depthstencil_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
a.parshin
parents: 2518
diff changeset
527 ui_depthstencil_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
528 ui_depthstencil_desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
529 // Stencil operations if pixel is back-facing
a.parshin
parents: 2518
diff changeset
530 ui_depthstencil_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
531 ui_depthstencil_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
a.parshin
parents: 2518
diff changeset
532 ui_depthstencil_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
a.parshin
parents: 2518
diff changeset
533 ui_depthstencil_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
a.parshin
parents: 2518
diff changeset
534
a.parshin
parents: 2518
diff changeset
535 ErrorD3D(d3dd->CreateDepthStencilState(&ui_depthstencil_desc, &ui_depthstencil));
a.parshin
parents: 2518
diff changeset
536
a.parshin
parents: 2518
diff changeset
537
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
538 D3D11_BLEND_DESC ui_blend_solid_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
539 memset(&ui_blend_solid_desc, 0, sizeof(ui_blend_solid_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
540 ui_blend_solid_desc.RenderTarget[0].BlendEnable = false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
541 ui_blend_solid_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
542 ErrorD3D(d3dd->CreateBlendState(&ui_blend_solid_desc, &ui_blend_solid));
2521
a.parshin
parents: 2518
diff changeset
543
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
544 D3D11_BLEND_DESC ui_blend_alpha_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
545 memset(&ui_blend_alpha_desc, 0, sizeof(ui_blend_alpha_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
546 ui_blend_alpha_desc.RenderTarget[0].BlendEnable = true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
547 ui_blend_alpha_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
548 ui_blend_alpha_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
549 ui_blend_alpha_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
550 ui_blend_alpha_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
551 ui_blend_alpha_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
552 ui_blend_alpha_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
553 ui_blend_alpha_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
554 ErrorD3D(d3dd->CreateBlendState(&ui_blend_alpha_desc, &ui_blend_alpha));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
555
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
556
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
557 return pD3DBitmaps.Load(L"data\\d3dbitmap.hwl") && pD3DSprites.Load(L"data\\d3dsprite.hwl");
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
558 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
559
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
560
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
561
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
562
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
563 bool RenderD3D11::MoveSpriteToDevice(Sprite *pSprite)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
564 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
565 HWLTexture *sprite_texture; // eax@1
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
566 unsigned __int16 *v9; // edx@5
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
567 LPVOID v10; // eax@5
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
568 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-7Ch]@4
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
569
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
570 sprite_texture = pD3DSprites.LoadTexture(pSprite->pName, pSprite->uPaletteID);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
571 if ( sprite_texture )
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
572 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
573 pSprite->uAreaX = sprite_texture->uAreaX;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
574 pSprite->uAreaY = sprite_texture->uAreaY;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
575 pSprite->uBufferWidth = sprite_texture->uBufferWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
576 pSprite->uBufferHeight = sprite_texture->uBufferHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
577 pSprite->uAreaWidth = sprite_texture->uAreaWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
578 pSprite->uAreaHeight = sprite_texture->uAreaHeigth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
579
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
580 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
581 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
582 desc.Width = sprite_texture->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
583 desc.Height = sprite_texture->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
584 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
585 desc.MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
586 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
587 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
588 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
589 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
590 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
591 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
592 desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
593
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
594 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
595 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
596
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
597 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
598 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
599 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
600 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
601 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
602
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
603 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
604 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
605
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
606 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
607 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
608 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
609 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
610 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
611 auto src = sprite_texture->pPixels + y * desc.Width + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
612 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
613
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
614 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
615 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
616 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
617
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
618
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
619 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
620 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
621 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
622
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
623 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
624 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
625 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
626
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
627 pSprite->d3d11_srv = srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
628 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
629 /*if (!pRenderD3D->CreateTexture(sprite_texture->uWidth, sprite_texture->uHeight, &pSprite->pTextureSurface, &pSprite->pTexture, 1u, 0, uMinDeviceTextureDim))
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
630 Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
631 memset(&Dst, 0, sizeof(DDSURFACEDESC2));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
632 Dst.dwSize = 124;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
633 if ( LockSurface_DDraw4((IDirectDrawSurface4 *)pSprite->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) )
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
634 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
635 v9 = sprite_texture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
636 v10 = Dst.lpSurface;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
637 for (uint i=0; i<sprite_texture->uHeight; ++i)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
638 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
639 for (uint j=0; j<sprite_texture->uWidth/2; ++j)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
640 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
641 *(int *)v10 = *(int *)v9;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
642 v9 += 2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
643 v10 = (char *)v10 + 4;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
644 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
645 v10 = (char *)v10 + Dst.lPitch-sprite_texture->uWidth*2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
646 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
647 ErrD3D(pSprite->pTextureSurface->Unlock(NULL));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
648 }*/
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
649 delete [] sprite_texture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
650 delete sprite_texture;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
651 return true;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
652 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
653 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
654 }
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
655
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
656
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
657 ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
658 void DoCompile(const wchar_t *pFilename, const char *pShaderSource, unsigned int uShaderSourceLen,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
659 unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
660 bool CompileShader(ID3D11Device *d3dd, const wchar_t *pShaderSourceFile, D3D11_INPUT_ELEMENT_DESC *input_desc, int input_desc_size,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
661 ID3D11VertexShader **vertex_out, ID3D11PixelShader **pixel_out, ID3D11InputLayout **layout_out)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
662 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
663 unsigned char *vs, *ps;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
664 unsigned int vs_size, ps_size;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
665
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
666 HANDLE hSourceFile = CreateFileW(pShaderSourceFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
667 if (hSourceFile == INVALID_HANDLE_VALUE)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
668 Error("%S:\n\nCannot read shader file", pShaderSourceFile);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
669
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
670 char *pShaderSource = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
671 int uShaderSourceLen = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
672 uint uFileSize = GetFileSize(hSourceFile, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
673 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
674 DWORD w;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
675 char *p = new char[uFileSize + 1];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
676 ReadFile(hSourceFile, p, uFileSize, &w, nullptr);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
677 CloseHandle(hSourceFile);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
678 p[uFileSize] = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
679
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
680 pShaderSource = p;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
681 uShaderSourceLen = uFileSize;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
682 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
683
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
684 DoCompile(pShaderSourceFile, pShaderSource, uShaderSourceLen, &vs, &vs_size, &ps, &ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
685
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
686 ErrorD3D(d3dd->CreateVertexShader(vs, vs_size, nullptr, vertex_out));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
687 ErrorD3D(d3dd->CreatePixelShader(ps, ps_size, nullptr, pixel_out));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
688 ErrorD3D(d3dd->CreateInputLayout(input_desc, input_desc_size, vs, vs_size, layout_out));
2518
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
689
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
690 delete [] vs;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
691 delete [] ps;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
692
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
693 return true;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
694 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
695
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
696
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
697
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
698 static HMODULE compiler_dll = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
699 void DoCompile(const wchar_t *pFilename, const char *pSahderSource, unsigned int uShaderSourceLen,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
700 unsigned char **vs, unsigned int *vs_size, unsigned char **ps, unsigned int *ps_size)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
701 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
702 const char *pVSEntry = "vs",
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
703 *pVSVersionString = "vs_4_0";
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
704 const char *pPSEntry = "main",
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
705 *pPSVersionString = "ps_4_0";
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
706
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
707
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
708 uint uVSCompileOptions =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
709 #ifndef NDEBUG
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
710 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
711 D3D10_SHADER_SKIP_OPTIMIZATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
712 D3D10_SHADER_PREFER_FLOW_CONTROL;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
713 #else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
714 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
715 D3D10_SHADER_OPTIMIZATION_LEVEL3 |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
716 D3D10_SHADER_WARNINGS_ARE_ERRORS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
717 D3D10_SHADER_AVOID_FLOW_CONTROL |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
718 D3D10_SHADER_ENABLE_STRICTNESS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
719 D3D10_SHADER_IEEE_STRICTNESS;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
720 #endif
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
721
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
722 *vs_size = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
723 *vs = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
724 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
725 auto pVSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pVSEntry, pVSVersionString, uVSCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
726 if (pVSBlob)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
727 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
728 *vs = new unsigned char[*vs_size = pVSBlob->GetBufferSize()];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
729 memcpy(*vs, pVSBlob->GetBufferPointer(), *vs_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
730
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
731 pVSBlob->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
732 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
733 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
734
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
735
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
736 uint uPSCompileOptions =
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
737 #ifndef NDEBUG
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
738 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
739 D3D10_SHADER_SKIP_OPTIMIZATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
740 D3D10_SHADER_PREFER_FLOW_CONTROL;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
741 #else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
742 D3D10_SHADER_SKIP_VALIDATION |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
743 D3D10_SHADER_OPTIMIZATION_LEVEL3 |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
744 D3D10_SHADER_WARNINGS_ARE_ERRORS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
745 D3D10_SHADER_AVOID_FLOW_CONTROL |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
746 D3D10_SHADER_ENABLE_STRICTNESS |
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
747 D3D10_SHADER_IEEE_STRICTNESS;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
748 #endif
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
749
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
750 *ps_size = 0;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
751 *ps = nullptr;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
752 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
753 auto pPSBlob = DoD3DCompiling(pFilename, pSahderSource, uShaderSourceLen, pPSEntry, pPSVersionString, uPSCompileOptions);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
754 if (pPSBlob)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
755 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
756 *ps = new unsigned char[*ps_size = pPSBlob->GetBufferSize()];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
757 memcpy(*ps, pPSBlob->GetBufferPointer(), *ps_size);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
758
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
759 pPSBlob->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
760 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
761 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
762 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
763
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
764 ID3DBlob *DoD3DCompiling(const wchar_t *shader_name, const char *pShaderSource, uint uShaderSourceLen, const char *pEntry, const char *pVersionString, uint uCompileOptions)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
765 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
766 ID3DBlob *pShader,
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
767 *pErrors;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
768
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
769 if (!compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
770 for (int i = 45; i >= 38; --i)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
771 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
772 wchar_t dll_name[64];
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
773 swprintf(dll_name, L"d3dcompiler_%u.dll", i);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
774
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
775 compiler_dll = LoadLibraryW(dll_name);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
776 if (compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
777 break;
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
778 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
779
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
780 if (!compiler_dll)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
781 Error("Cannot find any suitable d3dcompiler.dll");
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
782
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
783 typedef HRESULT (__stdcall *fnD3DCompile)(const void * pSrcData, SIZE_T SrcDataSize, LPCSTR pSourceName, CONST D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, UINT Flags1, UINT Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
784 auto pD3DCompile = (fnD3DCompile)GetProcAddress(compiler_dll, "D3DCompile");
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
785
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
786 HRESULT hr = pD3DCompile(pShaderSource, uShaderSourceLen, nullptr, nullptr, nullptr, pEntry, pVersionString, uCompileOptions, 0, &pShader, &pErrors);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
787
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
788 if (FAILED(hr))
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
789 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
790 if (pErrors)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
791 Error("%S (%s) build failed:\n\n%s", shader_name, pVersionString, pErrors->GetBufferPointer());
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
792 else
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
793 Error("%S (%s) build failed", shader_name, pVersionString);
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
794 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
795 else if (pErrors)
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
796 {
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
797 Log::Warning(L"%s (%S) build warnings:\n\n%S", shader_name, pVersionString, pErrors->GetBufferPointer());
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
798 pErrors->Release();
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
799 }
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
800
3a1b56ab8749 d3d11 accepts RGBTexture
a.parshin
parents: 2508
diff changeset
801 return pShader;
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
802 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
803
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
804 /*
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
805 void RenderD3D11::PrepareTexture(RGBTexture *p)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
806 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
807 if (!p->d3d11_srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
808 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
809 auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
810 desc->Width = p->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
811 desc->Height = p->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
812 desc->ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
813 desc->MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
814 desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
815 desc->SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
816 desc->SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
817 desc->Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
818 desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
819 desc->CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
820 desc->MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
821
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
822 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
823 ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
824
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
825 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
826 memcpy(&ram_desc, desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
827 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
828 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
829 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
830
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
831 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
832 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
833
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
834 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
835 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
836 for (unsigned int y = 0; y < desc->Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
837 for (unsigned int x = 0; x < desc->Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
838 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
839 auto src = p->pPixels + y * p->uWidth + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
840 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
841
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
842 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
843 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
844 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
845
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
846 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
847 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
848 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
849
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
850 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
851 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
852 }
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
853 }*/
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
854
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
855
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
856
2574
dd36326a9994 More texture refactoring
a.parshin
parents: 2573
diff changeset
857 void RenderD3D11::PrepareTextureIndexed(Texture_MM7 *p)
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
858 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
859 if (!p->d3d11_srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
860 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
861 auto desc = p->d3d11_desc = new D3D11_TEXTURE2D_DESC;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
862 desc->Width = p->uTextureWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
863 desc->Height = p->uTextureHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
864 desc->ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
865 desc->MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
866 desc->Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
867 desc->SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
868 desc->SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
869 desc->Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
870 desc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
871 desc->CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
872 desc->MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
873
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
874 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
875 ErrorD3D(d3dd->CreateTexture2D(desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
876
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
877 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
878 memcpy(&ram_desc, desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
879 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
880 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
881 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
882
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
883 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
884 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
885
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
886 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
887 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
888 for (unsigned int y = 0; y < desc->Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
889 for (unsigned int x = 0; x < desc->Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
890 {
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2544
diff changeset
891 auto index = p->paletted_pixels[y * p->uTextureWidth + x];
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
892 auto src = p->pPalette16[index];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
893 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
894
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
895 if (index)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
896 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
897 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
898 *dst = 0xFF000000 | Color32_SwapRedBlue(src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
899 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
900 else
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
901 *dst = 0x00000000;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
902 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
903
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
904 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
905 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
906 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
907
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
908 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&p->d3d11_srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
909 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
910 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
911 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
912
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
913
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
914 ID3D11ShaderResourceView *RenderD3D11::PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette, unsigned short uFaceColor, unsigned short uShadowColor)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
915 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
916 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
917 desc.Width = uCharWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
918 desc.Height = uCharHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
919 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
920 desc.MipLevels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
921 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
922 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
923 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
924 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
925 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
926 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
927 desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
928
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
929 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
930 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
931
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
932 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
933 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
934 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
935 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
936 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
937
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
938 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
939 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
940
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
941 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
942 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
943 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
944 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
945 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
946 auto index = pFontPixels[y * desc.Width + x];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
947 auto src = pFontPalette[index];
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
948 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
949
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
950 if (index)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
951 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
952 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
953 *dst = 0xFF000000 | Color32_SwapRedBlue(index == 1 ? uShadowColor : uFaceColor);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
954 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
955 else
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
956 *dst = 0x00000000;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
957 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
958
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
959 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
960 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
961 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
962
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
963 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
964 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
965 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
966
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
967 return srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
968 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
969
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
970
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
971 ID3D11ShaderResourceView *RenderD3D11::PrepareFontTexture(unsigned char *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned short *pFontPalette)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
972 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
973 D3D11_TEXTURE2D_DESC desc;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
974 desc.Width = uCharWidth;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
975 desc.Height = uCharHeight;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
976 desc.ArraySize = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
977 desc.MipLevels = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
978 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
979 desc.SampleDesc.Count = 1;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
980 desc.SampleDesc.Quality = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
981 desc.Usage = D3D11_USAGE_DEFAULT;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
982 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
983 desc.CPUAccessFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
984 desc.MiscFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
985
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
986 ID3D11Texture2D *vram_texture = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
987 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
988
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
989 D3D11_TEXTURE2D_DESC ram_desc;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
990 memcpy(&ram_desc, &desc, sizeof(ram_desc));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
991 ram_desc.Usage = D3D11_USAGE_STAGING;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
992 ram_desc.BindFlags = 0;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
993 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
994
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
995 ID3D11Texture2D *ram_texture = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
996 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
997
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
998 D3D11_MAPPED_SUBRESOURCE map;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
999 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1000 for (unsigned int y = 0; y < desc.Height; ++y)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1001 for (unsigned int x = 0; x < desc.Width; ++x)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1002 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1003 auto index = pFontPixels[y * desc.Width + x];
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1004 auto src = pFontPalette[index];
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1005 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1006
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1007 if (index)
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1008 {
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1009 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1010 *dst = 0xFF000000 | Color32_SwapRedBlue(src);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1011 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1012 else
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1013 *dst = 0x00000000;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1014 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1015
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1016 d3dc->Unmap(ram_texture, 0);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1017 d3dc->CopyResource(vram_texture, ram_texture);
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1018 ram_texture->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1019
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1020 ID3D11ShaderResourceView *srv = nullptr;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1021 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1022 vram_texture->Release();
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1023
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1024 return srv;
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1025 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1026
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1027
2524
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1028 void d3d11_release(ID3D11ShaderResourceView *srv)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1029 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1030 srv->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1031 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1032
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1033
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1034 //----- (004A4DE1) --------------------------------------------------------
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1035 bool RenderD3D11::LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1036 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1037 unsigned __int16 *v13; // ecx@19
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1038 unsigned __int16 *v14; // eax@19
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1039 DWORD v15; // edx@20
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1040
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1041 HWLTexture* pHWLTexture = pD3DBitmaps.LoadTexture(pName, bMipMaps);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1042 if (!pHWLTexture)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1043 return false;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1044
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1045 int num_min_levels = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1046 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1047 int dim = min(pHWLTexture->uWidth, pHWLTexture->uHeight);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1048 while (dim > 1)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1049 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1050 dim /= 2;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1051 num_min_levels++;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1052 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1053 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1054
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1055
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1056 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1057 D3D11_TEXTURE2D_DESC desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1058 desc.Width = pHWLTexture->uWidth;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1059 desc.Height = pHWLTexture->uHeight;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1060 desc.ArraySize = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1061 desc.MipLevels = num_min_levels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1062 desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1063 desc.SampleDesc.Count = 1;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1064 desc.SampleDesc.Quality = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1065 desc.Usage = D3D11_USAGE_DEFAULT;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1066 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET/* for mipmap generation */;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1067 desc.CPUAccessFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1068 desc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1069
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1070 ID3D11Texture2D *vram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1071 ErrorD3D(d3dd->CreateTexture2D(&desc, nullptr, &vram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1072
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1073 D3D11_TEXTURE2D_DESC ram_desc;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1074 memcpy(&ram_desc, &desc, sizeof(ram_desc));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1075 ram_desc.Usage = D3D11_USAGE_STAGING;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1076 ram_desc.BindFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1077 ram_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1078 ram_desc.MiscFlags = 0;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1079
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1080 ID3D11Texture2D *ram_texture = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1081 ErrorD3D(d3dd->CreateTexture2D(&ram_desc, nullptr, &ram_texture));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1082
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1083 D3D11_MAPPED_SUBRESOURCE map;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1084 ErrorD3D(d3dc->Map(ram_texture, 0, D3D11_MAP_WRITE, 0, &map));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1085 for (unsigned int y = 0; y < desc.Height; ++y)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1086 for (unsigned int x = 0; x < desc.Width; ++x)
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1087 {
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1088 auto src = pHWLTexture->pPixels + y * desc.Width + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1089 auto dst = (unsigned int *)((char *)map.pData + y * map.RowPitch) + x;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1090
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1091 extern unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1092 *dst = 0xFF000000 | Color32_SwapRedBlue(*src);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1093 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1094
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1095 d3dc->Unmap(ram_texture, 0);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1096 d3dc->CopyResource(vram_texture, ram_texture);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1097 ram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1098
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1099 ID3D11ShaderResourceView *srv = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1100 ErrorD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, &srv));
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1101 vram_texture->Release();
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1102
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1103 d3dc->GenerateMips(srv);
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1104 *pOutTexture = (IDirect3DTexture2 *)srv;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1105 *pOutSurface = nullptr;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1106 }
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1107
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1108 delete [] pHWLTexture->pPixels;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1109 delete pHWLTexture;
c7264ab7132f Main menu rendered using d3d11
a.parshin
parents: 2523
diff changeset
1110 return true;
2525
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1111 }
4cc81f981afb Everything except game can use d3d11
a.parshin
parents: 2524
diff changeset
1112