Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED] LWJGL Visual Illusion Problem  (Read 700 times)
0 Members and 1 Guest are viewing this topic.
Offline Vladiedoo
« Posted 2012-11-20 00:01:45 »

Hi, so I obtained source code from http://www.youtube.com/watch?v=O0xtgfcxcq0&feature=plcp but noticed a strange visual effect.

I plugged in the code and when looking directly down onto a block this occurred.




I have jumped around with learning OpenGL but I've firmly started recently but I havn't been able to resolve the issue, yet.

Here is parts of the code that hopefully explains the problem
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
      static int width=800, height=600;
// ---------------------------------------------------------------------------------
     DisplayMode dm = new DisplayMode(width,height);
      for(DisplayMode mode : Display.getAvailableDisplayModes()){
         if(mode.getWidth() == 800 && mode.getHeight() == 600 && mode.isFullscreenCapable() && mode.getBitsPerPixel() == 32){
            dm = mode;
            break;
         }
      }
      if(dm.isFullscreenCapable()) Display.setFullscreen(false);
      Display.setDisplayMode(dm);
      Display.create();
// ------------------------------------------------------------------------------------

   private void initGL3() {
      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glLoadIdentity();

      GLU.gluPerspective((float) 100, App.width / App.height, 0.001f, 1000);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);

      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glShadeModel(GL11.GL_SMOOTH);
      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
      GL11.glClearDepth(1.0f);
      GL11.glEnable(GL11.GL_DEPTH_TEST);
      GL11.glDepthFunc(GL11.GL_LEQUAL);
   }

//    This is one of the crates that are being drawn.
//    float startX, float startY, float startZ, float endX, float endY, float endZ, Texture texSurround
     collidable.add(new PolyVoxel(20, 0.1f, 2, 22, 2, 4, texCrate));

// Rotation values are created from mouse movement (FPS camera).
  public void translateCamera() {
      GL11.glRotatef(rotation.x, 1, 0, 0);
      GL11.glRotatef(rotation.y, 0, 1, 0);
      GL11.glRotatef(rotation.z, 0, 0, 1);
      GL11.glTranslatef(-vector.x, -vector.y - 1.4f, -vector.z);
   }


Sorry for the long post, if someone could point me in the right direction I would be grateful, thanks for your time.
Offline theagentd
« Reply #1 - Posted 2012-11-20 00:33:56 »

Your call to GLU.gluPerspective() most likely screws up the aspect ratio. App.width and App.height are both ints, right? That means that App.width / App.height = 1 in most cases since effectively the decimals are getting cut off. You should just change it to
1  
(float)App.width / App.height

which should solve the problem.

Myomyomyo.
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #2 - Posted 2012-11-20 00:34:14 »

That usually means you've got your aspect ratio (second parameter to gluPerspective) wrong.

Are App.width and App.height ints? Because you may be getting integer divide so your aspect is incorrectly 1 rather than 1.6 (or whatever).

Edit: Spooky double post! persecutioncomplex

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2012-11-20 00:35:26 »

18 seconds too slow, sucker!  Grin

Myomyomyo.
Offline Vladiedoo
« Reply #4 - Posted 2012-11-20 00:36:45 »

[size=10pt]Excellent![/size] Thank you so much, that solved the issue. (Credits go to the answer that is 18 seconds faster of course  Pointing)
Offline theagentd
« Reply #5 - Posted 2012-11-20 00:50:50 »

[size=10pt]Excellent![/size] Thank you so much, that solved the issue. (Credits go to the answer that is 18 seconds faster of course  Pointing)
Yatta! Cool

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!