Author Topic: Sorry but I just don't get it.  (Read 6260 times)

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Sorry but I just don't get it.
« on: May 03, 2007, 09:23:14 am »
I read like tons of posts and just can't figure out how do I get a AWTGLCanvas which i can put this canvas into a Frame, and which renders using hardware (the AWTGL refer to the car bench program: mt_opengl.bat). And more importantly, how do i paint the canvas? I can get the canvas from enableGLCanvasRenderer() but apart from that i dunno what to do? And i try to paint using Frame.display(graphics, x, y) but im sure that is software way of rendering, so what about hardware? I dun need detailed explanation of the concept of GL, Software and AWT GL because i should by now understand them from all the posts. Just don't know how to make it work.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline Mr.Marbles

  • int
  • **
  • Posts: 81
    • View Profile
Re: Sorry but I just don't get it.
« Reply #1 on: May 03, 2007, 04:10:31 pm »

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Sorry but I just don't get it.
« Reply #2 on: May 03, 2007, 04:53:51 pm »
I already tried the way you mentioned in that post. But I got an all black screen in the canvas. And that's all. To make things clearer, the canvas is not totally black, i see some pixels blinking in red on the left, but im sure that's not the actually thing rendered.
« Last Edit: May 03, 2007, 05:09:17 pm by hytparadisee »
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Sorry but I just don't get it.
« Reply #3 on: May 03, 2007, 05:06:53 pm »
ok if you got a black screen that means that the canvas is being shown but the content is not being rendered or there are not any light source.

first. Be sure to add enough light sources.

second. Be sure to hav ethe Camera positioned and aimed to be able to see the Object3d. If the cam is inside the object3D you wont see it.

third. dont use Frame.display(graphics, x, y) because you need to render in OpenGL and that renders on software rendering, so the outpput wont be on your AWTGLCanvas.

There is a small example I did a year ago when I was using jpct. Is just a JFrame with an AWTGLCanvas which renders a car. The example can be found on the download section and its called car. I am not sure if the bat file will run on your PC beucasse I am not expert at oing jars so you need to add the dll on the system32 folder, but the code is there and its working fine. Check it.
Nada por ahora

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Sorry but I just don't get it.
« Reply #4 on: May 03, 2007, 05:38:26 pm »
Things are getting stranger. The screen is actually not totally black, i see some very small areas get rendered by rubbish pixels, and from the console I got something like this:

Expanding command queue to 2000 entries!
Expanding command queue to 3000 entries!
Expanding command queue to 4000 entries!
Expanding command queue to 5000 entries!
Expanding command queue to 6000 entries!
Expanding command queue to 7000 entries!
Expanding command queue to 8000 entries!

I'm afraid im in need of some code snippets to help me.

Regarding Melssj5's car program, i will take a look at the source. But from what i ran i think the app still runs on software rendering (cos i can feel the difference between software and GL, it is just not as smooth as the AWTGLCanvas on the car bench test program). Does your car program have any args to switch to the AWT GL mode?

Thanks All

YUN TAO
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline Mr.Marbles

  • int
  • **
  • Posts: 81
    • View Profile
Re: Sorry but I just don't get it.
« Reply #5 on: May 03, 2007, 08:40:25 pm »
Make sure you force a repaint on your canvas after the buffer update, like this:

Code: [Select]
moveObjects();
moveCamera();

buffer.clear();
theWorld.renderScene(buffer);
buffer.update();

glCanvas.repaint();

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Sorry but I just don't get it.
« Reply #6 on: May 04, 2007, 01:52:42 am »
I dont remember, I guess you should check the lights and the camera position first. About my car program, I dont really remember it. Anyway there is another called model3d or something like that, It for sure uses AWTGLCanvas becausse I made it to show Opngel on the University. But that code is a bit messy.
Nada por ahora

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Sorry but I just don't get it.
« Reply #7 on: May 04, 2007, 02:42:12 am »
OK, i'll take a look into that. Right now i still haven't solved it.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline hytparadisee

  • int
  • **
  • Posts: 86
    • View Profile
    • http://peterhi.com
Re: Sorry but I just don't get it.
« Reply #8 on: May 04, 2007, 02:59:54 am »
Thanks Melssj5 and Mr. Marbles. Problem Solved!

What I do is the following (from the source of Model3D), Just in case if someone as stupid as me met this problem ;D.

1. Setup a SAMPLINGMODE_HARDWARE_ONLY FrameBuffer
2. Disable software renderer
3. Enable and obtain the AWTGLCanvas
4. Add it to the container
5. In the rendering loop:
        5.1 clear the buffer
        5.2 update the buffer
        5.3 render world scene to buffer
        5.4 draw the world to buffer
        5.5 render buffer to GL (displayGLOnly())
        5.6 repaint canvas

The steps in red are what I missed.

Thanks again Melssj5 and Mr. Marbles.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Sorry but I just don't get it.
« Reply #9 on: May 04, 2007, 10:34:44 am »
        5.5 render buffer to GL (displayGLOnly())
        5.6 repaint canvas
Those two are the most important ones. While the latter may not always be required depending on how your application works, the former one is. If you omit it, the command queue will increase in size over and over and nothing will be rendered (as you've already noticed...).