From a58f2ac13b4045dccd2fef9cad48da9f2ed0d23a Mon Sep 17 00:00:00 2001 From: lewa_j Date: Sat, 10 Jan 2026 02:43:55 +0300 Subject: [PATCH] ref: dx2: render textures --- ref/dx2/r_context.c | 15 +++++++++++++++ ref/dx2/r_image.c | 2 ++ ref/dx2/r_local.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/ref/dx2/r_context.c b/ref/dx2/r_context.c index 6754eff9..b5871d03 100644 --- a/ref/dx2/r_context.c +++ b/ref/dx2/r_context.c @@ -478,6 +478,16 @@ static void D3D_PutProcessVertices(void** dst, DWORD flags, WORD start, WORD cou *dst = (void*)(((D3DPROCESSVERTICES*)*dst) + 1); } +static void D3D_PutRenderState(void** dst, D3DRENDERSTATETYPE type, DWORD arg) +{ + D3DSTATE* s = (D3DSTATE*)*dst; + + s->drstRenderStateType = type; + s->dwArg[0] = arg; + *dst = (void*)(((D3DSTATE*)*dst) + 1); + +} + static void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum ) { if (texnum <= 0 || texnum >= MAX_TEXTURES) @@ -540,6 +550,11 @@ static void R_DrawStretchPic( float x, float y, float w, float h, float s1, floa if (!(((ULONG)cur) & 7)) { D3D_PutInstruction(&cur, D3DOP_TRIANGLE, sizeof(D3DTRIANGLE), 0); } + + D3D_PutInstruction(&cur, D3DOP_STATERENDER, sizeof(D3DSTATE), 2); + D3D_PutRenderState(&cur, D3DRENDERSTATE_TEXTUREHANDLE, tex->d3dHandle); + D3D_PutRenderState(&cur, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_DECAL); + D3D_PutInstruction(&cur, D3DOP_TRIANGLE, sizeof(D3DTRIANGLE), 2); D3DTRIANGLE* tris = (D3DTRIANGLE*)cur; diff --git a/ref/dx2/r_image.c b/ref/dx2/r_image.c index 860f7bc6..43086eca 100644 --- a/ref/dx2/r_image.c +++ b/ref/dx2/r_image.c @@ -518,6 +518,8 @@ static qboolean GL_UploadTexture(dx_texture_t *tex, rgbdata_t *pic) #endif DXCheck(IDirectDraw_CreateSurface(dxc.pdd, &ddsd, &tex->dds, NULL)); + DXCheck(IDirectDrawSurface_QueryInterface(tex->dds, &IID_IDirect3DTexture, (void**)&tex->d3dTex)); + DXCheck(IDirect3DTexture_GetHandle(tex->d3dTex, dxc.pd3dd, &tex->d3dHandle)); tex->fogParams[0] = pic->fogParams[0]; tex->fogParams[1] = pic->fogParams[1]; diff --git a/ref/dx2/r_local.h b/ref/dx2/r_local.h index de61f898..d2ff19c9 100644 --- a/ref/dx2/r_local.h +++ b/ref/dx2/r_local.h @@ -58,6 +58,8 @@ typedef struct dx_texture_s #endif IDirectDrawSurface *dds; + IDirect3DTexture *d3dTex; + D3DTEXTUREHANDLE d3dHandle; uint hashValue; struct dx_texture_s *nextHash; } dx_texture_t;