Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[java] Magician or Gl4java


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 06 October 2000 - 07:44 PM

Hello im learning java at the moment but i wanna start learning opengl aswell. should i use gl4java or magician ? i can''t seem to find any information relating to these specificly. Does anyone know of some tutorials for implementing them ? i wanted to start working through NEHE''S opengl tutorials as a start.

Sponsor:

#2 Jerry Lynn   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 October 2000 - 05:21 PM

I don''t have an answer for you, but I can tell you a couple of things to consider.

SGI has recommended to the ARB that Magician be adopted as the OpenGL standard for java bindings, so that is one mark in its favor.

You mentioned that you were interested in working through the Nehe tutorials. The Nehe tutorials have been ported to Java by Hodglimm (linked below), but he used the GL4Java API. I would imagine this is a mark in favor of using GL4Java. I am not aware of Nehe ports that use Magician.

The Nehe tutorials and the Java port are linked from the FAQ. There is also an article with information on Magician but its somewhat outdated (from back when Magician was to be cancelled).

http://games.cpbinc.com/faq/ogl.asp

I am not as familiar with GL4Java, so I can''t give you a personal impression. Magician has worked well for me. The performance is good and overall its very stable (though I did have some problems with Magician and earlier versions of my video card drivers). Magician does a really good job of leveraging Java''s OO capabilities while not straying too far from the standard OpenGL approach (as least in my opinion).



#3 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 October 2000 - 06:17 PM

Thx jarry for the responce, one thing that is holding me back from learning opengl is how magician is supposed to work with java. What i mean is the docs that accompany magician provide code examples of how magician+opengl+java work together, yet i don''t know opengl. The docs atleast in my opinion don''t explain magician from a beginners point of view one that doesn''t know opengl. How am i supposed to learn opengl using java if magician does''t have any docs assuming no prior opengl knowledge ?

#4 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 08 October 2000 - 03:24 PM

Here is what you do to use Magician:
1 - Aquire OpenGL Red Book
2 - Find a demo that came with Magician such as openGL/logo.java
3 - Erase all code that is applet only ( init(), start()... )
4 - Erase all code that makes the letters
5 - Erase all the comments at the top because they annoy me
6 - Keep the rest

Basically what is left is what you would have if you were using GLUT with C/C++. You will have to erase a bunch of code, like the lighting and material stuff int the initialize() method, that the old app used but you should be able to see the basics of opengl especially if you follow step one. The book will make it alot easier. I am seriously thinking about setting up a small site for Magician demos, maybe some NeHe ports but I might not have a place for it next semester and I know little html. If you wait a week I MAY have some more help for you. I looked to see if I have some of the early Magician stuff I did but I wrote over them and they are a little messy to be useful. I will probably clean the stuff up and put up the first NeHe tut or one from the red book tomorrow. At the very least I will post the frame work for the basic Magician app.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

#5 Jerry Lynn   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 October 2000 - 03:27 AM

Well, looks like GKW beat me to the answer...

Magician''s implementation of OpenGL is not substantially different from standard OpenGL. In a couple of cases there are some minor variations, such as Magician using overloaded methods to handle various data type lengths rather than multiple methods with slightly different names. Any reference on OpenGL should do fine for you. The OpenGL SuperBible is another great starting place.

It is going to be more difficult to learn OpenGL in Java than it would be to do so with C++. I am not aware of any books that teach OpenGL in Java - and I have looked for several months now. Its kind of depressing in a a way. I know of several resources for learning OpenGL in Delphi or Visual Basic, but few for Java.

#6 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 October 2000 - 10:47 AM

Thx GKW and Jarry for the responces
i really appreciate them, GKW if you could tell me when you have any magician related material that would be great.

#7 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 09 October 2000 - 05:52 PM

I put together a little application that draws a triangle and a quad like one of the nehe tutorials I hope it looks alright in the forum. I am going to try an set up a site and post it there. But this is it for tonight. Vikes suck.

Jerry - Have you ever tried to do a JApplet with Magician? I get a can''t find GLEventListener class. AWT applets work fine. Not a big deal but I would like to know why it does not work.

/*

MagicianTemplate.java



This app just draws a triangle and a rectangle but

you can erase the drawing code and put your

own in and you should have a working application.

This application uses Swing so get JRE 1.3.



Magician uses AWT canvas which is incompatable

with the lightweight Swing components but

work arounds exist. I hope this will be fixed

in JRE 1.4



GKW

*/





import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import com.hermetica.magician.*;



public class MagicianTemplate extends JFrame implements GLEventListener, WindowListener {



// Components of the Magician OpenGL state machine

GL gl = null;

CoreGL coregl = new CoreGL();

GLU glu = null;

CoreGLU coreglu = new CoreGLU();



// The GLComponent is the canvas where the graphics will be rendered

GLComponent glc = null;



// Creates new form MagicianTemplate

public MagicianTemplate() {

// Sets up the the OpenGL state machine

gl = coregl;

glu = coreglu;

setTitle( "Magician Template" );

}



public static void main (String args[]) {

MagicianTemplate mt = new MagicianTemplate();

// Initializes the GLComponent for drawing

mt.setupGL();

}



// Called once when the GLComponent is initialized

public void initialize(final com.hermetica.magician.GLDrawable p1) {

/* Sets the color that the color buffer is filled with

during the glClear call in display() */



gl.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );



/* Depth buffer is now enabled

It is not needed in this application but it gives

you an idea of what can be put in initialize() */



gl.glEnable( GL.GL_DEPTH_TEST );

}



// Handles the drawing

public void display(final com.hermetica.magician.GLDrawable p1) {

/* Clears the color buffer and the depth buffer. If you don''t

clear them then the values from the last time display() was

called will still be there and cause unintended results. */



gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );



/* Loads the identity matrix onto the stack. In this case

it is the MODELVIEW matrix which was set in reshape(). */



gl.glLoadIdentity();



/* Moves all geometry after this call 2.0 units into the

screen.*/



gl.glTranslated( 0.0d, 0.0d, -2.0d );



/* Saves the current matrix onto the stack to isolate the

translation for the triangle from the quad. I did push

the last translation onto the stack because I want both

the triangle and the rectangle to be moved away from the

viewer. */



gl.glPushMatrix();



/* Moves the origin -2.5 units along the x-axis */



gl.glTranslated( -2.5d, 0.0d, 0.0d );



/* Draws a triangle. Don''t forget the glEnd() or things

will get funky. */



gl.glBegin( GL.GL_TRIANGLES );

gl.glVertex3d( 0.0d, 1.0d, 0.0d );

gl.glVertex3d( -1.0d, 0.0d, 0.0d );

gl.glVertex3d( 1.0d, 0.0d, 0.0d );

gl.glEnd();



/* Destroys the current matrix and replaces it with the

last matrix pushed onto the stack. The origin is now

restored to the earlier matrix when the origin was at

( 0.0, 0.0, -2.0 ). */



gl.glPopMatrix();



/* Since this application is so simple I don''t really

need to save the current matrix again but I am. */



gl.glPushMatrix();



/* Move the origin 2.5 along the x-axis */



gl.glTranslated( 2.5d, 0.0d, 0.0d );



/* Draws a rectangle */



gl.glBegin( GL.GL_QUADS );

gl.glVertex3d( -1.0d, 1.0d, 0.0d );

gl.glVertex3d( -1.0d, 0.0d, 0.0d );

gl.glVertex3d( 1.0d, 0.0d, 0.0d );

gl.glVertex3d( 1.0d, 1.0d, 0.0d );

gl.glEnd();



/* Don''t really need this either for this application */

gl.glPopMatrix();



/* Kicks the machine into gear if it isn''t already. */

gl.glFlush();

}



/* Called at the creation of the rendering canvas and when

ever the canvas is resized in the GUI. */



public void reshape( GLDrawable component, int x, int y, int width, int height ) {



/* Sets up the viewport */

gl.glViewport( component, x, y, width, height );



/* Makes the prjection matrix the current matrix */

gl.glMatrixMode( GL.GL_PROJECTION );



/* Load the identity matrix into the projection matrix

just to make sure it is clean. */

gl.glLoadIdentity();



/* Sets up the view frustrum. Make sure the near and

far clipping planes are positive. */

gl.glFrustum( -2.0, 2.0, -2.0, 2.0, 1.0, 5.0 );



/* Changes the matrix to the Modelview matrix. This

is the matrix that moves and rotates your geometry. */

gl.glMatrixMode( GL.GL_MODELVIEW );



/* Load the identity matrix. Make sure the matrix is

clean. */

gl.glLoadIdentity();

}

/* Returns the state machine */

public GL getGL() {

return( gl );

}



public void windowDeactivated(final java.awt.event.WindowEvent p1) {

}



public void windowClosed(final java.awt.event.WindowEvent p1) {

}



public void windowDeiconified(final java.awt.event.WindowEvent p1) {

}



public void windowOpened(final java.awt.event.WindowEvent p1) {

}



public void windowIconified(final java.awt.event.WindowEvent p1) {

}



public void windowClosing(final java.awt.event.WindowEvent p1) {

if( glc != null ) {

/* This has to be called to release the memory associated

with the rendering canvas. On my machine it is about

200k. */

glc.destroy();

}

setVisible( false );

dispose();

System.exit( 1 );

}



public void windowActivated(final java.awt.event.WindowEvent p1) {

}



/* Sets up the rendering canvas. */

public void setupGL() {

/* GLDrawableFactory is the call you want to make to create

a rendering canvas. There is a class called GLComponentFactory

but that was used in an earlier version of Magician.

This call sets the size of the canvas to 400 x 400. */

glc = (GLComponent)GLDrawableFactory.createGLComponent( 400, 400 );



/* Adds the rendering canvas to the JFrame. */

getContentPane().add( glc, BorderLayout.CENTER );



/* You have to make the rendering canvas visible before you call

GLComponent.initialize() or an exception will be thrown. So

do a setVisible( true ) or a pack(). */

pack();

show();



/* Gets the capabilities of the canvas. */

GLCapabilities caps = glc.getContext().getCapabilities();



/* Don''t need to set the depth bits for this app but here it is */

caps.setDepthBits( 8 );

/* Sets to RGBA pixels instead of color-indexed */

caps.setPixelType( GLCapabilities.RGBA );

/* Stores 32 per pixel. Does not change hardware settings.

JRE 1.4 is supposed to support fullscreen java apps so

is may change hardware setting then. */

caps.setColourBits( 32 );



/* Sets up double buffering for faster rendering. Does not

matter in this case. */

caps.setDoubleBuffered( GLCapabilities.DOUBLEBUFFER );



/* Sets up the listeners for the app. If you don''t add

the GLEventListener then the rendering canvas won''t

do anything. */

addWindowListener( this );

glc.addGLEventListener( this );



/* Initializes the canvas. Make sure the GLComponent is visible

on the screen or an exception will be thrown. */

glc.initialize();

}

}


I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

#8 Jerry Lynn   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 October 2000 - 05:26 AM

Sorry, no. All of my Magician work has been with applications (extending JFrame or JWindow and implementing my GLEventListener on the subclass).

I can''t see why subclassing a JApplet would cause the problem you mentioned. JApplet is heavy-wieght container isn''t it (I will need to look that up to be sure)? Nothing that I know of about subclassing the JApplet should interfere with implementing the GLEventListener interface...

Like I said, I am not familiar with using Magician in applets, but if post some code I could take a look and at least brainstorm a little on what might be the problem.

#9 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 10 October 2000 - 07:46 AM

I should have said that it was the java plugin that is not working. Without the java plugin a normal awt applet works fine but if I use the converter from sun and try the same applet I get the can''t find GLEventListener class. Without the plugin I can''t use JApplet but it is the plugin that is not working right. If you can just try one of the demo applets with the java plugin I would appreciate it.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

#10 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 October 2000 - 08:16 AM

yeah, i think a web site devoted to magician would be grea jarry
it would sure help my sorry ass out. you should also try and get gamedev.net to host it for you.

#11 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 12 October 2000 - 06:01 PM

I am no web designer but take a look. Damn applets and jars are still pissing me off. And if gamedev would host it that would be cool because I really hate those damn banners. Freeservers say they don''t much info on people so I went with them. And they don''t appropriate ip like yahoo.

java.lang.NoClassDefFoundError: com/hermetica/magician/GLEventListener
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

#12 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 October 2000 - 06:32 PM

Great first attempt at a web site dude

im sure you''ll help alot of people with your information regarding magician.
some magician specific information would be great to start off.
as to get those of use starting out like myself well versed in it before the plunge into opengl

have you talked to gamedev regarding hosting the site ?

#13 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 15 October 2000 - 01:06 PM

Can you be more specific as to what you would like a tutorial on? The GLComponent is basically a AWT Canvas, so in that respect it is no different than normal java GUI stuff. You just get to issue special commands for OpenGL to it. Do you want someing that explains GLComponent, GLEventListener, ...? I don''t know what your knowledge of Java is but you should probalble be somewhat fluent in Java before you start on Magician. I have been told that I am not a good teacher so give me as much feedback as you can. Something about my inability to suffer fools gladly.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!

#14 alert   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 October 2000 - 04:05 PM

Well i just started learning java and havn''t got into any awt related stuff yet.
but i wanna get into anything that is graphics related right away


#15 GKW   Members   -  Reputation: 200

Like
Likes
Like

Posted 16 October 2000 - 08:31 AM

You need to learn about AWT and events before you start on Magician. I know 3D graphics are cool but you don''t even know how to add Magician to an application. I am working on a tutorial on making a VERY simple applet, now that I have applets working, in the next couple of days. You really need to learn AWT before you learn OpenGL. By that time I should have some more stuff up on the site. You can learn java in 21 days. It is not a complex language.

I wanrned you! Didn't I warn you?! That colored chalk was forged by Lucifer himself!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS