Show Posts
|
|
Pages: [1] 2 3 4
|
|
2
|
Java Game APIs & Engines / JOGL Development / Re: Saving GLUTessellation Data
|
on: 2007-04-12 18:07:23
|
Probably the simplest way to do this is with a display list. The syntax is something like this: 1 2 3 4 5 6
| int list = gl.glGenLists(1); gl.glNewList(list,GL.GL_COMPILE); ... your call to the Tessellator here .... gl.glEndList(); |
Then, when you want to actually render into the scene, call gl.glCallList(list); There are other techniques like vertex buffer objects and the like, but that would probably require a major re-write of your Tessellator. This technique is pretty quick and easy.
|
|
|
|
|
3
|
Java Game APIs & Engines / JOGL Development / Re: newbie: read and display bitmap
|
on: 2007-04-06 20:15:47
|
Two possibilities leap to mind for me: 1) Instead of glDrawPixels, use the TextureIO and Texture classes that are in the com.sun.opengl.util.texture package. Then enable and bind the texture and draw a square with the appropriate texture coordinates: 1 2 3 4 5 6
| glBegin( GL_QUADS ); glTexCoord2d(0.0,0.0); glVertex2d(0.0,0.0); glTexCoord2d(1.0,0.0); glVertex2d(1.0,0.0); glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0); glTexCoord2d(0.0,1.0); glVertex2d(0.0,1.0); glEnd(); |
The use of the texture classes is fairly straightforward from the javadocs (and a bunch of the demos use them, as well). This is convinient in JOGL because those texture classes encapsulate all the hard work. 2) using glDrawPixels, use the javax.imageio.ImageIO.read(file) method to read the file, and pull the pixel data out of the resulting BufferedImage and store it in a java.nio.floatBuffer . You should be able to pass that into glDrawPixels... except, I think (although I'm not sure how consistent this is on various machines), bmp data is stored as BGR instead of the usual RGB, so your format will probably be GL_BGR (although it might be GL_RGB).
|
|
|
|
|
10
|
Java Game APIs & Engines / JOGL Development / loadDRIHack() vanishes in 1.1.0
|
on: 2007-01-10 07:46:57
|
|
I noticed that the com.sun.opengl.impl.NativeLibLoader.loadDRIHack() method mysteriously vanished in jogl 1.1.0 ... does this mean that the NativeLibLoader class shouldn't be used in applications (e.g. that it may or may not be around in the future) ?
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / Re: Mouse pointer
|
on: 2006-12-19 08:36:14
|
|
I've been looking into using java.awt.Robot to do as you say (e.g. to keep it from leaving the frame). But the javadocs suggest that it isn't supposed to be used in applications (e.g. for "testing"). Is there some reason that they say it should be only used for testing?
|
|
|
|
|
13
|
Java Game APIs & Engines / JOGL Development / Re: How to calculate vertex normals.
|
on: 2006-12-08 02:16:06
|
Below is the method I use for computing normals in a hightfield data set (the getData(x,y) method call gets the height value at the specified x,y coordinates). The main complication is that around the edges, there are viewer values available to do it. Note that I'm using the Java3D vecmath package for the vector math. 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| private Vector3f computeNormal(int xCoord,int yCoord) { Vector3f[] vecs = this.normalCompVecs; int gran = this.normalGranularity; float scal = this.normalScaling; float value = getData(xCoord,yCoord); if ((vecs.length - 1) == 8) { int vecsToCross = 1; int xp1 = xCoord + 1; int xm1 = xCoord - 1; int yp1 = yCoord + 1; int ym1 = yCoord - 1; boolean left = (xCoord == 0); boolean right = (xCoord >= (getXSize() - gran)); boolean bottom = (yCoord == 0); boolean top = (yCoord >= (getYSize() - gran)); if (left&&bottom) { vecs[1].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecs[2].set(gran,gran,scal*(getData(xp1,yp1)-value)); vecs[3].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecsToCross = 3; } else if (left&&top) { vecs[1].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecs[2].set(gran,-gran,scal*(getData(xp1,ym1)-value)); vecs[3].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecsToCross = 3; } else if (right&&bottom) { vecs[1].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecs[2].set(-gran,gran,scal*(getData(xm1,yp1)-value)); vecs[3].set(-gran,0,scal*(getData(xm1,yCoord)-value)); vecsToCross = 3; } else if (right&&top) { vecs[1].set(-gran,0,scal*(getData(xm1,yCoord)-value)); vecs[2].set(-gran,-gran,scal*(getData(xm1,ym1)-value)); vecs[3].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecsToCross = 3; } else if (left) { vecs[1].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecs[2].set(gran,-gran,scal*(getData(xp1,ym1)-value)); vecs[3].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecs[4].set(gran,gran,scal*(getData(xp1,yp1)-value)); vecs[5].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecsToCross = 5; } else if (right) { vecs[1].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecs[2].set(-gran,gran,scal*(getData(xm1,yp1)-value)); vecs[3].set(-gran,0,scal*(getData(xm1,yCoord)-value)); vecs[4].set(-gran,-gran,scal*(getData(xm1,ym1)-value)); vecs[5].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecsToCross = 5; } else if (top) { vecs[1].set(-gran,gran,scal*(getData(xm1,yCoord)-value)); vecs[2].set(-gran,-gran,scal*(getData(xm1,ym1)-value)); vecs[3].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecs[4].set(gran,-gran,scal*(getData(xp1,ym1)-value)); vecs[5].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecsToCross = 5; } else if (bottom) { vecs[1].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecs[2].set(gran,gran,scal*(getData(xp1,yp1)-value)); vecs[3].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecs[4].set(-gran,gran,scal*(getData(xm1,yp1)-value)); vecs[5].set(-gran,0,scal*(getData(xm1,yCoord)-value)); vecsToCross = 5; } else { vecs[1].set(gran,0,scal*(getData(xp1,yCoord)-value)); vecs[2].set(gran,gran,scal*(getData(xp1,yp1)-value)); vecs[3].set(0,gran,scal*(getData(xCoord,yp1)-value)); vecs[4].set(-gran,gran,scal*(getData(xm1,yp1)-value)); vecs[5].set(-gran,0,scal*(getData(xm1,yCoord)-value)); vecs[6].set(-gran,-gran,scal*(getData(xm1,ym1)-value)); vecs[7].set(0,-gran,scal*(getData(xCoord,ym1)-value)); vecs[8].set(gran,-gran,scal*(getData(xp1,ym1)-value)); vecsToCross = 8; } for(int i = 1; i < vecsToCross; ++i) vecs[i].cross(vecs[i],vecs[i+1]); if (vecsToCross == 8) { vecs[8].cross(vecs[8],vecs[1]); vecsToCross = 9; } vecs[0].set(0,0,0); for(int i = 1; i < (vecsToCross - 1); ++i) vecs[0].add(vecs[i]); } else throw new Exception("Invalid number of vectors for normal calculatuion"); vecs[0].normalize(); return vecs[0]; }
|
|
|
|
|
|
14
|
Java Game APIs & Engines / JOGL Development / Re: Java2D dynamic Texture is upside down
|
on: 2006-12-08 02:10:04
|
Try using 1
| texdata = new TextureData(GL.GL_RGB, width, height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, false, false, true, imageBuffer, null); |
The difference being the boolean argument "mustFlipVertically" is true instead of false. There are a billion and a half ways of storing textures, and it seems like half of them are upside-down and half are rightside-up (depending on the file format it came from and so on)...
|
|
|
|
|
18
|
Java Game APIs & Engines / JOGL Development / Exception on isFunctionAvailable call
|
on: 2006-11-23 03:57:00
|
|
Below is a stacktrace of an Exception that was thrown when I tried to call gl.isFunctionAvailable("glCreateShader") . This exact same code works perfectly on three other computers, but for some reason it throws this exception on two others (I don't see any obvious connection between the two that generated the exception, other than that they were both Dell laptops). What could be causing this?
java.lang.NumberFormatException: For input string: "GL_ARB_shader_objects" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.valueOf(Unknown Source) at com.sun.opengl.impl.FunctionAvailabilityCache$Version.<init>(FunctionAvailabilityCache.java:312) at com.sun.opengl.impl.FunctionAvailabilityCache.isPartOfGLCore(FunctionAvailabilityCache.java:200) at com.sun.opengl.impl.FunctionAvailabilityCache.isFunctionAvailable(FunctionAvailabilityCache.java:83) at com.sun.opengl.impl.GLContextImpl.isFunctionAvailable(GLContextImpl.java:323) at com.sun.opengl.impl.windows.WindowsGLContext.isFunctionAvailable(WindowsGLContext.java:241) at com.sun.opengl.impl.GLImpl.isFunctionAvailable(GLImpl.java:27847) at sddm.SDDMListener.setupShaderAna(SDDMListener.java:109) at sddm.SDDMListener.init(SDDMListener.java:86) at com.sun.opengl.impl.GLDrawableHelper.init(GLDrawableHelper.java:72) at javax.media.opengl.GLCanvas$InitAction.run(GLCanvas.java:264) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:189) at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:258) at javax.media.opengl.GLCanvas.display(GLCanvas.java:130) at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142) at sun.awt.RepaintArea.paintComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
|
|
|
|
|
22
|
Java Game APIs & Engines / JOGL Development / Strange graphics Corruption
|
on: 2006-10-31 09:00:26
|
|
Attached is a screenshot from an ATI Radeon Mobility 9200... I've gotten something looking like this twice now, once from copying from the frame buffer to a texture, and now in applying a color matrix and copying pixels. Even more strangely, however, if I just copy the frame with the color matrix left alone, it works fine. Has anyone seen anything like this before? It's probably not JOGL-related (more likely the hardware) but I just want to check to be sure.
|
|
|
|
|
23
|
Java Game APIs & Engines / JOGL Development / Re: GL_COLOR_MATRIX or GL_COLOR_MATRIX_EXT
|
on: 2006-10-26 11:55:22
|
|
I've been meaning to take a look at FBOs when I get some time, anyway, although given that I'm mostly writing this as a compatibility technique for older hardware, I'm not sure how useful it'll be.
It seems like you aren't thanked often enough at the end of threads despite pretty much always answering the question... so thanks, Ken
|
|
|
|
|
26
|
Java Game APIs & Engines / JOGL Development / Re: How to use Swing and JOGL to implement this application?
|
on: 2006-10-26 11:40:30
|
|
I'm not sure I understand the question here - are you asking for a basic rundown of how to do anything with JOGL at all, or something specific about this application? It seems fairly straightforward to me - you can draw all the models with the GLUT class that's included in JOGL, and all the settings on the sliders are the basic OpenGL fixed functionality, not Programmable Shaders or anything. I don't imagine it would take more than a few hours to write this (of course, that's without accounting for learning how JOGL works)... So is it just a feasability question, or did you have something more specific?
|
|
|
|
|
27
|
Java Game APIs & Engines / JOGL Development / Checking doublebuffering from inside a GLEventListener
|
on: 2006-10-25 04:40:27
|
|
The subject pretty much says it - is it possible to check if you're single-buffered or double-buffered inside one of the GLEventListener methods? I could, of course, send some sort of signal when generating the listener based on the GLCapabilities, but that's kind of a hassle. I can certainly imagine that the whole point of de-coupling the listeners and drawables would make this impossible, but I'm wondering if there's some clever hack that I'm missing exists...?
|
|
|
|
|
28
|
Java Game APIs & Engines / JOGL Development / Re: GL_COLOR_MATRIX or GL_COLOR_MATRIX_EXT
|
on: 2006-10-25 04:34:57
|
|
Ok, well, that's unfortunate... I wish there was some way to know if it is slow, and use it only when necessary... Oh,well, I guess its the dreaded "implementation specifeic."
Also, is there a way to call glCopyPixels() and have it read/write from a PBuffer to the main frame buffer, or do I have to read from the PBuffer to a texture and then draw to a framebuffer screen-filling rectangle with the texture on it?
|
|
|
|
|
29
|
Java Game APIs & Engines / JOGL Development / Re: GL_COLOR_MATRIX or GL_COLOR_MATRIX_EXT
|
on: 2006-10-24 11:41:39
|
|
After a little bit of experimentation, I've determined that it isn't the color matrix at all - copying from one buffer to the same buffer is apparently very slow (e.g. at least 1000X slower than from one buffer to another). This seems strange, but not a serious problem, as I can just write to aux buffers or Pbuffers and copy from there. Still, it seems strange that a buffer can't self-copy without such a gigantic delay (at least on my test machine).
In a related note, will gl.isExtensionAvailable("GL_SGI_color_matrix") return true if I have an OpenGL Version that supports the builtin version of GL_COLOR ? I'm not sure what version this was added in (I know its there in 2.0, but I'm not sure about anything before), otherwise I suppose I could just directly check the version.
|
|
|
|
|
30
|
Java Game APIs & Engines / JOGL Development / Re: GL_COLOR_MATRIX or GL_COLOR_MATRIX_EXT
|
on: 2006-10-24 05:30:18
|
|
That seems to work, although I can't test it because of a different issue... I'm trying to use the color matrix to manipulate the colors in an image I'm rendering to the frame buffer. If I understand the color matrix correctly, it applys only to pixel transfer operations, but I don't want to copy to main memory, because that's relatively slow. Instead, I'm just doing glCopyPixel(), which in principle should only operate in video memory. The problem is, it's EXTREMELY slow, in fact, much slower than if I copy all the pixels to CPU memory, manipulate them with software, and copy them back, which doesn't seem right. Is there something else that slows down glCopyPixels() that I can work around?
|
|
|
|
|