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  
  problems of a simple rendering app please help  (Read 909 times)
0 Members and 1 Guest are viewing this topic.
Offline ultr.0

Junior Newbie




平生不修善果,只爱杀人放火


« Posted 2009-02-09 12:06:52 »

Hi

Two problems with a program as trivial as actively rendering a "hello" string on the canvas. First, BufferStrategy.contentsLost() always returns true

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  
      try {
         //boolean contentsLost = bufferStrategy.contentsLost();
         boolean contentsLost = bufferStrategy.contentsLost()
               && !bufferStrategy.contentsRestored();
         contentsLost = false;
         if (contentsLost && !renderer.onContentsLost()) {
            return;
         }

         while (!renderer.update())
            ;

         if (contentsLost) {
            return;
         }

         Graphics g = bufferStrategy.getDrawGraphics();
         //Graphics g = getGraphics();
         if (null != g) {
            renderer.render(g);
            g.dispose();
         }
      } finally {
         bufferStrategy.show();
      }


Second, when the rendering canvas was added to the containing frame, layout management seems take no effect, and the canvas shrinks into itself at the top left corner of the frame. Did I missed anything?

Thanks in advance!

Ultr.zero
------------------------------
Java for fun
Offline ultr.0

Junior Newbie




平生不修善果,只爱杀人放火


« Reply #1 - Posted 2009-02-09 12:13:39 »

Would you kindly please view the whole source code at http://ultr_zero.googlegroups.com/web/ultr0-game-double-bufferred.jar?hl=en&gda=UJu7f1EAAABXNDLuhyWxmGuxQjc0_VHMPqokIIU9j8TUIm8x0xmn77pb5fMU98QuEZ7aBUAcFLaTR4qEDPm6rzSKuWq1gO8cUwk_6Qi3BU8HCN0q6OYwM5VxXgp_nHWJXhfr7YhqVgA&gsc=L7C0eRYAAAD4PX6IESzHsP7JEWesaD9ig-kXU5InE09W2o0GCSVgCQ?

Ultr.zero
------------------------------
Java for fun
Offline CommanderKeith
« Reply #2 - Posted 2009-02-09 12:38:54 »

Second, when the rendering canvas was added to the containing frame, layout management seems take no effect, and the canvas shrinks into itself at the top left corner of the frame. Did I missed anything?


The first problem may be caused by the second - make sure the canvass is visible and has a non-zero width and height. Add the canvas to a JFrame by calling frame.add(canvas) and the canvass should be added to fill up the jframe, since the BorderLayout is the default for JFrames and BorderLayout.CENTER is the default layout contraint for a BorderLayout.

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 21:26:44

Mr.CodeIt (20 views)
2014-12-15 07:50:38

BurntPizza (40 views)
2014-12-10 10:41:13

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

JscottyBieshaar (37 views)
2014-12-06 00:39:02

SHC (50 views)
2014-12-04 04:27:13

CopyableCougar4 (47 views)
2014-11-30 09:32:03

toopeicgaming1999 (113 views)
2014-11-27 03:22:04

toopeicgaming1999 (100 views)
2014-11-27 03:20:36

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

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

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

List of Learning Resources
by Longor1996
2014-08-16 22:40:00

List of Learning Resources
by SilverTiger
2014-08-06 07:33:27

Resources for WIP games
by CogWheelz
2014-08-02 04:20:17

Resources for WIP games
by CogWheelz
2014-08-02 04:19:50

List of Learning Resources
by SilverTiger
2014-08-01 04: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!