Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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  
  AWTGLCanvas not painting  (Read 1186 times)
0 Members and 1 Guest are viewing this topic.
Offline Alan_W

JGO Knight


Medals: 7
Projects: 3


Java tames rock!


« Posted 2005-08-27 19:54:45 »

Can anyone point me to a working application using AWTGLCanvas?

I've subclassed it and overriden paintGL() and update(), both of which are getting called, but nothing is happening.  I tried some simple OGL as follows:

1  
2  
3  
4  
5  
6  
    protected void paintGL() {
        System.out.print("paint ");
        System.out.println(getWidth()+" "+getHeight());
        GL11.glClearColor(1f, 0f, 0f, 0f); // Red
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
   }


I though something would happen, but it doesn't (I tried alpha=1 also);

Incidentally, If I want to initialise the projection matrix where does the initialisation go?  Can I call makeCurrent() in the constructor (after explicitly calling underlying constructor to be on safe side), and then do some GL?

Alan

Edit: I added a swapBuffers() at the end of paintGL(), and got a nice red square.  I'd still like recommendations on where (and how) to put in the initialisation code.

1  
java.lang.IllegalStateException: Canvas not yet displayable


Initialisation... Ho Hum.

Edit2:  Does each context have its own projection and model matrices, or is there a common one.  I.e. there is more then one AWTGLCanvas do I need to set up projection on each paint() call?

Time flies like a bird. Fruit flies like a banana.
Offline princec
« League of Dukes »

JGO Kernel


Medals: 196
Projects: 3


Eh? Who? What? ... Me?


« Reply #1 - Posted 2005-08-30 11:40:49 »

I can't help you with most of this thread except to say that as far as programs are concerned, every context is completely totally unique, each with its own state. There are one or two extensions to let them share a bit of memory here and there.

Cas Smiley

Offline Alan_W

JGO Knight


Medals: 7
Projects: 3


Java tames rock!


« Reply #2 - Posted 2005-08-30 19:30:23 »

Cas,

Thanks for confirming that the contexts are completely separate.  For initialisation, I'm going with a flag which I check on every paintGL() call.  If it's false, the initialisation code gets called, which in turn sets the flag.  Perhaps not the most elegant solution, but it works.  Think that covers my initial queries Smiley

So far I've converted most of my (very basic) software renderer based level editor over to a AWTGLCanvas based implementation.  The only visible difference is some missing pixels along the edges of the faces in the opengl version, which needs looking at.  Lots to do yet, but very promising.

Alan

Time flies like a bird. Fruit flies like a banana.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (81 views)
2013-05-17 21:29:12

alaslipknot (90 views)
2013-05-16 21:24:48

gouessej (122 views)
2013-05-16 00:53:38

gouessej (114 views)
2013-05-16 00:17:58

theagentd (126 views)
2013-05-15 15:01:13

theagentd (113 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.086 seconds with 20 queries.