comparison src/video/win32/SDL_d3drender.c @ 3599:0f958e527e5e

Updated to compile on Windows
author Sam Lantinga <slouken@libsdl.org>
date Thu, 24 Dec 2009 19:18:05 +0000
parents 9c2e92de786a
children e86edac50872
comparison
equal deleted inserted replaced
3598:427ff6d745df 3599:0f958e527e5e
116 const SDL_Rect * rect, int markDirty, 116 const SDL_Rect * rect, int markDirty,
117 void **pixels, int *pitch); 117 void **pixels, int *pitch);
118 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 118 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
119 static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, 119 static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
120 int numrects, const SDL_Rect * rects); 120 int numrects, const SDL_Rect * rects);
121 static int D3D_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, 121 static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
122 int count); 122 const SDL_Point * points, int count);
123 static int D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, 123 static int D3D_RenderDrawLines(SDL_Renderer * renderer,
124 int count); 124 const SDL_Point * points, int count);
125 static int D3D_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 125 static int D3D_RenderDrawRects(SDL_Renderer * renderer,
126 int count); 126 const SDL_Rect ** rects, int count);
127 static int D3D_RenderFillRects(SDL_Renderer * renderer,
128 const SDL_Rect ** rects, int count);
127 static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 129 static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
128 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 130 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
129 static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, 131 static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
130 Uint32 format, void * pixels, int pitch); 132 Uint32 format, void * pixels, int pitch);
131 static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, 133 static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
460 renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; 462 renderer->SetTextureScaleMode = D3D_SetTextureScaleMode;
461 renderer->UpdateTexture = D3D_UpdateTexture; 463 renderer->UpdateTexture = D3D_UpdateTexture;
462 renderer->LockTexture = D3D_LockTexture; 464 renderer->LockTexture = D3D_LockTexture;
463 renderer->UnlockTexture = D3D_UnlockTexture; 465 renderer->UnlockTexture = D3D_UnlockTexture;
464 renderer->DirtyTexture = D3D_DirtyTexture; 466 renderer->DirtyTexture = D3D_DirtyTexture;
465 renderer->RenderPoints = D3D_RenderPoints; 467 renderer->RenderDrawPoints = D3D_RenderDrawPoints;
466 renderer->RenderLines = D3D_RenderLines; 468 renderer->RenderDrawLines = D3D_RenderDrawLines;
467 renderer->RenderRects = D3D_RenderRects; 469 renderer->RenderDrawRects = D3D_RenderDrawRects;
468 renderer->RenderCopy = D3D_RenderCopy; 470 renderer->RenderCopy = D3D_RenderCopy;
469 renderer->RenderReadPixels = D3D_RenderReadPixels; 471 renderer->RenderReadPixels = D3D_RenderReadPixels;
470 renderer->RenderWritePixels = D3D_RenderWritePixels; 472 renderer->RenderWritePixels = D3D_RenderWritePixels;
471 renderer->RenderPresent = D3D_RenderPresent; 473 renderer->RenderPresent = D3D_RenderPresent;
472 renderer->DestroyTexture = D3D_DestroyTexture; 474 renderer->DestroyTexture = D3D_DestroyTexture;
1019 break; 1021 break;
1020 } 1022 }
1021 } 1023 }
1022 1024
1023 static int 1025 static int
1024 D3D_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) 1026 D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
1027 int count)
1025 { 1028 {
1026 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; 1029 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1027 DWORD color; 1030 DWORD color;
1028 Vertex *vertices; 1031 Vertex *vertices;
1029 int i; 1032 int i;
1066 } 1069 }
1067 return 0; 1070 return 0;
1068 } 1071 }
1069 1072
1070 static int 1073 static int
1071 D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) 1074 D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
1075 int count)
1072 { 1076 {
1073 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; 1077 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1074 DWORD color; 1078 DWORD color;
1075 Vertex *vertices; 1079 Vertex *vertices;
1076 int i; 1080 int i;
1122 } 1126 }
1123 return 0; 1127 return 0;
1124 } 1128 }
1125 1129
1126 static int 1130 static int
1127 D3D_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 1131 D3D_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
1132 int count)
1133 {
1134 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1135 DWORD color;
1136 int i;
1137 Vertex vertices[5];
1138 HRESULT result;
1139
1140 if (data->beginScene) {
1141 IDirect3DDevice9_BeginScene(data->device);
1142 data->beginScene = SDL_FALSE;
1143 }
1144
1145 D3D_SetBlendMode(data, renderer->blendMode);
1146
1147 result =
1148 IDirect3DDevice9_SetTexture(data->device, 0,
1149 (IDirect3DBaseTexture9 *) 0);
1150 if (FAILED(result)) {
1151 D3D_SetError("SetTexture()", result);
1152 return -1;
1153 }
1154
1155 color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
1156
1157 for (i = 0; i < SDL_arraysize(vertices); ++i) {
1158 vertices[i].z = 0.0f;
1159 vertices[i].rhw = 1.0f;
1160 vertices[i].color = color;
1161 vertices[i].u = 0.0f;
1162 vertices[i].v = 0.0f;
1163 }
1164
1165 for (i = 0; i < count; ++i) {
1166 const SDL_Rect *rect = rects[i];
1167
1168 vertices[0].x = (float) rect->x;
1169 vertices[0].y = (float) rect->y;
1170
1171 vertices[1].x = (float) rect->x+rect->w-1;
1172 vertices[1].y = (float) rect->y;
1173
1174 vertices[2].x = (float) rect->x+rect->w-1;
1175 vertices[2].y = (float) rect->y+rect->h-1;
1176
1177 vertices[3].x = (float) rect->x;
1178 vertices[3].y = (float) rect->y+rect->h-1;
1179
1180 vertices[4].x = (float) rect->x;
1181 vertices[4].y = (float) rect->y;
1182
1183 result =
1184 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, 4,
1185 vertices, sizeof(*vertices));
1186
1187 if (FAILED(result)) {
1188 D3D_SetError("DrawPrimitiveUP()", result);
1189 return -1;
1190 }
1191 }
1192 return 0;
1193 }
1194
1195 static int
1196 D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
1197 int count)
1128 { 1198 {
1129 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; 1199 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1130 DWORD color; 1200 DWORD color;
1131 int i; 1201 int i;
1132 float minx, miny, maxx, maxy; 1202 float minx, miny, maxx, maxy;