Skip to content

Commit

Permalink
Fix fullscreen resize options
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbata committed Oct 9, 2023
1 parent 798b095 commit f5aa3b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ The file can be made read-only to avoid this problem.
* `fullscreen`: `false` by default. Turns on fullscreen mode instead of the default windowed mode
* `fullscreen_mode`: options: `Best` (picks the closest supported resolution), `Native` (default, the current display mode)
* `fullscreen_stretch`: options: `Centre`, `Stretch`, `Fit` (default), `Aspect_4_3`. Try with `fullscreen_mode=Native` if you experience trouble.
* `fullscreen_interpolation`: options: `Nearest` (default), `Bilinear`, `Biqubic`
* `fullscreen_interpolation`: options: `Nearest` (default, fast and crispy), `Bilinear` (smoother resize quality, slower), `Bicubic` (slow, best vailable resize quality)
* `alwaysrun`: `false` by default
* `vanilla_key_behavior`: `true` by default
* `automap_plotter_style`: options: `Thin` (default, vanilla), `Thick` (scaled), `Deep` (slightly rounded scaled)
Expand Down
6 changes: 6 additions & 0 deletions src/awt/DoomFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.awt.Image;
import static java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION;
import static java.awt.RenderingHints.KEY_ANTIALIASING;
import static java.awt.RenderingHints.KEY_COLOR_RENDERING;
import static java.awt.RenderingHints.KEY_RENDERING;
import static java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_OFF;
import static java.awt.RenderingHints.VALUE_COLOR_RENDER_SPEED;
import static java.awt.RenderingHints.VALUE_RENDER_SPEED;
import java.util.function.Supplier;
import java.util.logging.Level;
Expand Down Expand Up @@ -164,6 +166,10 @@ private Graphics2D getGraphics2D() {
localG2d.setRenderingHint(KEY_ALPHA_INTERPOLATION, VALUE_ALPHA_INTERPOLATION_SPEED);
localG2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_OFF);
localG2d.setRenderingHint(KEY_RENDERING, VALUE_RENDER_SPEED);
localG2d.setRenderingHint(KEY_COLOR_RENDERING, VALUE_COLOR_RENDER_SPEED);

// add fullscreen interpolation applyFullscreenOptions
applyFullscreenOptions(localG2d);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/awt/DoomWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public EventObserver<H> getObserver() {
}

public boolean switchFullscreen() {
LOGGER.log(Level.INFO, "FULLSCREEN SWITHED");
LOGGER.log(Level.INFO, "Fullscreen switched");
// remove the frame from view
doomFrame.dispose();
doomFrame = new DoomFrame<>(dimension, component, doomFrame.imageSupplier);
Expand Down
8 changes: 4 additions & 4 deletions src/awt/FullscreenOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public interface FullscreenOptions {

enum InterpolationMode {
Nearest, Bilinear, Biqubic;
Nearest, Bilinear, Bicubic;
}

enum StretchMode {
Expand Down Expand Up @@ -123,15 +123,15 @@ interface Fitter {
int fit(int width, int defWidth, int height, int defHeight);
}

default void options(Graphics2D graphics) {
default void applyFullscreenOptions(Graphics2D graphics) {
switch (INTERPOLATION) {
case Nearest:
graphics.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
break;
case Bilinear:
graphics.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR);
break;
case Biqubic:
case Bicubic:
graphics.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BICUBIC);
break;
}
Expand All @@ -149,7 +149,7 @@ default FullscreenFunction createFullSwitcher(final GraphicsDevice device) {
return (w, h) -> device.getDisplayMode();
}

throw new Error("Enum reflection overuse?");
throw new Error(String.format("Unsupported mode: %s", String.valueOf(FULLMODE)));
}

@FunctionalInterface
Expand Down

0 comments on commit f5aa3b3

Please sign in to comment.