You can subscribe to this list here.
1999 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2000 |
Jan
(39) |
Feb
(22) |
Mar
(41) |
Apr
(44) |
May
(47) |
Jun
(25) |
Jul
(28) |
Aug
(39) |
Sep
(35) |
Oct
(31) |
Nov
(31) |
Dec
(3) |
2001 |
Jan
(18) |
Feb
(43) |
Mar
(47) |
Apr
(38) |
May
(9) |
Jun
(20) |
Jul
(8) |
Aug
(11) |
Sep
(15) |
Oct
(43) |
Nov
(27) |
Dec
(73) |
2002 |
Jan
(42) |
Feb
(47) |
Mar
(49) |
Apr
(58) |
May
(12) |
Jun
(68) |
Jul
(42) |
Aug
(9) |
Sep
(19) |
Oct
(36) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(13) |
Feb
(24) |
Mar
(40) |
Apr
(52) |
May
(39) |
Jun
(46) |
Jul
(17) |
Aug
(5) |
Sep
(4) |
Oct
(9) |
Nov
(13) |
Dec
(12) |
2004 |
Jan
(1) |
Feb
(17) |
Mar
(4) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(6) |
Nov
(6) |
Dec
(3) |
2005 |
Jan
|
Feb
|
Mar
(8) |
Apr
(1) |
May
|
Jun
(1) |
Jul
(2) |
Aug
(5) |
Sep
(4) |
Oct
(3) |
Nov
(3) |
Dec
(1) |
2006 |
Jan
(2) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
(5) |
Sep
(8) |
Oct
(9) |
Nov
(8) |
Dec
(5) |
2007 |
Jan
(3) |
Feb
(11) |
Mar
(5) |
Apr
(5) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(5) |
2008 |
Jan
(7) |
Feb
(8) |
Mar
(30) |
Apr
(17) |
May
(20) |
Jun
(8) |
Jul
(19) |
Aug
(10) |
Sep
(7) |
Oct
(2) |
Nov
(1) |
Dec
|
2009 |
Jan
(13) |
Feb
(7) |
Mar
(13) |
Apr
(27) |
May
(95) |
Jun
(77) |
Jul
(43) |
Aug
(25) |
Sep
(24) |
Oct
(32) |
Nov
(6) |
Dec
(6) |
2010 |
Jan
|
Feb
(2) |
Mar
(30) |
Apr
(58) |
May
(60) |
Jun
(72) |
Jul
(32) |
Aug
(45) |
Sep
(19) |
Oct
(4) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: aNt <an...@to...> - 2002-03-17 14:41:10
|
Daniel It all seemed to work ok until 10.1.3 I think its the hardware accel stuff they added at apple. The hardware accel uses opengl as far as I can tell to speed things up. I have also tried the new QTJava with its JQTCanvas and this also blows up under swing at the moment. Swing seems to be cool for just drawing stuff fast on osx (java simple components). I bet all the heavyweight to lightweight will be fixed for May 6th :) WWDC and all that. I will try and hook up with 'Gerard' and get him to have a little mess around. But then we may just get drunk on beers and have a giggle will have to see :) Tops aNt |
From: Daniel B. <db...@if...> - 2002-03-16 22:33:41
|
Hi all, I trying to get the swing demo files to run under Mac OS X 10.1.3. The gl4java Version is 2.7.2.0. which I downloaded from Gerard Ziemski page. At the moment, these demos and all the other examples that I found which make use of either GLAnimPanel or GLJPanel produce the follwing exception: An exception is thrown, while creating a GL context java.lang.ClassCastException: com.apple.mrj.internal.awt.basepeers.VContainerPeer java.lang.ClassCastException: com.apple.mrj.internal.awt.basepeers.VContainerPeer ...etc... I have no clue whether this is a problem of apple's java implementation or of gl4java. I would really like to include some opengl functionality in my visualization program which makes heavy use of swing. For this reason I appreciate any tips and tricks how to get gl4java and swing to work under Mac OS X. Thanks in advance! Daniel |
From: R.M. L. <u8...@cs...> - 2002-03-13 16:49:32
|
To actually gradually transfrom the viewport to the selected object or coordinates? Almost like an animated zoom? If anyone has any ideas or could point me in the right direction, that would be fantastic, since i'm totally stuck with how to do this. Thanks again, Mark. |
From: R.M. L. <u8...@cs...> - 2002-03-11 14:08:58
|
Hello, Is it possible to make a sphere unwrap using some kind of morphing animation, if anyone knows where to point me in the right direction that would be great. Many thanks again, Mark. |
From: Alban C. <aco...@mi...> - 2002-03-07 10:08:18
|
Hello, I finally found out I was mistaken loading alpha channel, and as usual this gl4java is made by too damn good programmers !!! I was in fact using a dangerous approach specifying the image format with hard coding : gl=2EglTexImage2D(gl=2EGL_TEXTURE_2D,0,3,texLoader=2EgetImageWidth(),texLoad= er=2Eget ImageHeight(),0, gl=2EGL_RGB ,gl=2EGL_UNSIGNED_BYTE,texLoader=2EgetTexture= ()); And there was my mistake, I had two functions loading textures, and didn't figure the one my program was using was the one with GL_RGB hard coded ! So when loading a RGBA image, it was in fact considered as RGB and my pixels were all messed up=2E A much smarter approach is to let the loader decide of the format of the file, replacing GL_RGB by texLoader=2EgetGLFormat() So a smart glTexImage2D function looks like this : gl=2EglTexImage2D(gl=2EGL_TEXTURE_2D,0,3,texLoader=2EgetImageWidth(),texLoad= er=2Eget ImageHeight(),0,texLoader=2EgetGLFormat(),gl=2EGL_UNSIGNED_BYTE,texLoader=2E= getTex ture()); Hope this can be usefull for everybody, Regards, Alban Cousini=E9 http://www=2Emind2machine=2Ecom tel : +33 491 246 734 fax : +33 491 246 702 |
From: Alban C. <aco...@mi...> - 2002-03-07 09:21:13
|
>Hello, > I'm looking at some of the demo code, but i'm not entirely sure >how to go from the exert below to loading in and binding the three >textures i require in the loadtextures method, do we have to delete >the >image after we are finished. >If there is an easier way to load in 3 textures, could someone please >let me know. >The loading in part seems to be the most difficult part. > >Thanks again, > Mark. Sure, it is possible. When you load your textures, you are storing them in the array object texture[]. So basically, what you have to do is repeat the operation for each texture, binding a different texture slot each time. Here is some code that should work and generate 3 mipmapped textures : int[] texture = new int[3]; //Storage for 3 textures string[] texturePaths = new String[3]; texturePaths[0]="pic/crate.png"; texturePaths[1]="pic/crate2.png"; texturePaths[2]="pic/crate3.png"; init(){ gl.glGenTextures(3, texture); //initialise the 3 texture slots for(int i=0; i<3; i++) { PngTextureLoader texLoader = new PngTextureLoader(gl,glu); texLoader.readTexture(getCodeBase(), texturePaths[i]); if(texLoader.isOk()) { //there you store the texture in slot i ... gl.glBindTexture(GL_TEXTURE_2D, texture[i]); //... and then specify the parameters gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR_MIPMAP_LINEAR); glu.gluBuild2DMipmaps(gl.GL_TEXTURE_2D, 3, texLoader.getImageWidth(), texLoader.getImageHeight(), texLoader.getGLFormat(), gl.GL_UNSIGNED_BYTE, texLoader.getTexture()); } } display(){ //there you select the texture you want to display int index = 0; //or 1 or 2 according to the texture you want to display gl.glBindTexture(gl.GL_TEXTURE_2D, texture[index]); //code to draw your object goes here gl.glBegin(); //(...) gl.glEnd(); } |
From: Alban C. <aco...@mi...> - 2002-03-07 08:54:11
|
>How can I read a transparency texture??? >I have tried to use a transparency gif, but i can't read it=2E >when I try to use : > glu=2EgluBuild2DMipmaps(GL_TEXTURE_2D, > 4, > texLoader=2EgetImageWidth(), > texLoader=2EgetImageHeight(), > GL_RGBA, > GL_UNSIGNED_BYTE, > texLoader=2EgetTexture()); > >the browser crash=2E > >If I use GL_RGB, the browser don't crash=2E > >Somebody can say me a solution or / and an example ??? > >are there any other file type with trasparency that gl4java can load >(jpg >not support transparency)?? > >Tnak you=2E GL4java doesn't support gif images actually=2E The only file format you "could" extract transparency is the =2Epng file format where GL4JAVA "should= " support loading of the alpha channel, though I can't suceed having it working=2E Gl4java also has a parser for =2Etga files, but it has not implemented the loading of the alpha channel contained in this kind of files=2E the third format supported by gl4java is jpg, but the jpg file format itself does not have an alpha channel, so it is not possible to store transparency information into a jpg file=2E Regards, Alban Cousini=E9 |
From: R.M. L. <u8...@cs...> - 2002-03-06 16:55:50
|
Hello, I'm looking at some of the demo code, but i'm not entirely sure how to go from the exert below to loading in and binding the three textures i require in the loadtextures method, do we have to delete the image after we are finished. If there is an easier way to load in 3 textures, could someone please let me know. The loading in part seems to be the most difficult part. Thanks again, Mark. Current code, taken from demo: public void LoadGLTextures() { PngTextureLoader texLoader = new PngTextureLoader(gl,glu); texLoader.readTexture(getCodeBase(), "pic/crate.png");//Load in tex, check name & path.. if(texLoader.isOk()) { //Create nearest filtered texture gl.glGenTextures(3, texture); gl.glBindTexture(GL_TEXTURE_2D, texture[0]); //Takes color and alpha data from texture, helps with lighting gl.glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl.glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glu.gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texLoader.getImageWidth(), texLoader.getImageHeight(), GL_RGB, GL_UNSIGNED_BYTE, texLoader.getTexture()); } } |
From: Jiba <Jea...@im...> - 2002-03-06 16:54:16
|
On 2002.03.06 16:48:03 +0000 Ricardo Olanda wrote: > > How can I read a transparency texture??? > > I have tried to use a transparency gif, but i can't read it. > > when I try to use : > glu.gluBuild2DMipmaps(GL_TEXTURE_2D, > 4, > texLoader.getImageWidth(), > texLoader.getImageHeight(), > GL_RGBA, > GL_UNSIGNED_BYTE, > texLoader.getTexture()); > > the browser crash. > > If I use GL_RGB, the browser don't crash. > > Somebody can say me a solution or / and an example ??? > > are there any other file type with trasparency that gl4java can load (jpg > not support transparency)?? > > Tnak you. > I personnaly use PNG but with the LATEST release of png.jar (get it from sixlength). The version given with GL4Java is (was ?) out to date. Jiba |
From: Ricardo O. <ro...@gl...> - 2002-03-06 16:43:02
|
How can I read a transparency texture??? I have tried to use a transparency gif, but i can't read it. when I try to use : glu.gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texLoader.getImageWidth(), texLoader.getImageHeight(), GL_RGBA, GL_UNSIGNED_BYTE, texLoader.getTexture()); the browser crash. If I use GL_RGB, the browser don't crash. Somebody can say me a solution or / and an example ??? are there any other file type with trasparency that gl4java can load (jpg not support transparency)?? Tnak you. |
From: Alban C. <aco...@mi...> - 2002-03-04 15:35:15
|
Hello everybody, Anyone ever suceeded to have a png with an alpha channel parsed successfully ? All my png files encoded on 32 bytes display incorrectly, like if they were read as RVB instead of RVBA, with a bad interleave/decay not taking account of the 8 additonal bytes of Alpha channel=2E I've been trying generating pngs with alpha channels both with photoshop and gimp, giving the same result=2E Has anyone met this problem ? Does anyone use alpha succesfully on opacity maps ? thanks for info, Alban Cousini=E9 http://www=2Emind2machine=2Ecom tel : +33 491 246 734 fax : +33 491 246 702 |
From: Kenneth B. R. <kbr...@al...> - 2002-03-04 08:30:27
|
> How can I get the thread handle to GLAnimCanvas display() so I > can wait for the repaint using something like: repaintThread.join()? Currently there is no way to access the internal thread of the GLAnimCanvas. If you need to call join() you are probably trying to shut down. Try doing this cooperatively, by setting a flag in your GLEventListener (assuming you are using the listener model) and checking whether that flag has been set in your display() method, calling GLAnimCanvas.stop() from there, and returning). You could use an external synchronization object if you want to be able to wait() until the target thread has stopped. See Doug Lea's Concurrent Programming in Java web site at http://g.oswego.edu/dl/cpj/ Alternatively you could change the GLAnimCanvas implementation to do this (instead of losing the reference to the internal thread) and also provide a join() method. If you decide to do this, get the latest sources via CVS (see http://sourceforge.net/projects/gl4java/ ) and we'll incorporate the changes into the main tree. |
From: Kenneth B. R. <kbr...@al...> - 2002-03-04 08:12:58
|
> I looked at the GL4Java demos that show how to share a GLContext (share > display lists) between two canvases. They use the inheritence method when > creating a GLCanvas. In my app I am not using the inheritence method for my > GLAnimCanvas. Instead, I am creating the GLAnimCanvas via the > GLDrawableFactory, and I am registering a GLEventListener. So, how do I share > a GLContext in this paradigm? As mentioned in my earlier message, it will be necessary to add code to the library to implement this. You can check out the latest source code via CVS; see http://sourceforge.net/projects/gl4java/ . We'll gladly incorporate changes you make into the source base. (I'm personally busy with JavaOne preparations and can't do this work at the moment.) > I looked at the constructors for the GLContext class, and I see that one of > the constructors takes a sharedContext. But it is not obvious to me how to use > this constructor. Which component do I pass into the constructor (the 1st or > the 2nd, and BTW shouldn't the type of this argument be GLCanvas and not > awt.Component)? More importantly, what do I do with this newly created > GLContext? (Since there is NO set method in GLCanvas that would allow me to > use this new GLContext). Look at GLCanvas.java, in particular the paint() method where the GLContext is instantiated. This, combined with the SharedGLTest demo, should give you an idea of the proper instantiation of GLContext objects. It shouldn't be too difficult to add the necessary constructors to GLCanvas, GLAnimCanvas, GLJPanel, and GLJAnimPanel to take the shared context as an argument instead of requiring the classes to be subclassed in order to set it. Then the GLDrawableFactory can be extended with additional methods taking a GLContext with which to share textures and display lists. > "Kenneth B. Russell" wrote: > > The GLDrawable APIs (largely borrowed from Magician) were added > fairly late, so there is still missing functionality like this. > > The underlying mechanism should be available; GLContext can take > a "shared" GLContext in its constructor. There are some > demonstrations (all of which depend on subclassing GLCanvas) of > this functionality in the demos. > > > I am porting my application from Magician to GL4Java, and there > are some > > differences in the two APIs that I am trying to figure out. > > Specifically, I was sharing display lists and textures between two > > > displays (ie, two GLDrawables) in my app. In the old API, I was > able to > > create my second "GLDrawable" by passing in my first "GLDrawable" > as an > > argument during creation. This linked the two OpenGL state > machines and > > allowed the desired sharing. > > > > Does anyone know the proper way to do this in GL4Java? In the > > GLDrawableFactory class, I saw that createGLAnimCanvas() was > overloaded > > to take the arguments 'glName' and 'gluName', but I don't think > that is > > what I am looking for, is it? We tried getting the Context from > the > > first GLDrawable and setting it in the second GLDrawable, but that > > > caused nothing to be rendered at all. Does anyone have some > advice? > > --Boundary_(ID_UghF3EvwTtxuxRiWRwukeg) > Content-type: text/html; charset=us-ascii > Content-transfer-encoding: 7BIT > > <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> > <html> > I looked at the GL4Java demos that show how to share a GLContext (share > display lists) between two canvases. They use the inheritence method when > creating a GLCanvas. In my app I am not using the inheritence method for > my GLAnimCanvas. Instead, I am creating the GLAnimCanvas via the GLDrawableFactory, > and I am registering a GLEventListener. So, how do I share a GLContext > in this paradigm? > <p>I'd like to stay with the GLEvenListener, and avoid sub-classing, for > several reasons: > <br>1) GL4Java documentation recommends this method > <br>2) The GLDrawableFactory creates the AnimCanvas properly on all platforms > (ie, no need to worry about X11 vs Win32 visuals) > <br>3) It would require a lot of changes in my app to abandon the GLEventListener > <p>The simple demo program (called MiscDemos\ShardedGLTest.java) just sets > the protected member called SharedGLContext in the parent GLCanvas class. > But I cannot do this because I am not sub-classing. Furthermore, there > is no mutator method (set method) in the GLCanvas class for the SharedGLContext > variable. How can I share my GLContext in this scenario? > <p>I looked at the constructors for the GLContext class, and I see that > one of the constructors takes a sharedContext. But it is not obvious to > me how to use this constructor. Which component do I pass into the constructor > (the 1st or the 2nd, and BTW shouldn't the type of this argument be GLCanvas > and not awt.Component)? More importantly, what do I do with this newly > created GLContext? (Since there is NO set method in GLCanvas that would > allow me to use this new GLContext). > <p>Please help. > <br>-Mark > <br> > <p>"Kenneth B. Russell" wrote: > <p>The GLDrawable APIs (largely borrowed from Magician) were added > <br>fairly late, so there is still missing functionality like this. > <p>The underlying mechanism should be available; GLContext can take > <br>a "shared" GLContext in its constructor. There are some > <br>demonstrations (all of which depend on subclassing GLCanvas) of > <br>this functionality in the demos. > <blockquote>> I am porting my application from Magician to GL4Java, and > there are some > <br>> differences in the two APIs that I am trying to figure out. > <br>> Specifically, I was sharing display lists and textures between two > <br>> displays (ie, two GLDrawables) in my app. In the old API, I was able > to > <br>> create my second "GLDrawable" by passing in my first "GLDrawable" > as an > <br>> argument during creation. This linked the two OpenGL state machines > and > <br>> allowed the desired sharing. > <br>> > <br>> Does anyone know the proper way to do this in GL4Java? In the > <br>> GLDrawableFactory class, I saw that createGLAnimCanvas() was overloaded > <br>> to take the arguments 'glName' and 'gluName', but I don't think that > is > <br>> what I am looking for, is it? We tried getting the Context from the > <br>> first GLDrawable and setting it in the second GLDrawable, but that > <br>> caused nothing to be rendered at all. Does anyone have some advice?</blockquote> > </html> > > --Boundary_(ID_UghF3EvwTtxuxRiWRwukeg)-- > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup |
From: Jacob M. <ja...@ma...> - 2002-03-04 07:18:06
|
Hi, A university technical report called "Evaluating Java for Game Development" has been published. It considers whether Java can be used for professional game development and whether it is a good idea to do so. Of special interest to this group is that GL4Java is one of the technologies that is evaluated and benchmarked in the report. Read the report here: http://www.rolemaker.dk/articles/evaljava/ Sincerely, Jacob Marner |
From: Kay <kan...@in...> - 2002-03-04 05:09:57
|
Hi, All: How can I get the thread handle to GLAnimCanvas display() so I can wait for the repaint using something like: repaintThread.join()? thanks, -Kay |
From: Kenneth B. R. <kbr...@al...> - 2002-03-01 16:29:38
|
> When building I get the compiler errors shown below. They indicate that the > compiler can not find the GLFunc14 method glAllocateMemoryNV(int, float, > float, float). It is referenced in both the DBFlyer and DBZoomer class on > lines (720, 725) and (593, 598) respectively. This routine was added in GL4Java 2.8.2.0. http://jausoft.com/Files/Java/1.1.X/GL4Java/binpkg/ |
From: Jacob M. <ja...@ma...> - 2002-03-01 15:17:49
|
Try using the latest version of Gl4Java instead. v.2.8.2. (Don't download from source forge. They are old if I recall correctly) Either use the installer on the gl4java home page or get the files here: http://jausoft.com/Files/Java/1.1.X/GL4Java/binpkg/ Jacob Marner ----- Original Message ----- From: <NM...@th...> To: <gl4...@li...> Cc: <wj...@Th...> Sent: Friday, March 01, 2002 16:08 Subject: [gl4java-usergroup] Error building Sun's Java 1.4 JCanyon demo > Hi, > > I am trying to build the JCanyon demo that Sun Microsystems has posted as > an official Java 1.4 demo at > http://java.sun.com/products/jfc/tsc/articles/jcanyon/ > > On the page it states that the demo uses an "unmodified 2.8.x" distribution > of GL4Java. I've downloaded and installed the latest GL4Java binaries ( > rel-2-8-0-8 prerelease ) from sourceforge. > > When building I get the compiler errors shown below. They indicate that the > compiler can not find the GLFunc14 method glAllocateMemoryNV(int, float, > float, float). It is referenced in both the DBFlyer and DBZoomer class on > lines (720, 725) and (593, 598) respectively. > > I have used JAD to decompile the GLFunc14.class file that is in the > rel-2-8-0-8 prerelease of GL4Java. The glAllocateMemoryNV(int, float, > float, float) method does not exist in the interface. > > Does the new GL4Java release not include this method? Do I just not have > the correct version of the GL4Java jar? Am I just doing something wrong? > I viewed the API documentation at > http://gl4java.sourceforge.net/docs/html/index.html and the method is > listed. > > Thanks for your help, > Noah > > HERE IS THE COMPILER ERRORS GENERATED : > > D:\jcanyon-src>make > javac -g -d . terrain/*.java tools/*.java > edu/mit/alum/kbrussel/linalg/*.java ac > tion/*.java f16/*.java comparison/*.java > terrain/DBFlyer.java:720: cannot resolve symbol > symbol : method glAllocateMemoryNV (int,float,float,float) > location: interface gl4java.GLFunc14 > bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0f, 0f, > priority).asFloatBuffer(); > ^ > terrain/DBFlyer.java:725: cannot resolve symbol > symbol : method glAllocateMemoryNV (int,float,float,float) > location: interface gl4java.GLFunc14 > bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0f, 0f, > 1.f).asFloatBuffer(); > ^ > terrain/DBZoomer.java:593: cannot resolve symbol > symbol : method glAllocateMemoryNV (int,int,int,float) > location: interface gl4java.GLFunc14 > bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0, 0, > priority).asFloatBuffer(); > ^ > terrain/DBZoomer.java:598: cannot resolve symbol > symbol : method glAllocateMemoryNV (int,int,int,float) > location: interface gl4java.GLFunc14 > bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0, 0, > 1.f).asFloatBuffer(); > ^ > 4 errors > make: *** [all] Error 1 > > > > > > > > > > > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup > |
From: <NM...@th...> - 2002-03-01 15:08:48
|
Hi, I am trying to build the JCanyon demo that Sun Microsystems has posted as an official Java 1.4 demo at http://java.sun.com/products/jfc/tsc/articles/jcanyon/ On the page it states that the demo uses an "unmodified 2.8.x" distribution of GL4Java. I've downloaded and installed the latest GL4Java binaries ( rel-2-8-0-8 prerelease ) from sourceforge. When building I get the compiler errors shown below. They indicate that the compiler can not find the GLFunc14 method glAllocateMemoryNV(int, float, float, float). It is referenced in both the DBFlyer and DBZoomer class on lines (720, 725) and (593, 598) respectively. I have used JAD to decompile the GLFunc14.class file that is in the rel-2-8-0-8 prerelease of GL4Java. The glAllocateMemoryNV(int, float, float, float) method does not exist in the interface. Does the new GL4Java release not include this method? Do I just not have the correct version of the GL4Java jar? Am I just doing something wrong? I viewed the API documentation at http://gl4java.sourceforge.net/docs/html/index.html and the method is listed. Thanks for your help, Noah HERE IS THE COMPILER ERRORS GENERATED : D:\jcanyon-src>make javac -g -d . terrain/*.java tools/*.java edu/mit/alum/kbrussel/linalg/*.java ac tion/*.java f16/*.java comparison/*.java terrain/DBFlyer.java:720: cannot resolve symbol symbol : method glAllocateMemoryNV (int,float,float,float) location: interface gl4java.GLFunc14 bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0f, 0f, priority).asFloatBuffer(); ^ terrain/DBFlyer.java:725: cannot resolve symbol symbol : method glAllocateMemoryNV (int,float,float,float) location: interface gl4java.GLFunc14 bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0f, 0f, 1.f).asFloatBuffer(); ^ terrain/DBZoomer.java:593: cannot resolve symbol symbol : method glAllocateMemoryNV (int,int,int,float) location: interface gl4java.GLFunc14 bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0, 0, priority).asFloatBuffer(); ^ terrain/DBZoomer.java:598: cannot resolve symbol symbol : method glAllocateMemoryNV (int,int,int,float) location: interface gl4java.GLFunc14 bigArrayVar = gl.glAllocateMemoryNV(bufferSizeInBytes, 0, 0, 1.f).asFloatBuffer(); ^ 4 errors make: *** [all] Error 1 |
From: R.M. L. <u8...@cs...> - 2002-03-01 10:53:59
|
Hello, I'm currently using some of the demo code to load a texture, i was just wondering how you alter it (the loader) to load another texture and bind different textures to different objects? Do you use some kind of stack? Thanks again, Mark. At the moment the texture loader method looks like: public void LoadGLTextures() { PngTextureLoader texLoader = new PngTextureLoader(gl,glu); texLoader.readTexture(getCodeBase(), "pic/crate.png");//Load in tex, check name & path.. if(texLoader.isOk()) {//Mip map texture //Create nearest filtered texture gl.glGenTextures(1, texture); gl.glBindTexture(GL_TEXTURE_2D, texture[0]); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glu.gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texLoader.getImageWidth(), texLoader.getImageHeight(), GL_RGB, GL_UNSIGNED_BYTE, texLoader.getTexture()); } |
From: Mark M. <pat...@lm...> - 2002-03-01 04:24:16
|
I looked at the GL4Java demos that show how to share a GLContext (share display lists) between two canvases. They use the inheritence method when creating a GLCanvas. In my app I am not using the inheritence method for my GLAnimCanvas. Instead, I am creating the GLAnimCanvas via the GLDrawableFactory, and I am registering a GLEventListener. So, how do I share a GLContext in this paradigm? I'd like to stay with the GLEvenListener, and avoid sub-classing, for several reasons: 1) GL4Java documentation recommends this method 2) The GLDrawableFactory creates the AnimCanvas properly on all platforms (ie, no need to worry about X11 vs Win32 visuals) 3) It would require a lot of changes in my app to abandon the GLEventListener The simple demo program (called MiscDemos\ShardedGLTest.java) just sets the protected member called SharedGLContext in the parent GLCanvas class. But I cannot do this because I am not sub-classing. Furthermore, there is no mutator method (set method) in the GLCanvas class for the SharedGLContext variable. How can I share my GLContext in this scenario? I looked at the constructors for the GLContext class, and I see that one of the constructors takes a sharedContext. But it is not obvious to me how to use this constructor. Which component do I pass into the constructor (the 1st or the 2nd, and BTW shouldn't the type of this argument be GLCanvas and not awt.Component)? More importantly, what do I do with this newly created GLContext? (Since there is NO set method in GLCanvas that would allow me to use this new GLContext). Please help. -Mark "Kenneth B. Russell" wrote: The GLDrawable APIs (largely borrowed from Magician) were added fairly late, so there is still missing functionality like this. The underlying mechanism should be available; GLContext can take a "shared" GLContext in its constructor. There are some demonstrations (all of which depend on subclassing GLCanvas) of this functionality in the demos. > I am porting my application from Magician to GL4Java, and there are some > differences in the two APIs that I am trying to figure out. > Specifically, I was sharing display lists and textures between two > displays (ie, two GLDrawables) in my app. In the old API, I was able to > create my second "GLDrawable" by passing in my first "GLDrawable" as an > argument during creation. This linked the two OpenGL state machines and > allowed the desired sharing. > > Does anyone know the proper way to do this in GL4Java? In the > GLDrawableFactory class, I saw that createGLAnimCanvas() was overloaded > to take the arguments 'glName' and 'gluName', but I don't think that is > what I am looking for, is it? We tried getting the Context from the > first GLDrawable and setting it in the second GLDrawable, but that > caused nothing to be rendered at all. Does anyone have some advice? |
From: Kenneth B. R. <kbr...@al...> - 2002-02-28 05:46:40
|
> After having another attempt at picking i noticed something strange in > my applet. When you move the spheres with the arrow keys ( y > translation) and (x translation) or use the mouse zoom (z translation) > you are still able to click on the spheres and the crosshair will appear > as a test. > However, when you use the rotation and camera rotation feature the > program appears to lose track of the objects. This sounds like incorrect matrix management. Performing picking in 3D is non-trivial, which is why I prefer to (a) do all of the requisite linear algebra at the application level, to avoid misuses of the underlying graphics library, and (b) write it once so I can forget about how it's implemented. Take a look at gleem: http://www.media.mit.edu/~kbrussel/gleem/ It is likely that you'll at least be able to borrow some of the picking routines if not use the widgets to solve your problem. It's got a nice ExaminerViewer class (UI and name borrowed from Open Inventor) which allows rotating and dollying using the mouse while still maintaining proper selection of the widgets. |
From: R.M. L. <u8...@cs...> - 2002-02-27 17:01:21
|
After having another attempt at picking i noticed something strange in my applet. When you move the spheres with the arrow keys ( y translation) and (x translation) or use the mouse zoom (z translation) you are still able to click on the spheres and the crosshair will appear as a test. However, when you use the rotation and camera rotation feature the program appears to lose track of the objects. If anyone can help, they're welcome to try it out... Left mouse button-pick, crosshair should appear on an object Hold right mouse button, camera movements Hold both buttons, y direction to zoom, x to rotate spheres. PS, it uses MatrixFuncs.class from the jausoft demos Thanks, Mark. ---------------------------------------------------------------------- import java.applet.*; import java.awt.*; import java.awt.event.*; //Gl4Java classes. import gl4java.GLContext; import gl4java.awt.GLAnimCanvas;//Constantly redraws canvas import gl4java.utils.textures.*; public class Windowt extends Applet { renderCanvas canvas = null; //Initialise applet public void init() { setLayout(new BorderLayout());//lays applet components out canvas = new renderCanvas(getSize().width, getSize().height); canvas.requestFocus(); add("Center", canvas); } //Begin the applet public void start() { canvas.start(); //Begins canvas animation } public void stop() { canvas.stop();//stops the canvas } public void destroy() { canvas.stop(); canvas.destroy();//destroys canvas } //NB put commas here private class renderCanvas extends GLAnimCanvas implements KeyListener,MouseListener, MouseMotionListener { //Keys initially //Putting in mouse float xrot = 0.0f;//rotation for x and y float yrot = 0.0f; //Think about mouse x and y and the out of window calculations //Make sure this works private MatrixFuncs mFun = null; private float rotation[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; float moveX = 0.0f;//For mouse movements, try as ints float moveY = 0.0f; float x = 0.0f; float y = 0.0f; float z = -8.0f; public renderCanvas(int w, int h) { super(w, h); addKeyListener(this);//Key listener back in addMouseListener(this);//Alter, will for mouse addMouseMotionListener(this); mFun = new MatrixFuncs(); } public void preInit() { //Understand this doubleBuffer = true; stereoView = false; } public void init() { /*float[] ambient = {0.5f, 0.5f, 0.5f, 1.0f}; float[] diffuse = {1.0f, 1.0f, 1.0f, 1.0f}; float[] position = {0.0f, 0.0f, 2.0f, 1.0f}; gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);//Clears colour, change background gl.glClearDepth(1.0);//Clear depth buffer gl.glDepthFunc(GL_LESS);//Depth test gl.glEnable(GL_DEPTH_TEST);//enable test of depth gl.glShadeModel(GL_SMOOTH);//Smooth colour shading gl.glMatrixMode(GL_PROJECTION);//Projection matrix gl.glLoadIdentity();//Resets matrix glu.gluPerspective(45.0f, (float)getSize().width/(float)getSize().height, 0.1f, 100f);//Calculate window aspect ratio gl.glMatrixMode(GL_MODELVIEW);//Model view matrix /*gl.glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); gl.glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); gl.glLightfv(GL_LIGHT0, GL_POSITION, position);//Put in later gl.glEnable(GL_LIGHT0); gl.glEnable(GL_LIGHTING);*/ } public void destroy() { cvsDispose();//Destroys GL context } public void reshape(int width, int height) { //Might need to change viewport for object selection??? gl.glViewport(0, 0 , width, height);//Reset viewport & perspective gl.glMatrixMode(GL_PROJECTION);//select proj matrix gl.glLoadIdentity();//reset proj matrix glu.gluPerspective(45.0f, (float)getSize().width/(float)getSize().height,0.1f, 100.0f);//Aspect ratio of window gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); } public void display() {//Draw to the canvas //Changing to implement true camera... if (glj.gljMakeCurrent(true)==false) return;//Is GL initialised properly gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//Clears //screen & depth buffer gl.glLoadIdentity();//Reset view gl.glMultMatrixf(rotation); gl.glTranslatef(0.0f, 0.0f, z);//Move into environment gl.glTranslatef(x, 0.0f, 0.0f);//Strafe gl.glTranslatef(0.0f, y, 0.0f);//Strafe gl.glRotatef(xrot,0.0f,1.0f,0.0f);//Rotate on x axis gl.glRotatef(yrot,1.0f,0.0f,0.0f);//Rotate y..swapped drawLayout(GL_RENDER); gl.glFlush();//Might not be necessary gl.glEnd(); glj.gljSwap();//Swap buffers glj.gljFree(); } private void renderSphereRed(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(1.0f,0.0f,0.0f);//Red glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } private void renderSphereYellow(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(1.0f, 1.0f, 0.0f);//Yellow glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } private void renderSphereBlue(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(0.0f, 0.0f, 1.0f);//Blue glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } void drawLayout(int mode) {//Check syntax if (mode == GL_SELECT){ //Might put in draw methods gl.glLoadName(1); } renderSphereRed(-2.0f, 1.0f, -1.0f);//Wrap bitmaps around renderSphereBlue(2.0f, 2.0f, 2.0f);//Need morphing operation renderSphereYellow(2.0f, 4.0f, 5.0f);//?Name convertor needed gl.glEnd(); } void processSelection(float moveX, float moveY) { int BUFSIZE = 512;//May change size int[] selectBuf = new int[BUFSIZE]; int hits; int[] viewport = new int[4]; gl.glGetIntegerv(GL_VIEWPORT, viewport); gl.glSelectBuffer(BUFSIZE, selectBuf); gl.glRenderMode(GL_SELECT);//Select mode gl.glInitNames(); gl.glPushName(-1);//Check implementation of stack names gl.glMatrixMode(GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluPickMatrix((float) moveX, (float) (viewport[3] - moveY),5.0,5.0, viewport);//Size of pick cube, may change //Check perspective matrix glu.gluPerspective(45.0f, (float)getSize().width/(float)getSize().height,0.1f, 100.0f);//Aspect ratio of window //Need drawLayout method drawLayout(GL_SELECT); gl.glPopMatrix(); gl.glFlush(); hits = gl.glRenderMode(GL_RENDER); gl.glMatrixMode(GL_MODELVIEW); if (hits > 0) //Need process hits method processHits(hits, selectBuf); } void processHits (int hits, int buffer[]) { //Will have zoom and menu here setCursor( Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); /*glu.gluLookAt(0.0f, 0.0f, 0.0f);*/ /*objectZoom(moveX, moveY);*/ } /*public void objectZoom(float moveX, float moveY) { //Another picking operation, need reverse //Zoom to where clicked..first attempt, see red book //Check viewpoint gl.glPushMatrix(); gl.glGetIntegerv(GL_VIEWPORT, viewport); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); glu.gluPickMatrix((double) moveX, (double) (viewport[3] - moveY),5.0,5.0, viewport); gl.glScalef(zoom, zoom, zoom); display(GL_RENDER); gl.glPopMatrix(); //Look in book }*///no //Required for implementation of mouselistener etc... public void mouseEntered(MouseEvent e) { Component comp = e.getComponent(); if(comp.equals(this)) { requestFocus(); } } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) {//Find a way to hide the mouse pointer moveX = e.getX();//Take new mouse reading moveY = e.getY(); //Selection here if ((e.getModifiers() & InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK) { //Test for cursor hiding, hand selector setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if(!glj.gljMakeCurrent(true))//See if is initialised return; processSelection(moveX,moveY);//Send arguements to process selection glj.gljSwap(); glj.gljCheckGL(); glj.gljFree(); } } public void mouseReleased(MouseEvent e) { setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } public void mouseClicked(MouseEvent e) { Component comp = e.getComponent(); if(comp.equals(this)) { requestFocus(); } } public void mouseMoved(MouseEvent e) { } public void mouseDragged(MouseEvent e) { //Manual zoom.... if ((e.isMetaDown()) & ((e.getModifiers() & InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)) { setCursor( Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); //Also two button for roataion of structure //Put in proper camera zoom. float newMoveX = e.getX(); float newMoveY = e.getY();//Need distance for zoom //See which feels better for user xrot -= newMoveX - moveX; //Might need method z -= newMoveY - moveY; //Update method moveX = newMoveX; moveY = newMoveY; } else if (e.isMetaDown()) { setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));//Find correct method float newMoveX = e.getX(); float newMoveY = e.getY(); float angleX = (float)(newMoveX - moveX)*360.0f/(float)getSize().width;//Assign x angle float angleY = (float)(newMoveY - moveY)*360.0f/(float)getSize().height;//Assign y angle float mBuf1[] = new float[16]; float mBuf2[] = new float[16]; moveX = newMoveX; moveY = newMoveY; if ((angleX != 0.0f) || (angleY != 0.0f)) { mFun.rotateAroundY(((float)angleX), mBuf1); mFun.rotateAroundX(((float)angleY), mBuf2); //Accredit particle source..fair, for matrix mFun.multiplyMatrices(mBuf2,mBuf1, mBuf1);//Look at both mFun.multiplyMatrices(rotation, mBuf1, rotation); } } } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { //Ensure initialisation if (glj.gljMakeCurrent(true)== false) return; switch(e.getKeyCode()) { case KeyEvent.VK_PAGE_UP: {//Move back with page up z -=0.5f; break; } case KeyEvent.VK_PAGE_DOWN: {//Move forward with pd z +=0.5f; break; } //Change position, change to strafe case KeyEvent.VK_UP:{//height y -=0.1f; break; } case KeyEvent.VK_DOWN:{//height y +=0.1f; break; }//Give a camera like feel // case KeyEvent.VK_RIGHT:{//pan x -=0.1f; break; } case KeyEvent.VK_LEFT:{//pan x +=0.1f; break; } } glj.gljFree(); } public void keyReleased(KeyEvent e) { } } } |
From: Kenneth B. R. <kbr...@al...> - 2002-02-26 16:51:28
|
In addition to Mark Montana's advice on using the OpenGL selection mechanism, you may also want to consider doing the ray-object intersections in your application to get more control over the selection process. The free software library gleem ( http://www.media.mit.edu/~kbrussel/gleem/ ) implements a small library of 3D manipulator widgets on top of "OpenGL for Java Technology" (the official, non-trademark-infringing name of GL4Java). You could use this library to implement your picking and moving, and for the 1D and 2D translation widgets, even replace the widgets' geometry with your own. |
From: Mark M. <pat...@lm...> - 2002-02-26 15:52:12
|
Mark, There are two things you have to understand about selection (ie, picking). First, you have to understand how pure OpenGL does picking. The OpenGL "Red" book will have a nice chapter on this subject, and I really recommend that you read that. Second, you have to understand how GL4Java catches the mouse click events for picking. I can give you a brief description below, but you need to do some reading. How OpenGL does picking: When OpenGL is told that the user clicked the mouse in the canvas for the purpose of picking (see below), it has to render the entire scene at that point (or at least render the objects that you intend to be pickable). OpenGL needs to be told where your mouse was during the click, and you define a "hot area" around the mouse cursor (usually 5x5 pixels) by modifying the matrix stack (see "Red" book). When it renders the scene during this particular frame, nothing is drawn on the monitor. Instead every object is drawn in memory only. Do accomplish this you must put OpenGL in picking mode (see "Red" book). OpenGL will generate a list of every object rendered during this picking frame that happened to intersect with the "hot area" around the mouse cursor. Then it returns this list (ie, "hit" list) for you to process. The list is actually a list of integers. The integers correspond to various 'names' (integers not Strings) that you specified immediately before rendering each object during the pick frame. In other words, you tell OpenGL what integer name you choose for each object during the picking frame. (See "Red" book). Finally, you have to parse through the hit list yourself and decide which object you really intended to pick if there are multiple objects. The easiest method is to just get the first object in that Hit list. What you do with that information (ie, the integer name of the picked object) is up to you and your program design at this point. Remember you ONLY need to put OpenGL in picking mode when you intend to do picking. You ONLY need to modify the matrix stack to have the 5x5 pixel hat area when you intend to do picking. And you ONLY have to provide integers names to objects during the frame that you intend to do picking. Otherwise you are wasting time and screwing up your normal render frames. How GL4Java catches a mouse click: You need to make an object that implements the GLEventListener in GL4Java. Then you need to register this event listener with you GLAnimCanvas, or whatever type of Canvas you are using. Your application should know that it is in picking mode (via some GUI mode you are in), and it should perform all the picking work mentioned above upon the next mouse click. Good luck, Mark M "R.M. Logan" wrote: > Hello, > I was wondering if anybody could help, I'm trying to make objects > in my applet window selectable ie. to select a sphere to trigger an > event...so far i've been mostly following tutorials to get where i am..i > have an environment where objects can be placed and then rotated, zoomed > around with the mouse and keys. I know that to select the objects it's > something to do with hits, but so far i'm at a loss. > If anybody could point me in the correct direction that would be great. > Below is the basic structure of my applet, without my attempts so far at > selection, which will begin from mouseclicked and trigger a select(float > x, float y) method, but i'm again not sure about the methods (esp GL) > which are required. Many thanks. > > //Mark Logan > //Selection of objects in an applet window > > import java.applet.*; > import java.awt.*; > import java.awt.event.*; > > //Gl4Java classes..get out of red > > import gl4java.GLContext; > import gl4java.awt.GLAnimCanvas; > import gl4java.utils.textures.*; > > public class Windowt extends Applet { > > renderCanvas canvas = null; > > //Initialise applet > public void init() { > > setLayout(new BorderLayout());//lays applet components out > canvas = new renderCanvas(getSize().width, getSize().height); > canvas.requestFocus(); > add("Center", canvas); > } > > //Begin the applet > > public void start() { > canvas.start(); //Begins canvas animation > } > > public void stop() { > canvas.stop();//stops the canvas > } > > public void destroy() { > canvas.stop(); > canvas.destroy();//destroys canvas > } > > private class renderCanvas extends GLAnimCanvas implements > KeyListener,MouseListener, MouseMotionListener { > > float xrot = 0.0f;//rotation for x and y > float yrot = 0.0f; > > float moveX = 0.0f;//For mouse movements, try as ints > float moveY = 0.0f; > > float x = 0.0f; > float y = 0.0f; > float z = -8.0f; > > public renderCanvas(int w, int h) { > super(w, h); > addKeyListener(this); > addMouseListener(this); > addMouseMotionListener(this); > } > > public void preInit() { > > doubleBuffer = true; > stereoView = false; > } > > public void init() { > > gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);//Clears colour, change > background > gl.glClearDepth(1.0);//Clear depth buffer > gl.glDepthFunc(GL_LESS);//Depth test > gl.glEnable(GL_DEPTH_TEST);//enable test of depth > gl.glShadeModel(GL_SMOOTH);//Smooth colour shading > gl.glMatrixMode(GL_PROJECTION);//Projection matrix > gl.glLoadIdentity();//Resets matrix > glu.gluPerspective(45.0f, > (float)getSize().width/(float)getSize().height, 0.1f, 100f);//Calculate > window aspect ratio > gl.glMatrixMode(GL_MODELVIEW);//Model view matrix > } > > public void destroy() { > cvsDispose();//Destroys GL context > } > > public void reshape(int width, int height) > { > //Might need to change viewport for object selection??? > gl.glViewport(0, 0 , width, height);//Reset viewport & perspective > gl.glMatrixMode(GL_PROJECTION);//select proj matrix > gl.glLoadIdentity();//reset proj matrix > glu.gluPerspective(45.0f, > (float)getSize().width/(float)getSize().height,0.1f, 100.0f);//Aspect > ratio of window > gl.glMatrixMode(GL_MODELVIEW); > } > > public void display() {//Draw to the canvas > //Changing to implement true camera... > if (glj.gljMakeCurrent(true)==false) > return;//Is GL initialised properly > gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//Clears > //screen & depth buffer > gl.glLoadIdentity();//Reset view > //Look at this, pan for keys, just sub letters for numbers > //Think x and z in terms of new camera movements > > gl.glTranslatef(0.0f, 0.0f, z);//Move into environment > gl.glTranslatef(x, 0.0f, 0.0f);//Strafe > gl.glTranslatef(0.0f, y, 0.0f);//Strafe > gl.glRotatef(xrot,0.0f,1.0f,0.0f);//Rotate on x axis > gl.glRotatef(yrot,1.0f,0.0f,0.0f);//Rotate y..swapped > > renderSphereRed(-2.0f, 1.0f, -1.0f);//Wrap bitmaps around > renderSphereBlue(2.0f, 2.0f, 2.0f);//Need morphing operation > renderSphereYellow(2.0f, 4.0f, 5.0f);//?Name convertor needed > > gl.glFlush();//Might not be necessary > > gl.glEnd(); > > glj.gljSwap();//Swap buffers > glj.gljFree(); > } > > > private void renderSphereRed(float x, float y, float z) {//Create > sphere > > gl.glPushMatrix(); > gl.glTranslatef(x,y,z); > > long qobj = glu.gluNewQuadric(); > glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); > glu.gluQuadricNormals(qobj, GLU_SMOOTH); > gl.glColor3f(1.0f,0.0f,0.0f);//Red > glu.gluQuadricTexture(qobj, false); > glu.gluSphere(qobj, 0.4f, 16, 16); > glu.gluDeleteQuadric(qobj); > > gl.glPopMatrix(); > } > > private void renderSphereYellow(float x, float y, float z) > {//Create sphere > > gl.glPushMatrix(); > gl.glTranslatef(x,y,z); > > long qobj = glu.gluNewQuadric(); > glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); > glu.gluQuadricNormals(qobj, GLU_SMOOTH); > gl.glColor3f(1.0f, 1.0f, 0.0f);//Yellow > glu.gluQuadricTexture(qobj, false); > glu.gluSphere(qobj, 0.4f, 16, 16); > glu.gluDeleteQuadric(qobj); > > gl.glPopMatrix(); > } > > private void renderSphereBlue(float x, float y, float z) {//Create > sphere > > gl.glPushMatrix(); > gl.glTranslatef(x,y,z); > > long qobj = glu.gluNewQuadric(); > glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); > glu.gluQuadricNormals(qobj, GLU_SMOOTH); > gl.glColor3f(0.0f, 0.0f, 1.0f);//Blue > glu.gluQuadricTexture(qobj, false); > glu.gluSphere(qobj, 0.4f, 16, 16); > glu.gluDeleteQuadric(qobj); > > gl.glPopMatrix(); > } > > //Required for implementation of mouselistener etc... > public void mouseEntered(MouseEvent e) { > Component comp = e.getComponent(); > > if(comp.equals(this)) { > requestFocus(); > } > } > > public void mouseExited(MouseEvent e) { > } > > public void mousePressed(MouseEvent e) {//Find a way to hide the > mouse pointer > moveX = e.getX();//Take new mouse reading > moveY = e.getY(); > //Selection here > if ((e.getModifiers() & > InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK) { > //Test for cursor hiding, hand selector > setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); > } > } > public void mouseReleased(MouseEvent e) { > > setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); > > } > > public void mouseClicked(MouseEvent e) { > Component comp = e.getComponent(); > if(comp.equals(this)) { > requestFocus(); > } > > } > > public void mouseMoved(MouseEvent e) { > } > public void mouseDragged(MouseEvent e) { > //Reposition, for better format. > //Again, rearrange, put in method for both buttons held down and y > coordinate zoom > //Manual zoom.... > > if ((e.isMetaDown()) & ((e.getModifiers() & > InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)) { > setCursor( Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); > > float newMoveY = e.getY();//Need distance for zoom > > //See which feels better for user > z -= newMoveY - moveY; > > //Update method > > moveY = newMoveY; > > } > > //Think about proper camera, might need sin methods... > > else if (e.isMetaDown()) { > setCursor( > Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));//Find correct method > > float newMoveX = e.getX();//Give us new mouse position > float newMoveY = e.getY(); > > xrot -= newMoveX - moveX;//See which feels better for user > yrot -= newMoveY - moveY; > > //Update method > moveX = newMoveX; > moveY = newMoveY; > > } > > > } > > > //Find actionlistener thing in swing book > public void keyTyped(KeyEvent e) { > //Leave keyboard events out, put mouse in > } > public void keyPressed(KeyEvent e) { > > //Ensure initialisation > if (glj.gljMakeCurrent(true)== false) > return; > > switch(e.getKeyCode()) { > case KeyEvent.VK_PAGE_UP: {//Move back with page up > z -=0.5f; > break; > } > case KeyEvent.VK_PAGE_DOWN: {//Move forward with pd > z +=0.5f; > break; > } > //Change position, change to strafe > case KeyEvent.VK_UP:{//height > y -=0.1f; > break; > } > case KeyEvent.VK_DOWN:{//height > y +=0.1f; > break; > }//Give a camera like feel > > // > case KeyEvent.VK_RIGHT:{//pan > x -=0.1f; > break; > } > case KeyEvent.VK_LEFT:{//pan > x +=0.1f; > break; > } > } > glj.gljFree(); > > } > public void keyReleased(KeyEvent e) { > > } > } > } > > _______________________________________________ > gl4java-usergroup mailing list > gl4...@li... > https://lists.sourceforge.net/lists/listinfo/gl4java-usergroup |
From: R.M. L. <u8...@cs...> - 2002-02-26 12:43:06
|
Hello, I was wondering if anybody could help, I'm trying to make objects in my applet window selectable ie. to select a sphere to trigger an event...so far i've been mostly following tutorials to get where i am..i have an environment where objects can be placed and then rotated, zoomed around with the mouse and keys. I know that to select the objects it's something to do with hits, but so far i'm at a loss. If anybody could point me in the correct direction that would be great. Below is the basic structure of my applet, without my attempts so far at selection, which will begin from mouseclicked and trigger a select(float x, float y) method, but i'm again not sure about the methods (esp GL) which are required. Many thanks. //Mark Logan //Selection of objects in an applet window import java.applet.*; import java.awt.*; import java.awt.event.*; //Gl4Java classes..get out of red import gl4java.GLContext; import gl4java.awt.GLAnimCanvas; import gl4java.utils.textures.*; public class Windowt extends Applet { renderCanvas canvas = null; //Initialise applet public void init() { setLayout(new BorderLayout());//lays applet components out canvas = new renderCanvas(getSize().width, getSize().height); canvas.requestFocus(); add("Center", canvas); } //Begin the applet public void start() { canvas.start(); //Begins canvas animation } public void stop() { canvas.stop();//stops the canvas } public void destroy() { canvas.stop(); canvas.destroy();//destroys canvas } private class renderCanvas extends GLAnimCanvas implements KeyListener,MouseListener, MouseMotionListener { float xrot = 0.0f;//rotation for x and y float yrot = 0.0f; float moveX = 0.0f;//For mouse movements, try as ints float moveY = 0.0f; float x = 0.0f; float y = 0.0f; float z = -8.0f; public renderCanvas(int w, int h) { super(w, h); addKeyListener(this); addMouseListener(this); addMouseMotionListener(this); } public void preInit() { doubleBuffer = true; stereoView = false; } public void init() { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);//Clears colour, change background gl.glClearDepth(1.0);//Clear depth buffer gl.glDepthFunc(GL_LESS);//Depth test gl.glEnable(GL_DEPTH_TEST);//enable test of depth gl.glShadeModel(GL_SMOOTH);//Smooth colour shading gl.glMatrixMode(GL_PROJECTION);//Projection matrix gl.glLoadIdentity();//Resets matrix glu.gluPerspective(45.0f, (float)getSize().width/(float)getSize().height, 0.1f, 100f);//Calculate window aspect ratio gl.glMatrixMode(GL_MODELVIEW);//Model view matrix } public void destroy() { cvsDispose();//Destroys GL context } public void reshape(int width, int height) { //Might need to change viewport for object selection??? gl.glViewport(0, 0 , width, height);//Reset viewport & perspective gl.glMatrixMode(GL_PROJECTION);//select proj matrix gl.glLoadIdentity();//reset proj matrix glu.gluPerspective(45.0f, (float)getSize().width/(float)getSize().height,0.1f, 100.0f);//Aspect ratio of window gl.glMatrixMode(GL_MODELVIEW); } public void display() {//Draw to the canvas //Changing to implement true camera... if (glj.gljMakeCurrent(true)==false) return;//Is GL initialised properly gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//Clears //screen & depth buffer gl.glLoadIdentity();//Reset view //Look at this, pan for keys, just sub letters for numbers //Think x and z in terms of new camera movements gl.glTranslatef(0.0f, 0.0f, z);//Move into environment gl.glTranslatef(x, 0.0f, 0.0f);//Strafe gl.glTranslatef(0.0f, y, 0.0f);//Strafe gl.glRotatef(xrot,0.0f,1.0f,0.0f);//Rotate on x axis gl.glRotatef(yrot,1.0f,0.0f,0.0f);//Rotate y..swapped renderSphereRed(-2.0f, 1.0f, -1.0f);//Wrap bitmaps around renderSphereBlue(2.0f, 2.0f, 2.0f);//Need morphing operation renderSphereYellow(2.0f, 4.0f, 5.0f);//?Name convertor needed gl.glFlush();//Might not be necessary gl.glEnd(); glj.gljSwap();//Swap buffers glj.gljFree(); } private void renderSphereRed(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(1.0f,0.0f,0.0f);//Red glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } private void renderSphereYellow(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(1.0f, 1.0f, 0.0f);//Yellow glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } private void renderSphereBlue(float x, float y, float z) {//Create sphere gl.glPushMatrix(); gl.glTranslatef(x,y,z); long qobj = glu.gluNewQuadric(); glu.gluQuadricOrientation(qobj , GLU_OUTSIDE); glu.gluQuadricNormals(qobj, GLU_SMOOTH); gl.glColor3f(0.0f, 0.0f, 1.0f);//Blue glu.gluQuadricTexture(qobj, false); glu.gluSphere(qobj, 0.4f, 16, 16); glu.gluDeleteQuadric(qobj); gl.glPopMatrix(); } //Required for implementation of mouselistener etc... public void mouseEntered(MouseEvent e) { Component comp = e.getComponent(); if(comp.equals(this)) { requestFocus(); } } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) {//Find a way to hide the mouse pointer moveX = e.getX();//Take new mouse reading moveY = e.getY(); //Selection here if ((e.getModifiers() & InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK) { //Test for cursor hiding, hand selector setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } } public void mouseReleased(MouseEvent e) { setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } public void mouseClicked(MouseEvent e) { Component comp = e.getComponent(); if(comp.equals(this)) { requestFocus(); } } public void mouseMoved(MouseEvent e) { } public void mouseDragged(MouseEvent e) { //Reposition, for better format. //Again, rearrange, put in method for both buttons held down and y coordinate zoom //Manual zoom.... if ((e.isMetaDown()) & ((e.getModifiers() & InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)) { setCursor( Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); float newMoveY = e.getY();//Need distance for zoom //See which feels better for user z -= newMoveY - moveY; //Update method moveY = newMoveY; } //Think about proper camera, might need sin methods... else if (e.isMetaDown()) { setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));//Find correct method float newMoveX = e.getX();//Give us new mouse position float newMoveY = e.getY(); xrot -= newMoveX - moveX;//See which feels better for user yrot -= newMoveY - moveY; //Update method moveX = newMoveX; moveY = newMoveY; } } //Find actionlistener thing in swing book public void keyTyped(KeyEvent e) { //Leave keyboard events out, put mouse in } public void keyPressed(KeyEvent e) { //Ensure initialisation if (glj.gljMakeCurrent(true)== false) return; switch(e.getKeyCode()) { case KeyEvent.VK_PAGE_UP: {//Move back with page up z -=0.5f; break; } case KeyEvent.VK_PAGE_DOWN: {//Move forward with pd z +=0.5f; break; } //Change position, change to strafe case KeyEvent.VK_UP:{//height y -=0.1f; break; } case KeyEvent.VK_DOWN:{//height y +=0.1f; break; }//Give a camera like feel // case KeyEvent.VK_RIGHT:{//pan x -=0.1f; break; } case KeyEvent.VK_LEFT:{//pan x +=0.1f; break; } } glj.gljFree(); } public void keyReleased(KeyEvent e) { } } } |