Bugzilla – Attachment 44 Details for
Bug 148
Swing Component Shadow on GLJPanel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test case that works with 1.4.2 (click button to exhibit bug)
Main.java (text/plain), 2.93 KB, created by
Sven Gothel
on 2005-04-09 17:22:00 CEST
(
hide
)
Description:
Test case that works with 1.4.2 (click button to exhibit bug)
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2005-04-09 17:22:00 CEST
Size:
2.93 KB
patch
obsolete
>import net.java.games.jogl.*; >import javax.swing.*; >import java.awt.*; >import java.awt.event.*; >import javax.swing.event.*; > > >public class Main { > > public Main(){ > > JFrame frame = new JFrame("Test Frame"); > frame.setBounds(10, 10, 500, 500); > frame.getContentPane().setLayout(new BorderLayout()); > > GLCapabilities glCaps = new GLCapabilities(); > glCaps.setRedBits(8); > glCaps.setBlueBits(8); > glCaps.setGreenBits(8); > glCaps.setAlphaBits(8); > > GLJPanel panel = GLDrawableFactory.getFactory().createGLJPanel(glCaps); > frame.getContentPane().add(panel, BorderLayout.CENTER); > JPanel p = new JPanel(new FlowLayout()); > JButton b = new JButton("Test Me"); > p.add(b); > frame.getContentPane().add(p, BorderLayout.WEST); > panel.addGLEventListener(new GLContextRenderer()); > > final Animator animator = new Animator(panel); > frame.addWindowListener(new WindowAdapter() { > public void windowClosing(WindowEvent e) { > animator.stop(); > System.exit(0); > } > }); > frame.setVisible(true); > animator.start(); > } > > public static void main(String[] args) { > new Main(); > } >} > >class GLContextRenderer implements GLEventListener { > > GL gl; > GLDrawable glDrawable; > float xRot; > > public void init(GLDrawable glDrawable) { > this.gl = glDrawable.getGL(); > this.glDrawable = glDrawable; > gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading > gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background > gl.glClearDepth(1.0f); // Depth Buffer Setup > gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing > gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do > gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations > gl.glEnable(GL.GL_TEXTURE_2D); > > } > > public void display(GLDrawable glDrawable) { > gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); > gl.glLoadIdentity(); > > gl.glTranslatef(0.0f, 0.0f, -6.0f); > gl.glColor3f(1.0f, 0.0f, 0.0f ); > gl.glRotatef(xRot, 1.0f, 0.0f, 0.0f); > > gl.glBegin( GL.GL_TRIANGLES ); > gl.glVertex3f( 0.0f, 0.0f, 0.0f ); > gl.glVertex3f( 1.0f, 0.0f, 0.0f ); > gl.glVertex3f( 1.0f, 1.0f, 0.0f ); > gl.glEnd(); > xRot += .2f; > } > > public void reshape(GLDrawable glDrawable, int x, int y, int width, int >height) { > final GLU glu = glDrawable.getGLU(); > > if (height <= 0) // avoid a divide by zero error! > height = 1; > final float h = (float)width / (float)height; > gl.glViewport(0, 0, width, height); > gl.glMatrixMode(GL.GL_PROJECTION); > gl.glLoadIdentity(); > glu.gluPerspective(45.0f, h, 1.0, 20.0); > gl.glMatrixMode(GL.GL_MODELVIEW); > gl.glLoadIdentity(); > } > > public void displayChanged(GLDrawable glDrawable, boolean b, boolean b1) { > //To change body of implemented methods use File | Settings | File Templates. > } >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 148
: 44