Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2] 3 4
  ignore  |  Print  
  Anyone working on the NeHe tutorials?  (Read 16233 times)
0 Members and 1 Guest are viewing this topic.
Offline Caoimhin

Junior Member





« Reply #30 - Posted 2003-09-09 22:07:20 »

Quote

My demos as you mentioned defaults to the desktop resolution when fullscreen is set to true. However it takes one line of code to change that to whatever resolution, refresh rate, color depth you want.

Great, please put in that line of code.  It should set to 640x480@60hz.  That's safe on even the older monitors.  I'm sure what color depth to default to.  Either 16 or 32, but there should probably also be some fallback routine in case the mode is unavailable.  I think 640x480:16@60 should work on all cards.

Quote

Also, man I'm impressed to hear that there are people running their desktop at the amazing resolution that is 1600*1200, you must have one excellent 19" monitor or simply a good 21", I'm envious Grin.

Yeah, but this pc doesn't have a nice graphics card to match.  It's an ATI Rage 128 Ultra.   :-/  At home, I've a GeForce2 in my laptop.  It's nice, but it's aging.
Offline Java Cool Dude

Senior Member




Java forever


« Reply #31 - Posted 2003-09-11 02:10:34 »

Lesson09 NEW!!

I have updated all of my demos to work with Bitmaps instead of cheap PNGs, JPGs or GIFs.
I created a new texture loader that loads most of the common formats, I still have to implement TGA loading though, or steal pepi's work Grin
Please redownload those, the quality of the textures is frankly better Smiley

Lesson12
Lesson18
Lesson22
Lesson27
Lesson37

PS: I can't get monitor resolution to change on my pc, it always reports a runtime error Cry
Offline pepijnve

Junior Member




Java games rock!


« Reply #32 - Posted 2003-09-11 08:25:32 »

Feel free to use the tga loading from the relevant lesson. No use in reimplemting this. I do want to warn you that the TGA loading code is C-ish Java Grin
About the resolution switch: have you already set the fullscreen window when you call setDisplayMode. I think the docs mention that you have to be in fullscreen mode before being able to switch or otherwise you could get an exception.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Java Cool Dude

Senior Member




Java forever


« Reply #33 - Posted 2003-09-11 13:05:05 »

Lesson34 NEW!!

I got fullscreen that defaults to 640*480 16Bpp @60Hz working in all my ports, two enthusiastics thumbs up for pepi Grin

If you don't feel like re-downloading the demos and thus saving your bw, please replace the following line of code

   if(fullScreen==0)
     GraphicsEnvironment.getLocalGraphicsEnvironment().
     getDefaultScreenDevice().setFullScreenWindow(frame);


with this one

   if(fullScreen==0){
     GraphicsEnvironment.getLocalGraphicsEnvironment().
     getDefaultScreenDevice().setFullScreenWindow(frame);
     GraphicsEnvironment.getLocalGraphicsEnvironment().
     getDefaultScreenDevice().setDisplayMode((new DisplayMode(640, 480, 16, 60)));
   }


Updated:
Lesson09
Lesson12
Lesson18
Lesson22
Lesson27
Lesson37
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #34 - Posted 2003-09-11 17:36:16 »

There's a minimal TGA loader in the jogl-demos source tree.

Anyone up to the task of collecting all of these NeHe ports and getting them checked in to the jogl-demos tree?
Offline Java Cool Dude

Senior Member




Java forever


« Reply #35 - Posted 2003-09-11 17:45:44 »

Quote
There's a minimal TGA loader in the jogl-demos source tree.

As opposed to personal loader-> patting one's ego on the back Grin
Offline nlmueng

Junior Member





« Reply #36 - Posted 2003-09-12 16:05:51 »

I have all the examples done so far into the structure used by the demos area.  The package is demos.nehe.lessonXX.  All the data goes into demos.data.images or demos.data.models

I had to change some of the code to have it work correctly  when run from a jar or the command line.   Should clean some of it up at some point but for now here it is:

http://nlmueng.com/demos.jar

It is over a meg.
Offline Xerif

Junior Newbie




Java games rock!


« Reply #37 - Posted 2003-09-12 21:24:46 »

Quote
dum dee dee dum dee dum dum Another one bites the dust....
Lesson 18
Nforce2 Mobo


When I start this Lesson18 i got an "An unexpected exception has been detected in native code outside the VM. (....)
at net.java.games.jogl.impl.windows.WindowsGLImpl.glDisable(Native Method)
     at Lesson18.keyPressed(Lesson18.java:284)
"

So, if I want to run properly this lesson18, I must change the code and move lines "      if(!light)
       gl.glDisable(GL.GL_LIGHTING);
     else
       gl.glEnable(GL.GL_LIGHTING);" in the keyPressed method just after the line 215 ("gl.glBindTexture(gl.GL_TEXTURE_2D, texture[filter]);")

and now it's work fine.

I have a GeForce4TI4200 with the Nvidia Driver 44.67 and JVM "1.4.1-b21 mixed mode"

Xerif
bye
Offline wz

Senior Newbie




Linux sucks!


« Reply #38 - Posted 2003-09-12 21:42:37 »

I got this kind of errors for the most of the tutorials and reported one before. I am using RH linux 7.2 and not sure about graphic card and driver.

But I can run the c code from NEHE with some modification. For example, The lesson 11. I changed
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) to without using GLUT_ALPHA), then the c code runs fine.

Thanks.

wz
Offline Sylvie

Senior Newbie




Java games rock!


« Reply #39 - Posted 2003-09-12 22:05:40 »

I have noticed a similar problem running Jogl on Linux. It seems that requesting an alpha component for the color buffer crashes the default graphics driver (I'm running RedHat 9.0). For me, switching to use the default GLCapabilities parameters, which requests 0 alpha bits, fixed my problem.

Sean
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Java Cool Dude

Senior Member




Java forever


« Reply #40 - Posted 2003-09-12 22:19:16 »

Quote


When I start this Lesson18 i got an "An unexpected exception has been detected in native code outside the VM. (....)
at net.java.games.jogl.impl.windows.WindowsGLImpl.glDisable(Native Method)
     at Lesson18.keyPressed(Lesson18.java:284)
"

So, if I want to run properly this lesson18, I must change the code and move lines "      if(!light)
       gl.glDisable(GL.GL_LIGHTING);
     else
       gl.glEnable(GL.GL_LIGHTING);" in the keyPressed method just after the line 215 ("gl.glBindTexture(gl.GL_TEXTURE_2D, texture[filter]);")

and now it's work fine.

I have a GeForce4TI4200 with the Nvidia Driver 44.67 and JVM "1.4.1-b21 mixed mode"

Xerif
bye


Doh I was aware of that bug ever since I ported the demo, and yet I didn't fix it on time and then I got sucked into other stuff and completely forgot about it ....that's just lame :-/
But the fix consists in changing those lines position to somewhere else, you are right Smiley
Offline wz

Senior Newbie




Linux sucks!


« Reply #41 - Posted 2003-09-12 22:26:36 »

Hi, Sean,

Thanks for replying. Where and how did you change GLCapability in JOGL?

wz
Offline Sylvie

Senior Newbie




Java games rock!


« Reply #42 - Posted 2003-09-12 23:04:50 »


To change the capabilities in Jogl...

Assuming you are using the AWT or Swing components provided in Jogl, then you would create a GLCanvas (AWT) or GLJPanel (Swing) using a GLCapabilities object and put these components in a Frame or JFrame. So, to create a GLCanvas, the following code might be used:

GLCapabilities vCapabilities = new GLCapabilities();
GLCanvas vCanvas =
   GLDrawableFactory.getFactory().createGLCanvas(vCapabilities);

To request a canvas with different properties, use the methods provided by GLCapabilities and pass it into the createGLCanvas() factory method. Hope this helps.

Sean
Offline Java Cool Dude

Senior Member




Java forever


« Reply #43 - Posted 2003-09-12 23:32:38 »

Lesson24 NEW!
PS: Char arrays are evil(took me 2 hours to realize what was wrong in my code Angry ), stick with bytes Cool
Lesson18 Fixed minor bug in disable/enable lighting.

Offline Java Cool Dude

Senior Member




Java forever


« Reply #44 - Posted 2003-09-13 08:41:37 »

Lesson30 NEW!

Alright I spent about 7 hours STRAIGHT working on the linked port to have it finally up and running; damn my eyes are almost bleeding now that I'm done Cry
I have one bug that I couldn't fix though, and hence the main reason behind posting the whole source this early to get some help.
Basically when I change the size of the frame on runtime an exception occurs and the demo stops.
That same bug prohibits me from accessing the fullscreen mode, any help would be appreciated Smiley
Now my other concern is rather a matter of taste and high standards: Java audio playbacknever was my thing as it truly sounds hideous.
My suggestions is to hit F3 immidiately after starting the demo, otherwise don't blame me for harming your sensitive ears Grin
/me thinks it's about time he takes a closer look at JOAL Smiley

Offline Java Cool Dude

Senior Member




Java forever


« Reply #45 - Posted 2003-09-13 21:43:20 »

New addition: Multiple sounds played at once, and a lot better playback quality (still not good enough, might work on an mp3 loader and add it later on).

Any suggestions on the resize bug? I wanna move on to my two lasts port, I have a [censored] load of homework sitting on my desk Cry
Offline quintesse

Junior Member




Java games rock!


« Reply #46 - Posted 2003-09-15 08:41:57 »

Any idea when we can expect all the code to appear on the NeHe site?
Offline JorritK

Innocent Bystander




They broke my watch


« Reply #47 - Posted 2003-09-15 13:21:44 »

Quote

If we could come up with a common framework and distribution, then I'd be willing to use a common utility class.  But the three of us are not packaging our tutorials the same or even structuring the code in a similar manner.  Writing a common utility class we cna use might be hard.


The ported NeHe tutorials are great, but as Caoimhin already commented, not consistent.

The advantage of consistency between the lessons is that a total newbie can understand what a particular piece of code does. He isn't confronted by new ways of programming, which is particularly helpful when learning a complete new area. I don't consider myself to be a newbie in Java programming, but I am one in OpenGL.

I adopted Caoimhin's way of programming for doing these NeHe tutorials simply because he did the first seven lessons. It has some advantages and disadvantages, which I'm not going to discuss.

Maybe you guys can come up with a different way of presenting these lessons for what it's worth. It doesn't really matter, as long as they look the same. And I think that should be your ultimate goal.
Offline pepijnve

Junior Member




Java games rock!


« Reply #48 - Posted 2003-09-15 15:03:21 »

I agree that we should use a common base for the tutorials. What I tried to do in my code is to not pollute the 'lesson code' with basic jogl setup code (the component, fullscreen stuff, etc). It was an effort to keep the essence of the lessons (the actual OpenGL code) in one place.
What do you guys suggest for a clean common base? If we can agree on a common base or someone provides one, I would be happy to port the code I've written.
Offline nlmueng

Junior Member





« Reply #49 - Posted 2003-09-15 15:18:20 »

I would be happy to port them all to the same format too when they are done, I already moved them all to the same package structure and modified them so they work from a jar and command line, and also made it so they work in both linux and windows.  

I agree with pepijnve that the jogl code should be seperated out from the other code.  I like how he setup his code, allows for easy reading.

nathan
Offline wz

Senior Newbie




Linux sucks!


« Reply #50 - Posted 2003-09-15 16:13:10 »

Hi, JOGL gurus,

When I run your NEHE programs, I had a lot of exceptions out ot JVM as I stated in previous posts, for example Lesson 11.  Then in  Lesson 11 and Lesson 3, I had to create an Animator animator = new Animator(canvas), then use animator.start() to run it. I am using RH linux 7.2 and old hardware. Does anybody knows why??? Why was animator not used in the examples??? Any particular reasons? I want to find out the cause of the problems so that I do not have to change every program.

Actually, after I fixed Lesson 11, it runs better than the C code on my work station.  When I run C code, there is not much animation. But when I run jogl, it flys.

Thank you very much.

wz
Offline pepijnve

Junior Member




Java games rock!


« Reply #51 - Posted 2003-09-15 17:24:26 »

I'll modify the code I wrote to use Animator, since this seems to be more compatible. The only real difference between the two is which thread is doing the rendering. In the case of Animator it's a separate thread. In my code it's the AWT thread. If this really causes that much problems, it looks to me as a bug in jogl rather than a bug in the code.
Offline wz

Senior Newbie




Linux sucks!


« Reply #52 - Posted 2003-09-15 17:38:16 »

Hi,

Thank you very much for letting me know the difference. I agree that the problem may be in jogl since all other parts of the code work well after using animator. Maybe somebody from JOGL developing team can answer the question.

Thanks again.

wz
Offline Java Cool Dude

Senior Member




Java forever


« Reply #53 - Posted 2003-09-15 19:10:12 »

I'd go for the common work frame, but so far the only difference that my code holds against Nehe's is just the basic Java set up for a Canvas
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  
41  
42  
43  
44  
45  
46  
  public static void main(String []args) {

    int fullScreen = JOptionPane.showConfirmDialog(        null, "Would you like to run in fullscreen mode?",
                                                   "Fullscreen",  JOptionPane.YES_NO_OPTION);

    frame          = new JFrame();
    demo           = new Lesson30();
    screenWidth    = Toolkit.getDefaultToolkit().getScreenSize().width;
    screenHeight   = Toolkit.getDefaultToolkit().getScreenSize().height;

    switch(fullScreen){
      case 0:
        frame.setUndecorated(true);
      break;
      default:
        canvasWidth  = 640;
        canvasHeight = 480;
        xLocation    = (screenWidth  - canvasWidth )>>1;
        yLocation    = (screenHeight - canvasHeight)>>1;
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocation(xLocation,yLocation);
    }

    frame.getContentPane().add(demo.getCanvas(canvasWidth, canvasHeight),
                                              BorderLayout.CENTER);
    frame.pack();
    frame.requestFocus();
    frame.setVisible(true);

    if(fullScreen==0){
      GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().setFullScreenWindow(frame);
      GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().setDisplayMode((new DisplayMode(640, 480, 32, 60)));
    }
  }

  GLCanvas getCanvas(int w,int h){

    canvas  = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
    canvas.setSize(new Dimension(w,h));
    canvas.addGLEventListener((renderer = new initRenderer(demo)));
    frame.addKeyListener(this);
    canvas.addKeyListener(this);
    return canvas;
  }


I also include an extra class for the animation
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  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
import net.java.games.jogl.*;

public class initRenderer implements GLEventListener
{
  GL              gl;
  GLU             glu;
  Lesson30        main;
  GLDrawable      glDrawable;

  initRenderer(Lesson30 main){
    this.main         = main;
  }

  public void init(GLDrawable drawable){

    this.gl         = drawable.getGL();
    this.glu        = drawable.getGLU();
    this.glDrawable = drawable;

    main.gl         = gl;
    main.glu        = glu;

    main.initialize();
    drawable.setGL( new DebugGL(drawable.getGL()));
  }

  public void display(GLDrawable drawable){
    main.display();
  }

  public void reshape(GLDrawable drawable,
                      int xstart,
                      int ystart,
                      int width,
                      int height){

    height = (height == 0) ? 1 : height;

    gl.glViewport(0,0,width,height);         // Reset The Current Viewport
   gl.glMatrixMode(gl.GL_PROJECTION);       // Select The Projection Matrix
   gl.glLoadIdentity();                     // Reset The Projection Matrix

   // Calculate The Aspect Ratio Of The Window
   glu.gluPerspective(50.0f,(float)width/height,10.f,1700.0f);

    gl.glMatrixMode(gl.GL_MODELVIEW);        // Select The Modelview Matrix
   gl.glLoadIdentity();
  }

  public void displayChanged(GLDrawable drawable,
                             boolean modeChanged,
                             boolean deviceChanged){}
}


If a common frame has to be set, I would like to see fullscreen  implementation in it, actually I can take care of that part if no one sees harm.
Offline pepijnve

Junior Member




Java games rock!


« Reply #54 - Posted 2003-09-15 21:39:20 »

I reworked my code a bit and here is the end result http://pepijn.fab4.be/nehe/nehe-demos.zip. These are all the lessons I ported in one big zip. They now use a modified Animator class that has some very basic frame rate control. I also integrated the fullscreen stuff from JavaCoolDudes ports.
w0zhang: does this version work better?
Offline Caoimhin

Junior Member





« Reply #55 - Posted 2003-09-15 22:47:33 »

I won't be touching anything for the next week or two.  I've a dev deadline at work.   :-/
Offline wz

Senior Newbie




Linux sucks!


« Reply #56 - Posted 2003-09-15 23:01:43 »

Hi, Pepijnve,

Thanks a lot. There is one small glitch. You used Animator(canvas, 60), but I could not find such constructor for Animator in my JOGL lib. I think I am using the Sept. 5 release. After I changed it to Animator(canvas), it worked great. I tried lesson 11 and 14. It is great that you put commonlly used file in one folder.

I used C OpenGL before. It seems that this java stuff is much less portable than C!!! :-(

Thanks again. I had problem with every NEHE demo and was not targeting you. :-)

wz
Offline pepijnve

Junior Member




Java games rock!


« Reply #57 - Posted 2003-09-15 23:23:06 »

I had modified Animator to have this extra constructor. The extra integer is a desired frame rate. This modified version of Animator was also included in the zip file. To make things clearer, I've renamed my modified Animator to FPSAnimator (should have done this in the first place). It still has to be in the net.java.games.jogl package since Animator uses some package visible methods of GLCanvas.
The file at the previous URL contains the updated version.
Offline mockum

Junior Newbie




Java games rock!


« Reply #58 - Posted 2003-09-16 04:13:58 »

pepijnve,

I have jogl installed as an extension to my 1.4.2 JRE and am getting an IllegalAccessException with FPSAnimator.   Since there is only one line that needs to access package visible methods and it is in the Animator constructor, we can have FPSAnimator extend Animator without having to play tricks with packaging.  Like so:

package demos.nehe.common;
...
public class FPSAnimator extends Animator {
...
   /** Creates a new Animator for a particular drawable. */
   public FPSAnimator(GLDrawable drawable, int fps) {
       super(drawable);
       this.drawable = drawable;
       this.delay = 1000 / fps;
   }
...

Everything else is the same.  Also please include your build script in the .zip.

Thanks for your work.
Offline pepijnve

Junior Member




Java games rock!


« Reply #59 - Posted 2003-09-16 07:40:34 »

Ok thanks for the advice. I've applied the change and updated the zip file on my server. I hadn't realized that only GLCanvas.willSetRenderingThread is package visible and the other methods related to the rendering thread are public.
Right now I don't have a build script yet  Grin I just let my IDE do all the work. I'll write a little ant script tonight if I find some time.
Pages: 1 [2] 3 4
  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.

xsi3rr4x (73 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!