diff options
author | Carsten Weisse <[email protected]> | 2008-03-02 14:56:23 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2008-03-02 14:56:23 +0000 |
commit | 78d0a1f33aaca5d734122371c43fd51ff43ad3fd (patch) | |
tree | eb01e518130289d77dbdb3331042c5da399cc15a /src/jake2/render | |
parent | adaf8e215e6dfff3435d59867661b4cd8946569f (diff) |
use getters and setters of modified viddef_t
Diffstat (limited to 'src/jake2/render')
-rw-r--r-- | src/jake2/render/Base.java | 5 | ||||
-rw-r--r-- | src/jake2/render/basic/Draw.java | 8 | ||||
-rw-r--r-- | src/jake2/render/basic/Main.java | 24 | ||||
-rw-r--r-- | src/jake2/render/basic/Misc.java | 18 | ||||
-rw-r--r-- | src/jake2/render/fast/Draw.java | 8 | ||||
-rw-r--r-- | src/jake2/render/fast/Main.java | 29 | ||||
-rw-r--r-- | src/jake2/render/fast/Misc.java | 18 |
7 files changed, 57 insertions, 53 deletions
diff --git a/src/jake2/render/Base.java b/src/jake2/render/Base.java index ddec0d8..7997893 100644 --- a/src/jake2/render/Base.java +++ b/src/jake2/render/Base.java @@ -179,9 +179,8 @@ public abstract class Base implements QGLConst, RenderAPI { gl = (QGL)driver; } - public static void setVid(int width, int height) { - vid.width = width; - vid.height = height; + public static synchronized void setVid(int width, int height) { + vid.setSize(width, height); } }
\ No newline at end of file diff --git a/src/jake2/render/basic/Draw.java b/src/jake2/render/basic/Draw.java index a4347cb..52ee9fc 100644 --- a/src/jake2/render/basic/Draw.java +++ b/src/jake2/render/basic/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.2 2006-11-21 00:50:46 cawe Exp $ + * $Id: Draw.java,v 1.3 2008-03-02 14:56:23 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -290,9 +290,9 @@ public abstract class Draw extends Image { gl.glBegin(GL_QUADS); gl.glVertex2f(0,0); - gl.glVertex2f(vid.width, 0); - gl.glVertex2f(vid.width, vid.height); - gl.glVertex2f(0, vid.height); + gl.glVertex2f(vid.getWidth(), 0); + gl.glVertex2f(vid.getWidth(), vid.getHeight()); + gl.glVertex2f(0, vid.getHeight()); gl.glEnd(); gl.glColor4f(1,1,1,1); diff --git a/src/jake2/render/basic/Main.java b/src/jake2/render/basic/Main.java index 34545d7..8f46270 100644 --- a/src/jake2/render/basic/Main.java +++ b/src/jake2/render/basic/Main.java @@ -679,7 +679,7 @@ public abstract class Main extends Base { gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); gl.glScissor( r_newrefdef.x, - vid.height - r_newrefdef.height - r_newrefdef.y, + vid.getHeight() - r_newrefdef.height - r_newrefdef.y, r_newrefdef.width, r_newrefdef.height); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -715,10 +715,10 @@ public abstract class Main extends Base { // // set up viewport // - x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); - x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); - y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); - y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); + x = (int) Math.floor(r_newrefdef.x * vid.getWidth() / vid.getWidth()); + x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.getWidth() / vid.getWidth()); + y = (int) Math.floor(vid.getHeight() - r_newrefdef.y * vid.getHeight() / vid.getHeight()); + y2 = (int) Math.ceil(vid.getHeight() - (r_newrefdef.y + r_newrefdef.height) * vid.getHeight() / vid.getHeight()); w = x2 - x; h = y - y2; @@ -866,10 +866,10 @@ public abstract class Main extends Base { void R_SetGL2D() { // set 2D virtual screen size - gl.glViewport(0, 0, vid.width, vid.height); + gl.glViewport(0, 0, vid.getWidth(), vid.getHeight()); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); - gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + gl.glOrtho(0, vid.getWidth(), vid.getHeight(), 0, -99999, 99999); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glDisable(GL_DEPTH_TEST); @@ -1035,7 +1035,7 @@ public abstract class Main extends Base { vid_fullscreen.modified = false; gl_mode.modified = false; - Dimension dim = new Dimension(vid.width, vid.height); + Dimension dim = new Dimension(vid.getWidth(), vid.getHeight()); if ((err = glImpl.setMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) { gl_state.prev_mode = (int) gl_mode.value; @@ -1358,7 +1358,9 @@ public abstract class Main extends Base { @@@@@@@@@@@@@@@@@@@@@ */ public void R_BeginFrame(float camera_separation) { - + + vid.update(); + gl_state.camera_separation = camera_separation; /* @@ -1410,10 +1412,10 @@ public abstract class Main extends Base { /* ** go into 2D mode */ - gl.glViewport(0, 0, vid.width, vid.height); + gl.glViewport(0, 0, vid.getWidth(), vid.getHeight()); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); - gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + gl.glOrtho(0, vid.getWidth(), vid.getHeight(), 0, -99999, 99999); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glDisable(GL_DEPTH_TEST); diff --git a/src/jake2/render/basic/Misc.java b/src/jake2/render/basic/Misc.java index bc56f0e..a8c4b3e 100644 --- a/src/jake2/render/basic/Misc.java +++ b/src/jake2/render/basic/Misc.java @@ -2,7 +2,7 @@ * Misc.java * Copyright (C) 2003 * - * $Id: Misc.java,v 1.4 2007-01-11 23:36:15 cawe Exp $ + * $Id: Misc.java,v 1.5 2008-03-02 14:56:23 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -143,7 +143,7 @@ public final class Misc extends Mesh { try { RandomAccessFile out = new RandomAccessFile(file, "rw"); FileChannel ch = out.getChannel(); - int fileLength = TGA_HEADER_SIZE + vid.width * vid.height * 3; + int fileLength = TGA_HEADER_SIZE + vid.getWidth() * vid.getHeight() * 3; out.setLength(fileLength); MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, fileLength); @@ -151,10 +151,10 @@ public final class Misc extends Mesh { // write the TGA header image.put(0, (byte) 0).put(1, (byte) 0); image.put(2, (byte) 2); // uncompressed type - image.put(12, (byte) (vid.width & 0xFF)); // vid.width - image.put(13, (byte) (vid.width >> 8)); // vid.width - image.put(14, (byte) (vid.height & 0xFF)); // vid.height - image.put(15, (byte) (vid.height >> 8)); // vid.height + image.put(12, (byte) (vid.getWidth() & 0xFF)); // vid.getWidth() + image.put(13, (byte) (vid.getWidth() >> 8)); // vid.getWidth() + image.put(14, (byte) (vid.getHeight() & 0xFF)); // vid.getHeight() + image.put(15, (byte) (vid.getHeight() >> 8)); // vid.getHeight() image.put(16, (byte) 24); // pixel size // go to image data position @@ -163,7 +163,7 @@ public final class Misc extends Mesh { ByteBuffer rgb = image.slice(); // change pixel alignment for reading - if (vid.width % 4 != 0) { + if (vid.getWidth() % 4 != 0) { gl.glPixelStorei(GL_PACK_ALIGNMENT, 1); } @@ -172,10 +172,10 @@ public final class Misc extends Mesh { // e.g.: 1.5.2 NVIDIA 66.29 if (gl_config.getOpenGLVersion() >= 1.2f) { // read the BGR values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL_BGR, GL_UNSIGNED_BYTE, rgb); + gl.glReadPixels(0, 0, vid.getWidth(), vid.getHeight(), GL_BGR, GL_UNSIGNED_BYTE, rgb); } else { // read the RGB values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, rgb); + gl.glReadPixels(0, 0, vid.getWidth(), vid.getHeight(), GL_RGB, GL_UNSIGNED_BYTE, rgb); // flip RGB to BGR byte tmp; for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { diff --git a/src/jake2/render/fast/Draw.java b/src/jake2/render/fast/Draw.java index db6dfb2..6eeb937 100644 --- a/src/jake2/render/fast/Draw.java +++ b/src/jake2/render/fast/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.3 2007-05-12 23:20:29 cawe Exp $ + * $Id: Draw.java,v 1.4 2008-03-02 14:56:23 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -285,9 +285,9 @@ public abstract class Draw extends Image { gl.glBegin(GL_QUADS); gl.glVertex2f(0,0); - gl.glVertex2f(vid.width, 0); - gl.glVertex2f(vid.width, vid.height); - gl.glVertex2f(0, vid.height); + gl.glVertex2f(vid.getWidth(), 0); + gl.glVertex2f(vid.getWidth(), vid.getHeight()); + gl.glVertex2f(0, vid.getHeight()); gl.glEnd(); gl.glColor4f(1,1,1,1); diff --git a/src/jake2/render/fast/Main.java b/src/jake2/render/fast/Main.java index 98d2b2c..e5583cd 100644 --- a/src/jake2/render/fast/Main.java +++ b/src/jake2/render/fast/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.5 2006-12-12 14:46:04 cawe Exp $ + * $Id: Main.java,v 1.6 2008-03-02 14:56:23 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -667,7 +667,7 @@ public abstract class Main extends Base { gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f); gl.glScissor( r_newrefdef.x, - vid.height - r_newrefdef.height - r_newrefdef.y, + vid.getHeight() - r_newrefdef.height - r_newrefdef.y, r_newrefdef.width, r_newrefdef.height); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -705,14 +705,14 @@ public abstract class Main extends Base { // // set up viewport // - //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); + //int x = (int) Math.floor(r_newrefdef.x * vid.getWidth() / vid.getWidth()); int x = r_newrefdef.x; - //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); + //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.getWidth() / vid.getWidth()); int x2 = r_newrefdef.x + r_newrefdef.width; - //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); - int y = vid.height - r_newrefdef.y; - //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); - int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); + //int y = (int) Math.floor(vid.getHeight() - r_newrefdef.y * vid.getHeight() / vid.getHeight()); + int y = vid.getHeight() - r_newrefdef.y; + //int y2 = (int) Math.ceil(vid.getHeight() - (r_newrefdef.y + r_newrefdef.height) * vid.getHeight() / vid.getHeight()); + int y2 = vid.getHeight() - (r_newrefdef.y + r_newrefdef.height); int w = x2 - x; int h = y - y2; @@ -861,10 +861,10 @@ public abstract class Main extends Base { */ void R_SetGL2D() { // set 2D virtual screen size - gl.glViewport(0, 0, vid.width, vid.height); + gl.glViewport(0, 0, vid.getWidth(), vid.getHeight()); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); - gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + gl.glOrtho(0, vid.getWidth(), vid.getHeight(), 0, -99999, 99999); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glDisable(GL_DEPTH_TEST); @@ -1015,7 +1015,7 @@ public abstract class Main extends Base { vid_fullscreen.modified = false; gl_mode.modified = false; - Dimension dim = new Dimension(vid.width, vid.height); + Dimension dim = new Dimension(vid.getWidth(), vid.getHeight()); int err; // enum rserr_t if ((err = glImpl.setMode(dim, (int) gl_mode.value, fullscreen)) == rserr_ok) { @@ -1312,6 +1312,9 @@ public abstract class Main extends Base { * R_BeginFrame */ public void R_BeginFrame(float camera_separation) { + + vid.update(); + gl_state.camera_separation = camera_separation; @@ -1364,10 +1367,10 @@ public abstract class Main extends Base { /* ** go into 2D mode */ - gl.glViewport(0, 0, vid.width, vid.height); + gl.glViewport(0, 0, vid.getWidth(), vid.getHeight()); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); - gl.glOrtho(0, vid.width, vid.height, 0, -99999, 99999); + gl.glOrtho(0, vid.getWidth(), vid.getHeight(), 0, -99999, 99999); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); gl.glDisable(GL_DEPTH_TEST); diff --git a/src/jake2/render/fast/Misc.java b/src/jake2/render/fast/Misc.java index d611f34..0479d59 100644 --- a/src/jake2/render/fast/Misc.java +++ b/src/jake2/render/fast/Misc.java @@ -2,7 +2,7 @@ * Misc.java * Copyright (C) 2003 * - * $Id: Misc.java,v 1.4 2007-01-11 23:36:21 cawe Exp $ + * $Id: Misc.java,v 1.5 2008-03-02 14:56:23 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -136,7 +136,7 @@ public final class Misc extends Mesh { try { RandomAccessFile out = new RandomAccessFile(file, "rw"); FileChannel ch = out.getChannel(); - int fileLength = TGA_HEADER_SIZE + vid.width * vid.height * 3; + int fileLength = TGA_HEADER_SIZE + vid.getWidth() * vid.getHeight() * 3; out.setLength(fileLength); MappedByteBuffer image = ch.map(FileChannel.MapMode.READ_WRITE, 0, fileLength); @@ -144,10 +144,10 @@ public final class Misc extends Mesh { // write the TGA header image.put(0, (byte) 0).put(1, (byte) 0); image.put(2, (byte) 2); // uncompressed type - image.put(12, (byte) (vid.width & 0xFF)); // vid.width - image.put(13, (byte) (vid.width >> 8)); // vid.width - image.put(14, (byte) (vid.height & 0xFF)); // vid.height - image.put(15, (byte) (vid.height >> 8)); // vid.height + image.put(12, (byte) (vid.getWidth() & 0xFF)); // vid.getWidth() + image.put(13, (byte) (vid.getWidth() >> 8)); // vid.getWidth() + image.put(14, (byte) (vid.getHeight() & 0xFF)); // vid.getHeight() + image.put(15, (byte) (vid.getHeight() >> 8)); // vid.getHeight() image.put(16, (byte) 24); // pixel size // go to image data position @@ -155,7 +155,7 @@ public final class Misc extends Mesh { // change pixel alignment for reading - if (vid.width % 4 != 0) { + if (vid.getWidth() % 4 != 0) { gl.glPixelStorei(GL_PACK_ALIGNMENT, 1); } @@ -164,10 +164,10 @@ public final class Misc extends Mesh { // e.g.: 1.5.2 NVIDIA 66.29 if (gl_config.getOpenGLVersion() >= 1.2f) { // read the BGR values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL_BGR, GL_UNSIGNED_BYTE, image); + gl.glReadPixels(0, 0, vid.getWidth(), vid.getHeight(), GL_BGR, GL_UNSIGNED_BYTE, image); } else { // read the RGB values into the image buffer - gl.glReadPixels(0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, image); + gl.glReadPixels(0, 0, vid.getWidth(), vid.getHeight(), GL_RGB, GL_UNSIGNED_BYTE, image); // flip RGB to BGR byte tmp; for (i = TGA_HEADER_SIZE; i < fileLength; i += 3) { |