Main Menu

Version 1.08 has been released!

Started by EgonOlsen, October 27, 2005, 10:00:33 PM

Previous topic - Next topic

EgonOlsen

A new version with a lot of new stuff for you to play with. Most noticable, this version can do multi texturing at least for the OpenGL renderer (the software one simply ignores it). Have a look at the TextureInfo class on how to set it up.

Example:


Changes can be found here: http://www.jpct.net/changes.html

Have fun!

BTW: Adding MT support required a lot of changes, so i'm not sure if this one is as stable as jPCT used to be. Just to be sure, save your 1.07 version somewhere before upgrading... :wink:

EgonOlsen

Uploaded a new version that corrects a small bug with texture uploading. Here's an example of how to use multi texturing:

import com.threed.jpct.*;
import org.lwjgl.opengl.*;
import javax.swing.*;
import java.awt.*;

public class MTAWT {

 public static void main(String[] args) throws Exception {
   MTAWT mt = new MTAWT();
   mt.doIt();
 }

 private void doIt() throws Exception {

   JFrame frame=new JFrame();
   frame.setSize(320,240);
   frame.show();

   FrameBuffer fb=new FrameBuffer(320, 240, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
   fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
   Canvas canvas=fb.enableGLCanvasRenderer(IRenderer.MODE_OPENGL);
   frame.getContentPane().add(canvas);

   World w=new World();
   w.setAmbientLight(255,255,255);

   TextureManager tm=TextureManager.getInstance();
   Texture base=new Texture("base.jpg");
   Texture decal=new Texture("decal.jpg");

   tm.addTexture("base", base);
   tm.addTexture("decal", decal);

   int bid=tm.getTextureID("base");
   int did=tm.getTextureID("decal");

   Object3D plane=new Object3D(9);
   plane.setCulling(Object3D.CULLING_DISABLED);

   // Base texture only
   TextureInfo tInf1=new TextureInfo(bid,0,0,1,0,0,1);
   TextureInfo tInf2=new TextureInfo(bid,1,0,1,1,0,1);
   plane.addTriangle(new SimpleVector(-10,-10,30), new SimpleVector(-10,0,30), new SimpleVector(0,-10,30), tInf1);
   plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(0,0,30), new SimpleVector(0,-10,30), tInf2);

   // 2nd stage used, modulate
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_MODULATE);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_MODULATE);
   plane.addTriangle(new SimpleVector( 0, -10, 30), new SimpleVector( 0, 0, 30), new SimpleVector(10, -10, 30), tInf1);
   plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector(10, 0, 30), new SimpleVector(10, -10, 30), tInf2);

   // 2nd stage used, add
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_ADD);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_ADD);
   plane.addTriangle(new SimpleVector(-10,0,30), new SimpleVector(-10,10,30), new SimpleVector(0,0,30), tInf1);
   plane.addTriangle(new SimpleVector(-10,10,30), new SimpleVector(0,10,30), new SimpleVector(0,0,30), tInf2);

   // 2nd stage used, blend
   tInf1 = new TextureInfo(bid, 0, 0, 1, 0, 0, 1);
   tInf1.add(did, 0, 0, 1, 0, 0, 1, TextureInfo.MODE_BLEND);
   tInf2 = new TextureInfo(bid, 1, 0, 1, 1, 0, 1);
   tInf2.add(did, 1, 0, 1, 1, 0, 1, TextureInfo.MODE_BLEND);
   plane.addTriangle(new SimpleVector( 0, 0, 30), new SimpleVector( 0, 10, 30), new SimpleVector(10, 0, 30), tInf1);
   plane.addTriangle(new SimpleVector( 0, 10, 30), new SimpleVector(10, 10, 30), new SimpleVector(10, 0, 30), tInf2);

   w.addObject(plane);
   w.buildAllObjects();

   while (frame.isActive()) {
     fb.clear();
     w.renderScene(fb);
     w.draw(fb);
     fb.displayGLOnly();
     plane.rotateY(0.01f);
     canvas.repaint();
     Thread.sleep(10);
   }

   fb.disableRenderer(IRenderer.RENDERER_OPENGL);
   System.exit(0);
 }
}

Melssj5

Hi, I just downloaded it, but when I run the examples and tries to switch to the opengl render, then i got an exception and the program crashes.
Nada por ahora

EgonOlsen

Quote from: "Melssj5"then i got an exception and the program crashes.
Which exception?

Melssj5

C:\Documents and Settings\Gold Oozaru\Escritorio\jpctapi\examples\fps>java  -Dja
va.library.path=..\..\lib\lwjgl-0.97\ -cp ..\..\lib\lwjgl-0.97\lwjgl.jar;..\..\l
ib\jpct\jpct.jar;fps.jar -Xmx128m JPCTDemo width=512 height=384 mipmap zbuffer=1
6 refresh=60
Adding Lightsource: 0
Adding Lightsource: 1
Adding Lightsource: 2
Adding Lightsource: 3
Adding Lightsource: 4
Adding Lightsource: 5
Adding Lightsource: 6
Adding Lightsource: 7
Adding Lightsource: 8
Adding Lightsource: 9
Adding Lightsource: 10
Adding Lightsource: 11
Loading Texture...textures\other\numbers.jpg
Loading Texture...textures\other\envmap.jpg
Loading Texture...textures\ql0.jpg
Loading Texture...textures\ql1.jpg
Loading Texture...textures\ql10.jpg
Loading Texture...textures\ql11.jpg
Loading Texture...textures\ql12.jpg
Loading Texture...textures\ql2.jpg
Loading Texture...textures\ql3.jpg
Loading Texture...textures\ql4.jpg
Loading Texture...textures\ql5.jpg
Loading Texture...textures\ql6.jpg
Loading Texture...textures\ql7.jpg
Loading Texture...textures\ql8.jpg
Loading Texture...textures\ql9.jpg
Loading file 3ds\weapon.3ds
File 3ds\weapon.3ds loaded...5491 bytes
Processing new material Material!
Processing object from 3DS-file: stand001
Object 'stand001_jPCT0' created using 182 polygons and 103 vertices.
Loading file 3ds\ql.3ds
File 3ds\ql.3ds loaded...346811 bytes
Processing new material Material15!
Processing new material Material!
Processing new material Material13!
Processing new material Material12!
Processing new material Material11!
Processing new material Material3!
Processing new material Material9!
Processing new material Material10!
Processing new material Material8!
Processing new material Material1!
Processing new material Material7!
Processing new material Material6!
Processing new material Material5!
Processing new material Material4!
Processing new material Material2!
Processing object from 3DS-file: obj2
Object 'obj2_jPCT1' created using 382 polygons and 288 vertices.
Processing object from 3DS-file: obj8
Object 'obj8_jPCT2' created using 100 polygons and 152 vertices.
Processing object from 3DS-file: obj10
Object 'obj10_jPCT3' created using 28 polygons and 56 vertices.
Processing object from 3DS-file: obj12
Object 'obj12_jPCT4' created using 140 polygons and 136 vertices.
Processing object from 3DS-file: obj14
Object 'obj14_jPCT5' created using 268 polygons and 328 vertices.
Processing object from 3DS-file: obj16
Object 'obj16_jPCT6' created using 688 polygons and 728 vertices.
Processing object from 3DS-file: obj18
Object 'obj18_jPCT7' created using 740 polygons and 904 vertices.
Processing object from 3DS-file: obj20
Object 'obj20_jPCT8' created using 615 polygons and 665 vertices.
Processing object from 3DS-file: obj22
Object 'obj22_jPCT9' created using 40 polygons and 60 vertices.
Processing object from 3DS-file: obj24
Object 'obj24_jPCT10' created using 437 polygons and 515 vertices.
Processing object from 3DS-file: obj26
Object 'obj26_jPCT11' created using 284 polygons and 250 vertices.
Processing object from 3DS-file: obj28
Object 'obj28_jPCT12' created using 372 polygons and 274 vertices.
Processing object from 3DS-file: obj30
Object 'obj30_jPCT13' created using 938 polygons and 1030 vertices.
Processing object from 3DS-file: obj32
Object 'obj32_jPCT14' created using 771 polygons and 756 vertices.
Processing object from 3DS-file: obj34
Object 'obj34_jPCT15' created using 404 polygons and 226 vertices.
Processing object from 3DS-file: obj36
Object 'obj36_jPCT16' created using 765 polygons and 729 vertices.
Processing object from 3DS-file: obj38
Object 'obj38_jPCT17' created using 68 polygons and 136 vertices.
Processing object from 3DS-file: obj40
Object 'obj40_jPCT18' created using 220 polygons and 264 vertices.
Processing object from 3DS-file: obj42
Object 'obj42_jPCT19' created using 32 polygons and 35 vertices.
Processing object from 3DS-file: obj44
Object 'obj44_jPCT20' created using 588 polygons and 707 vertices.
Processing object from 3DS-file: obj46
Object 'obj46_jPCT21' created using 18 polygons and 18 vertices.
Processing object from 3DS-file: obj48
Object 'obj48_jPCT22' created using 250 polygons and 202 vertices.
Processing object from 3DS-file: obj50
Object 'obj50_jPCT23' created using 300 polygons and 342 vertices.
Created 2608 triangle-strips for object49 in 1 pass(es)
Building octree for 8448 triangles!
Octree constructed with 314 nodes / 266 leafs.
Java version is: 1.5.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Software renderer (OpenGL mode) initialized
205-230 -> using splitted buffer access!
Current mode:512 x 384 x 32 @60Hz
OpenGL renderer initialized
Software renderer disposed
Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid operation (
1282)
       at org.lwjgl.opengl.Util.checkGLError(Util.java:56)
       at org.lwjgl.opengl.Display.update(Display.java:549)
       at com.threed.jpct.GLRenderer.execute(Unknown Source)
       at com.threed.jpct.FrameBuffer.display(Unknown Source)
       at com.threed.jpct.FrameBuffer.display(Unknown Source)
       at com.threed.jpct.FrameBuffer.displayGLOnly(Unknown Source)
       at JPCTDemo.display(Unknown Source)
       at JPCTDemo.gameLoop(Unknown Source)
       at JPCTDemo.<init>(Unknown Source)
       at JPCTDemo.main(Unknown Source)
Nada por ahora

EgonOlsen

Strange...looks like i'm doing something in the renderer that isn't allowed in that state. Problem is, that this should be the case on every hardware/driver but i can't verify it. It's a damn case of "works for me".

Can you please (if time permits it):

1. Make sure that you have the latest version (i.e. download it again)
2. Try to run the example, press '1' to disable rgb scaling, switch to OpenGL and see if that works
3. Compile the example above and see if that works

Many thanx.

Melssj5

Ok, I will do ir, I will post a reply with the results!
Nada por ahora

Melssj5

Exactly the same!!

I downloaded it again, run the example and pressed 1 before switching to opengl and the same exception.

I have a Pentium 4 2.67 Ghz, 256 MB ddr RAM, GForce 4 video of 64MB card.
Nada por ahora

Melssj5

ok, i COMPILED TEH EXAMPLE ABOVE AND:

- IT COMPILES WELL BUT DOENT WORK.

THIS IS WHAT I GOT:

Java version is: 1.4.0
-> support for BufferedImage
-> using BufferedImage
Software renderer (legacy mode) initialized
Software renderer disposed
Loading Texture...base.jpg
OpenGL (AWTGLCanvas) renderer initialized
[ Sat Oct 29 15:28:20 GMT-05:00 2005 ] - ERROR: File not found - replacement texture used instead!
Loading Texture...decal.jpg
[ Sat Oct 29 15:28:20 GMT-05:00 2005 ] - ERROR: File not found - replacement texture used instead!
OpenGL (AWTGLCanvas) renderer disposed

TEXTURES ARE NOT FOUND!!!! BECAUSE THEY DOESNT EXIST BUT IN ANYWAY, THE FRAME CLOSES, I WILL USE OTHER TEXTURES TO TEST IT.


OK, I used to textures, the first one was a grass theture and the another one was similar to gold.

I got a plane divided in 4 squares, each one has a diferent texture. and the plane is turning.
Nada por ahora

Melssj5

I cant run my programas that use opengl with the new API. the same exception.

My program uses a thread to render, on the frame opened with openGl, not using AWTGLCanvas.
Nada por ahora

EgonOlsen

Ok, so only the "normal" GLRenderer seems to have a problem on your machine. I'll check it out on monday. I have a GF4MX somewhere...will try to track the problem down with that. Thanx for testing.

EgonOlsen

Ok, i've hopefully found the bug and fixed it. Corrected version should run on your machine. The problem was that i was initializing vertex arrays for non-present texture stages on lower end hardware.

Anonymous

The enableGLCanvas method is not present on the java doc!

EgonOlsen

Quote from: "Anonymous"The enableGLCanvas method is not present on the java doc!
:?:  :?:  :?: It is. It's called enableGLCanvasRenderer(int) and can be found in the FrameBuffer docs.

Melssj5

I just cant found that method.

I only have:

void    enableRenderer(int renderer)
         Enables a renderer (OpenGL or software) in OpenGL-lighting mode.

void    enableRenderer(int renderer, int mode)
         Enables a renderer (OpenGL or software) in the desired mode.

nothing else with the letter e on the FrameBuffer.

I am watching the javadoc downloades that came with the API!
Nada por ahora