Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
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  
  Swing + Java3D = giant black rectangle  (Read 1175 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Member




for great justice!


« Posted 2003-07-02 08:24:12 »

I'm having trouble with a large black rectangle when I introduce my java3d viewer for the first time. The rest of the game (I use the term loosely- it is an educational thing) uses normal Swing stuff and when I switch the view from a normal JPanel to a Canvas3D a large area of my screen fills with a black rectangle. This goes outside the limits of my application and does not clear up until I move or resize the application, forcing a repaint. Calling repaint does nothing, for some reason.

Anyone know what is causing this? I get a similar effect when I open two java3d applications but I am being very careful to only use one Canvas3d for everything I do here. Which isn't to say I'm not creating two, but I don't think I am.
Offline Breakfast

Senior Member




for great justice!


« Reply #1 - Posted 2003-07-02 14:32:35 »

So I got my debugger working and stepped through and it comes out on this line:

public Canvas3D View3D= new Canvas3D(SimpleUniverse.getPreferredConfiguration());

Which I'm sure I've used before without any ill-effects. Is it because I'm using more other stuff at the same time? Any good ways to work out what is wrong about the graphics configuration or tools I can use to see what is going on in more detail?
Offline bmyers

Junior Member





« Reply #2 - Posted 2003-07-02 15:22:38 »

Try keeping the JPanel, and adding the Canvas3D to the JPanel instead of replacing it.  Then the Canvas3D becomes a managed component and shouldn't go outside the application bounds, and should resize properly, etc.

Also, the Canvas3D is a heavyweight component, so it will show up over any lightweight Swing components, including menubars, toolbars, etc. if they are in the same container.  So ideally your Canvas3D should be the only component in the JPanel.  Your other Swing components should be in a different JPanel.  Then you can put both of the JPanels into another JPanel to organize them however you want, using LayoutManagers.

If you have popup menus and you want them to show up over the Canvas3D, then you can use:
1  
JPopupMenu.setDefaultLightWeightPopupEnabled(false);


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

Senior Member




for great justice!


« Reply #3 - Posted 2003-07-02 16:05:51 »

This is the odd thing, because it is actually being drawn on a JPanel anyway - and the Canvas3D is drawing correctly and in the right place, it is just that when it is initialized it draws this big old black rectangle over half my screen, a bit like this:

.................................
.AAAAAAA...................
.AABBBBBBBBBBB...........
.AABBBBBBBBBBB...........
.AABBBBBBBBBBB...........
.....BBBBBBBBBBB...........
.....BBBBBBBBBBB..........
.................................
.................................

Where A is my application, B is the black square and . is the background/other windows/etc.

I can force a repaint to get
.................................
.AAAAAAA...................
.AAAAAAABBBBBB..........
.AAAAAAABBBBBB..........
.AAAAAAABBBBBB..........
......BBBBBBBBBBB.........
......BBBBBBBBBBB.........
.................................
.................................
but the rest of the black area will stay until I redraw the underlying windows.

It looks like it is some kind of openGL initialization or something, but it seems to happen whether I use the OpenGL or D3D versions of J3D so that is probably not the case.
Offline Breakfast

Senior Member




for great justice!


« Reply #4 - Posted 2003-07-02 16:12:02 »

Oh, my mistake- it only happens when I'm using the OpenGL version of J3D. Looks like it's some kind of bug or driver clash. Great.
Offline Breakfast

Senior Member




for great justice!


« Reply #5 - Posted 2003-07-03 08:36:38 »

OK, so this is now starting to really annoy me - it does still happen using the DX version, but only when a second Canvas3D is created. I'm fairly sure that the reason is still to do with my rather lame Graphics card drivers (rage 128) but it is a fairly standard piece of kit and I'm sure it should be able to handle this.

Basically, assuming this is the case, I need to have a way to use a single Canvas3D throughout my application  without recreating it at any point. Is there a way to do this? I think all I need to do is remove everything from it, but it isn't clear how to do this.
Offline bmyers

Junior Member





« Reply #6 - Posted 2003-07-03 13:21:46 »

Hmmm.... I am using 2 Canvas3Ds at the same time with no problem, using both OpenGL and DX versions, on an ATI Mobility card, on Linux and Windows, with no issues.

Try adding the Canvas3D to the JPanel before making the JPanel visible, if you are not already.

I will try and post my code that does similiar stuff, if I get a chance.

Offline Breakfast

Senior Member




for great justice!


« Reply #7 - Posted 2003-07-05 19:00:52 »

In the end I just kept the one canvas and removed everything from it when I'm done with it for now and then added new stuff, so I didn't have to reallocate it at all.  That way even if I do see the rectangle of doom, it only happens once, at the beginning.
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 (18 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 (70 views)
2014-08-11 02:49:23

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

BurntPizza (37 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!