add basic scaling
This commit is contained in:
parent
414dc668ff
commit
f3117767fd
7 changed files with 65 additions and 39 deletions
|
@ -238,6 +238,12 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public static class RedrawFunction implements IntFunction {
|
||||
public void apply(IntVar cv, int value) {
|
||||
Client.CLIENT.rescale();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LevelFunction implements EnumFunction<LogLevel> {
|
||||
public void apply(EnumVar cv, LogLevel value) {
|
||||
Log.setLevel(value);
|
||||
|
@ -390,10 +396,6 @@ public class Client implements IThreadListener {
|
|||
@Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class, display = "Maximale Bildrate")
|
||||
public int sync = 0;
|
||||
|
||||
public int width;
|
||||
public int height;
|
||||
public int mouse_x;
|
||||
public int mouse_y;
|
||||
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterbreite")
|
||||
public int xsize = 1280;
|
||||
@Variable(name = "win_height", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterhöhe")
|
||||
|
@ -402,8 +404,18 @@ public class Client implements IThreadListener {
|
|||
public int saved_xpos = 0x80000000;
|
||||
@Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position")
|
||||
public int saved_ypos = 0x80000000;
|
||||
|
||||
public int fb_raw_x;
|
||||
public int fb_raw_y;
|
||||
private int mouse_raw_x;
|
||||
private int mouse_raw_y;
|
||||
public int fb_x;
|
||||
public int fb_y;
|
||||
public int mouse_x;
|
||||
public int mouse_y;
|
||||
|
||||
@Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1, max = 5, display = "Skalierung der Benutzeroberfläche", unit = "x", callback = RedrawFunction.class)
|
||||
private int scale = 1;
|
||||
|
||||
@Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
|
||||
public float sensitivity = 1.0f;
|
||||
|
@ -1112,7 +1124,7 @@ public class Client implements IThreadListener {
|
|||
GL11.glGetString(GL11.GL_RENDERER), GL11.glGetString(GL11.GL_VENDOR),
|
||||
this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS",
|
||||
this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"),
|
||||
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_x, this.fb_y,
|
||||
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_raw_x, this.fb_raw_y,
|
||||
this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh) + " Hz" : "",
|
||||
this.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate,
|
||||
this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f,
|
||||
|
@ -1949,8 +1961,10 @@ public class Client implements IThreadListener {
|
|||
|
||||
private void fbsize(int x, int y) {
|
||||
GL11.glViewport(0, 0, x, y);
|
||||
fb_x = x;
|
||||
fb_y = y;
|
||||
fb_raw_x = x;
|
||||
fb_raw_y = y;
|
||||
fb_x = Math.max(x / this.scale, 1);
|
||||
fb_y = Math.max(y / this.scale, 1);
|
||||
if(this.open != null) {
|
||||
this.refreshing = true;
|
||||
this.displayGuiScreen(this.open);
|
||||
|
@ -1971,9 +1985,11 @@ public class Client implements IThreadListener {
|
|||
|
||||
private void mouse(int x, int y) {
|
||||
if(!mouseFirst && open == null)
|
||||
this.moveCamera((float)(x - mouse_x) * sensitivity, (float)(mouse_y - y) * sensitivity);
|
||||
mouse_x = x;
|
||||
mouse_y = y;
|
||||
this.moveCamera((float)(x - mouse_raw_x) * sensitivity, (float)(mouse_raw_y - y) * sensitivity);
|
||||
mouse_raw_x = x;
|
||||
mouse_raw_y = y;
|
||||
mouse_x = x / this.scale;
|
||||
mouse_y = y / this.scale;
|
||||
mouseFirst = false;
|
||||
if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) {
|
||||
// if(mouse_clickx < 0 || mouse_clicky < 0) {
|
||||
|
@ -2056,7 +2072,9 @@ public class Client implements IThreadListener {
|
|||
// open.restyle();
|
||||
}
|
||||
|
||||
private void redraw() {
|
||||
private void rescale() {
|
||||
this.fb_x = Math.max(this.fb_raw_x / this.scale, 1);
|
||||
this.fb_y = Math.max(this.fb_raw_y / this.scale, 1);
|
||||
if(this.open != null) {
|
||||
this.refreshing = true;
|
||||
this.displayGuiScreen(this.open);
|
||||
|
@ -2150,10 +2168,16 @@ public class Client implements IThreadListener {
|
|||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0D, (double)this.fb_x, (double)this.fb_y, 0.0D, 1000.0D, 3000.0D);
|
||||
GL11.glOrtho(0.0D, (double)this.fb_raw_x, (double)this.fb_raw_y, 0.0D, 1000.0D, 3000.0D);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
||||
if(this.scale != 1)
|
||||
GL11.glScalef((float)this.scale, (float)this.scale, 1.0f);
|
||||
}
|
||||
|
||||
public void scissor(int x, int y, int width, int height) {
|
||||
GL11.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
|
||||
}
|
||||
|
||||
private void addFrame(long runningTime)
|
||||
|
@ -2350,23 +2374,23 @@ public class Client implements IThreadListener {
|
|||
if(this.saving)
|
||||
return;
|
||||
this.saving = true;
|
||||
final int stride = ((this.fb_x * 3) & 3) != 0 ? 4 + ((this.fb_x * 3) & ~3) : (this.fb_x * 3);
|
||||
final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fb_y).order(ByteOrder.nativeOrder());
|
||||
GL11.glReadPixels(0, 0, this.fb_x, this.fb_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data);
|
||||
final int stride = ((this.fb_raw_x * 3) & 3) != 0 ? 4 + ((this.fb_raw_x * 3) & ~3) : (this.fb_raw_x * 3);
|
||||
final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fb_raw_y).order(ByteOrder.nativeOrder());
|
||||
GL11.glReadPixels(0, 0, this.fb_raw_x, this.fb_raw_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data);
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
byte[] pixels = new byte[stride * Client.this.fb_y];
|
||||
byte[] pixels = new byte[stride * Client.this.fb_raw_y];
|
||||
data.get(pixels);
|
||||
byte[] conv = new byte[Client.this.fb_x * Client.this.fb_y * 3];
|
||||
for(int l = 0; l < Client.this.fb_y; l++) {
|
||||
System.arraycopy(pixels, l * stride, conv, (Client.this.fb_y - 1 - l) * Client.this.fb_x * 3, Client.this.fb_x * 3);
|
||||
byte[] conv = new byte[Client.this.fb_raw_x * Client.this.fb_raw_y * 3];
|
||||
for(int l = 0; l < Client.this.fb_raw_y; l++) {
|
||||
System.arraycopy(pixels, l * stride, conv, (Client.this.fb_raw_y - 1 - l) * Client.this.fb_raw_x * 3, Client.this.fb_raw_x * 3);
|
||||
}
|
||||
BufferedImage image = new BufferedImage(Client.this.fb_x, Client.this.fb_y, BufferedImage.TYPE_INT_ARGB);
|
||||
int[] img = new int[Client.this.fb_x * Client.this.fb_y];
|
||||
BufferedImage image = new BufferedImage(Client.this.fb_raw_x, Client.this.fb_raw_y, BufferedImage.TYPE_INT_ARGB);
|
||||
int[] img = new int[Client.this.fb_raw_x * Client.this.fb_raw_y];
|
||||
for(int z = 0; z < img.length; z++) {
|
||||
img[z] = (int)(conv[(z * 3) + 2] & 0xff) | ((int)(conv[(z * 3) + 1] & 0xff) << 8) | ((int)(conv[(z * 3) + 0] & 0xff) << 16) | 0xff000000;
|
||||
}
|
||||
image.setRGB(0, 0, Client.this.fb_x, Client.this.fb_y, img, 0, Client.this.fb_x);
|
||||
image.setRGB(0, 0, Client.this.fb_raw_x, Client.this.fb_raw_y, img, 0, Client.this.fb_raw_x);
|
||||
|
||||
File dir = new File("screenshots");
|
||||
dir.mkdirs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue