Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1400 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.

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

EgonOlsen (58 views)
2018-06-10 19:43:48

EgonOlsen (40 views)
2018-06-10 19:43:44

EgonOlsen (60 views)
2018-06-10 19:43:20

DesertCoockie (225 views)
2018-05-13 18:23:11

nelsongames (141 views)
2018-04-24 18:15:36

nelsongames (140 views)
2018-04-24 18:14:32

ivj94 (882 views)
2018-03-24 14:47:39

ivj94 (143 views)
2018-03-24 14:46:31

ivj94 (794 views)
2018-03-24 14:43:53

Solater (158 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!