Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Error in attaching canvas to a Frame  (Read 2183 times)
0 Members and 1 Guest are viewing this topic.
Offline zaknixon

Senior Newbie




</bored>


« Posted 2003-07-22 12:29:43 »

I have just started learning jogl and need some help.

Here is my code:
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  
public class Test {
     
      static GLCapabilities gl_Capabilities = new GLCapabilities();
     
      public static void main(String[] args){
           
//            gl_Capabilities.setRedBits(8);
//            gl_Capabilities.setBlueBits(8);
//            gl_Capabilities.setGreenBits(8);
//            gl_Capabilities.setAlphaBits(8);


            GLCanvas gl_canvas = GLDrawableFactory.getFactory().createGLCanvas(gl_Capabilities);
           
            GLJPanel gl_panel = GLDrawableFactory.getFactory().createGLJPanel(gl_Capabilities,gl_canvas);
           
            Frame frame = new Frame();
            frame.add(gl_panel);
           
            frame.setVisible(true);
            frame.setSize(400,400);
           
      }

}


And whenever this is ran, i get this error:


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
net.java.games.jogl.GLException: Error creating offscreen bitmap
      at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.create(WindowsOffscreenGLContext.java:147)
      at net.java.games.jogl.impl.windows.WindowsGLContext.makeCurrent(WindowsGLContext.java:117)
      at net.java.games.jogl.impl.windows.WindowsOffscreenGLContext.makeCurrent(WindowsOffscreenGLContext.java:116)
      at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)
      at net.java.games.jogl.GLJPanel.reshape(GLJPanel.java:131)
      at java.awt.Component.setBounds(Unknown Source)
      at java.awt.BorderLayout.layoutContainer(Unknown Source)
      at java.awt.Container.layout(Unknown Source)
      at java.awt.Container.doLayout(Unknown Source)
      at java.awt.Container.validateTree(Unknown Source)
      at java.awt.Container.validate(Unknown Source)
      at java.awt.Window.show(Unknown Source)
      at java.awt.Component.show(Unknown Source)
      at java.awt.Component.setVisible(Unknown Source)
      at Test.main(JoglFrame.java:45)


Line 45: frame.add(gl_panel);

Can someone tell me what is occurring?

Thanks,

Zak



----------------------------------
Zak Nixon
Software Engineer
Davidson Technologies
-----------------------------------
Offline AndersDahlberg

Junior Member





« Reply #1 - Posted 2003-07-22 13:02:10 »

Some quick question so that the pro's Grin can help you better:

1, Do you have a 3d card? Wink
2, Do you use windows xp with default drivers? (if so, update as windows don't provide opengl support)
3, Do you use linux without native (nvidia,ati etc) drivers?

These above are maybe not your problem - but easier to get them answered directly, so that it's easier to solve the real problem later Smiley
Offline zaknixon

Senior Newbie




</bored>


« Reply #2 - Posted 2003-07-22 13:05:35 »

Quote
1, Do you have a 3d card?  


Yes, I am using a Nvidia Quadro4 900 XGL video card.


Quote
2, Do you use windows xp with default drivers? (if so, update as windows don't provide opengl support)


I am running Windows XP with the Nvidia latest drivers.

Quote
3, Do you use linux without native (nvidia,ati etc) drivers?


I am currently not using Linux as my OS.

Thanks

Zak

----------------------------------
Zak Nixon
Software Engineer
Davidson Technologies
-----------------------------------
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Caoimhin

Junior Member





« Reply #3 - Posted 2003-07-22 13:54:18 »

Zak,

I can't get your code fragment to compile.  I suggest taking a look at the gears demo and start with it as your framework.
Archimedes
Guest
« Reply #4 - Posted 2003-07-22 14:19:27 »

If I add your gl_Canvas to the Frame directly and kick the GlJPanel, it works.
I didn't know it's cool to add a JPanel to an AWT Canvas anyway. :-)

Maybe the mixing of OpenGL AWT and Swing components ist the problem here (not the general mixing of AWT and Swing, but with OpenGL ) ?
I once encountered problems when I tried to use an AWT GlCanvas inside a Swing JFrame... however adding Swing components next to my GlCanvas inside an AWT Frame works fine.

http://jogl.dev.java.net/unbranded-source/browse/*checkout*/jogl/doc/userguide/index.html?rev=1.2
"(..) Jogl provides two basic widgets into which OpenGL rendering can be performed. The GLCanvas is a heavyweight AWT widget which supports hardware acceleration and which is intended to be the primary widget used by applications. The GLJPanel is a fully Swing-compatible lightweight widget which currently does not support hardware acceleration but which is intended to provide 100% correct Swing integration in the rare circumstances where a GLCanvas can not be used. See this article on The Swing Connection for more information about mixing lightweight and heavyweight widgets. (..)"

If you can live with "just" the GlCanvas I'd stick with this. Works great here (inside an AWT Frame).
Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #5 - Posted 2003-07-22 18:53:30 »

The intention of GLJPanel is to be used in Swing. Try creating a GLCanvas or putting your GLJPanel into a JFrame and see if that helps.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
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.

TehJavaDev (17 views)
2014-08-28 18:26:30

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

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

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

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

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

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

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

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

BurntPizza (36 views)
2014-08-08 02:01:56
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!