Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  Help Mixing Custom Heavyweight with Swing  (Read 826 times)
0 Members and 1 Guest are viewing this topic.
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Posted 2003-07-14 19:25:24 »

Hi there.  I know there are a few folks around that have worked with heavyweights that use native rendering and Swing.. for JOGL or Java3D, so I'm hoping that they might be able to help me here.  (Even though strictly speaking I'm not coding a game Smiley.)

I have created a custom component that uses native code to paint... actually, I don't even care so much about the 'paint()' method, as I have a native thread doing active rendering to the component.  The component is a live video 'window' which is being pushed frames from custom video capture hardware.  All of this is running on Windows XP or Win2k.

I have implemented the drawing code and my NativeVideoPreview component seems to be working fine from the point of view of the native drawing code.  I keep a global reference to my object that extends Canvas in my native code and use standard JAWT calls to get the drawing surface etc.. then ultimately call the Win32 function StretchDIBits to render to the HDC that I get from the JAWT_DrawingSurfaceInfo.

Questions:
I'm currently only using the hdc member of jawt_Win32DrawingSurfaceInfo, but how do I know which interpretation of the union of { HWND, HBITMAP, void*pbits } is valid?
It seems that since that union holds either a native window, DDB, or DIB that I can somehow use the JAWT stuff on something that isn't a heavyweight.  It seems that I could be asked to draw on some sort of backbuffer is that possible?

As I said, my drawing code is working, so I'm only interested in the above if it allows me to avoid the heavyweight and all the problems that it seems to be causing.

The Main Problem:
I have read the article at http://java.sun.com/products/jfc/tsc/articles/mixing/ on mixing heavy and light components.  I have set my popups to not be lightweight so menus and such work okay.  My problem is that although my heavyweight component never needs to be on top of anything, it does need to be clipped or even resized to a rectangular area that fits within my GUI where I want it.  That doesn't seem to be working properly.

I have the component in the top half of a JSplitPane, yet it insists on drawing past the splitter bar and over top of the lightweights that are in the bottom half.

I tried putting it in an AWT ScrollPane - something I would probably do eventually anyway, but it still does not render properly, the ScrollPane (or it's viewport) is much too small so the scroll bars are shown when they shouldn't be needed.  The top half of my JSplitPane is a JPanel with a GridBagLayout that contains only my heavyweight or the ScrollPane wrapping it.  The GridBagLayout constraints are set to let that component fill the available space (but it doesn't).

But that isn't the worst of my problems... it seems that ScrollPane or not, the heavyweight will grow vertically to go into the bottom half of the JSplitPane.  I can make it grow by SHRINKing the top pane.  As I drag the splitter bar up to the point where I start to squeeze the heavyweight (and would hope that the ScrollPane gets smaller, OR it is clipped to a smaller rectangle) it actually starts to get bigger vertically the smaller the vertical space I give it.  In fact even when I start to increase the size of the top pane if it still has less vertical space than the (now taller) heavyweight the heavyweight will grow more every time the splitter bar is moved....  The end result is a heavyweight that goes from the top off the top pane all the way to the bottom of my apps window.. tromping on top of everything.  (I can still see my live video drawing at the top of this component.)

If I continue to play with the splitter bar the heavyweight eventually disappears completely and never comes back.

I'm stumped.

Oh, yeah, I forgot to say that the top half of the split pane has the JPanel that I put the heavyweight in, and an entirely different GUI on another card of a CardLayout.. So it is JSplitPane->JPanel(CardLayout)->JPanel(GridBagLayout)->Heavyweight (direct or in AWT ScrollPane).

Any ideas?

If I can get away for the heavyweight entirely I would be willing, as I expect the sizing problems will vanish, although being heavyweight I could maybe use DirectX or OpenGL to render my YUV data without needing to software convert to RGB as I am doing now.

Totally unrelated comment:
Couldn't Z-order with heavyweights be emulated to a degree  by setting the clipping of the heavyweight to a complex region?  You can make top level windows odd shapes this way, so I would think it would be possible to "cut out" the areas that are supposed to have lightweights on top so they simply show through.

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.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!