Browse code

check SDL_UpdateTexture return code as well

Sigrid Solveig Haflínudóttir authored on 24/10/2021 19:48:56
Showing 1 changed files
... ...
@@ -156,8 +156,9 @@ set_size(Uint16 width, Uint16 height, int is_resize)
156 156
 	SDL_RenderSetLogicalSize(gRenderer, ppu.width + PAD * 2, ppu.height + PAD * 2);
157 157
 	gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, ppu.width + PAD * 2, ppu.height + PAD * 2);
158 158
 	if(gTexture == NULL || SDL_SetTextureBlendMode(gTexture, SDL_BLENDMODE_NONE))
159
-		return error("sdl_texture", SDL_GetError());
160
-	SDL_UpdateTexture(gTexture, NULL, ppu_screen, sizeof(Uint32));
159
+		return error("gTexture", SDL_GetError());
160
+	if(SDL_UpdateTexture(gTexture, NULL, ppu_screen, sizeof(Uint32)) != 0)
161
+		return error("SDL_UpdateTexture", SDL_GetError());
161 162
 	if(is_resize)
162 163
 		set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
163 164
 	ppu.reqdraw = 1;
... ...
@@ -219,7 +220,8 @@ redraw(Uxn *u)
219 220
 	for(y = 0; y < ppu.height; ++y)
220 221
 		for(x = 0; x < ppu.width; ++x)
221 222
 			ppu_screen[x + y * ppu.width] = palette[ppu_read(&ppu, x, y)];
222
-	SDL_UpdateTexture(gTexture, &gRect, ppu_screen, ppu.width * sizeof(Uint32));
223
+	if(SDL_UpdateTexture(gTexture, &gRect, ppu_screen, ppu.width * sizeof(Uint32)) != 0)
224
+		error("SDL_UpdateTexture", SDL_GetError());
223 225
 	SDL_RenderClear(gRenderer);
224 226
 	SDL_RenderCopy(gRenderer, gTexture, NULL, NULL);
225 227
 	SDL_RenderPresent(gRenderer);