Browse code

Removed clear between redraws and moved to set_window_size

neauoire authored on 07/06/2023 15:23:42
Showing 1 changed files
... ...
@@ -49,7 +49,7 @@ static SDL_Window *emu_window;
49 49
 static SDL_Texture *emu_texture;
50 50
 static SDL_Renderer *emu_renderer;
51 51
 static SDL_AudioDeviceID audio_id;
52
-static SDL_Rect gRect;
52
+static SDL_Rect emu_frame;
53 53
 static SDL_Thread *stdin_thread;
54 54
 
55 55
 Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000};
... ...
@@ -168,6 +168,7 @@ set_window_size(SDL_Window *window, int w, int h)
168 168
 	SDL_GetWindowPosition(window, &win.x, &win.y);
169 169
 	SDL_GetWindowSize(window, &win_old.x, &win_old.y);
170 170
 	if(w == win_old.x && h == win_old.y) return;
171
+	SDL_RenderClear(emu_renderer);
171 172
 	/* SDL_SetWindowPosition(window, (win.x + win_old.x / 2) - w / 2, (win.y + win_old.y / 2) - h / 2); */
172 173
 	SDL_SetWindowSize(window, w, h);
173 174
 }
... ...
@@ -175,16 +176,16 @@ set_window_size(SDL_Window *window, int w, int h)
175 176
 static int
176 177
 set_size(void)
177 178
 {
178
-	gRect.x = PAD;
179
-	gRect.y = PAD;
180
-	gRect.w = uxn_screen.width;
181
-	gRect.h = uxn_screen.height;
179
+	emu_frame.x = PAD;
180
+	emu_frame.y = PAD;
181
+	emu_frame.w = uxn_screen.width;
182
+	emu_frame.h = uxn_screen.height;
182 183
 	if(emu_texture != NULL)
183 184
 		SDL_DestroyTexture(emu_texture);
184 185
 	SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2);
185 186
 	emu_texture = SDL_CreateTexture(emu_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, uxn_screen.width, uxn_screen.height);
186 187
 	if(emu_texture == NULL || SDL_SetTextureBlendMode(emu_texture, SDL_BLENDMODE_NONE))
187
-		return system_error("emu_texture", SDL_GetError());
188
+		return system_error("SDL_SetTextureBlendMode", SDL_GetError());
188 189
 	if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, sizeof(Uint32)) != 0)
189 190
 		return system_error("SDL_UpdateTexture", SDL_GetError());
190 191
 	set_window_size(emu_window, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
... ...
@@ -194,13 +195,12 @@ set_size(void)
194 195
 static void
195 196
 redraw(void)
196 197
 {
197
-	if(gRect.w != uxn_screen.width || gRect.h != uxn_screen.height)
198
+	if(emu_frame.w != uxn_screen.width || emu_frame.h != uxn_screen.height)
198 199
 		set_size();
199 200
 	screen_redraw();
200 201
 	if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
201 202
 		system_error("SDL_UpdateTexture", SDL_GetError());
202
-	SDL_RenderClear(emu_renderer);
203
-	SDL_RenderCopy(emu_renderer, emu_texture, NULL, &gRect);
203
+	SDL_RenderCopy(emu_renderer, emu_texture, NULL, &emu_frame);
204 204
 	SDL_RenderPresent(emu_renderer);
205 205
 }
206 206