Show Posts
|
|
Pages: [1]
|
|
1
|
Java Game APIs & Engines / JOGL Development / Re: simple transparency
|
on: 2006-08-07 01:11:28
|
There's a difference between transparent and translucent. An alpha channel is used to define the opacity of every single pixel of an image, this is (relatively) rarely used, while a single transparent color (sup "magic pink") is just a simple transparency for non-rectangular sprites etc, this can be found everywhere, like here ->  , that's why I expected opengl to have some way to set one transparent color for textures...
|
|
|
|
|
3
|
Java Game APIs & Engines / JOGL Development / simple transparency
|
on: 2006-08-05 03:49:19
|
Ok, I've been reading tutorials (nehe, jumping into, redbook, forum search...) for hours now, and I can't find a solution to this simple problem: How do I get simple transparent backgrounds for my textured sprites?! I convert a texture with black background (RGB), and I can't get it to be displayed correctly with transparent background. If I use blending with GL_ONE/GL_ONE or whatever else, it's transparent all right, but the sprites are blended together, too, not drawn on top of each other! do I really need to use RGBA sprites to have a single transparent color?! I guess it's something incredibly trivial I just fail to see... 
|
|
|
|
|
4
|
Java Game APIs & Engines / JOGL Development / Re: INVALID_OPERATION
|
on: 2006-08-04 12:43:42
|
changed the code a bit to have all gl calls in one sequence. 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
| if(blah == null) while(!queue.isEmpty()) queue.remove().draw(this);
try {
gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,0.0f,-5.0f);
if(blah == null) {
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
gl.glBegin(GL.GL_QUADS); { gl.glColor3f(1.0f, 0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); } gl.glEnd();
} else { blah.bind(gl);
blah.textureBuffer.rewind(); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, blah.texWidth, blah.texHeight, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, blah.textureBuffer);
gl.glColor3f(0.0f, 1.0f, 1.0f);
gl.glBegin(GL.GL_QUADS); {
gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f);
gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f);
gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f);
gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f);
} gl.glEnd(); } |
exception thrown: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| java.lang.NullPointerException at com.sun.opengl.impl.FunctionAvailabilityCache$Version.<init>(FunctionAvailabilityCache.java:296) at com.sun.opengl.impl.FunctionAvailabilityCache.initAvailableExtensions(FunctionAvailabilityCache.java:133) at com.sun.opengl.impl.FunctionAvailabilityCache.isExtensionAvailable(FunctionAvailabilityCache.java:104) at com.sun.opengl.impl.GLContextImpl.isExtensionAvailable(GLContextImpl.java:337) at com.sun.opengl.impl.GLImpl.isExtensionAvailable(GLImpl.java:27851) at com.sun.opengl.impl.GLImpl.initBufferObjectExtensionChecks(GLImpl.java:27994) at com.sun.opengl.impl.GLImpl.checkUnpackPBODisabled(GLImpl.java:28027) at com.sun.opengl.impl.GLImpl.glTexImage2D(GLImpl.java:19578) at javax.media.opengl.DebugGL.glTexImage2D(DebugGL.java:8445) at com.mugenguild.vMugen.graphics.OglDisplay.display(OglDisplay.java:250) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298) at java.awt.event.InvocationEvent.dispatch(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) |
I have absolutely no idea what this could mean. The ByteBuffer is not null (I checked in the debugger, it's all how it's supposed to be, and also the nullpointerexception doesn't occur at the rewind), texwidth results to 64, texheight results to 128, all other parameters are constants. there were no exceptions caught where this call was made before also, the exception looks more like a function is missing or something within the ogl libs... hum. any ideas? Heh, wasn't sure if it would affect it or not, maybe I shouldn't be giving advice as a JOGL newb
no, why? it was an idea, and you learned something. nothing wrong there  \\ edit almost the same error msg here, so I guess it's not my code that is causing the problem... http://www.java-gaming.org/forums/index.php?topic=13705.0 \\\ edit ARRGH!!! I forgot to put a glEnd() at the end of a drawLine call, which I didn't even know was executed!! this, and the bug, made up for a perfect combination to keep me entertained, really >_< \\\\ edit f**kin' woot. it's working now. thanks, everyone =)
|
|
|
|
|
5
|
Java Game APIs & Engines / JOGL Development / Re: INVALID_OPERATION
|
on: 2006-08-04 01:53:54
|
No brackets, not sure if this is what the problem is tho
you can use brackets whereever you like, with local vars and stuff. and for indentation and readability, I think putting glBegin and glEnd into brackets makes sense  Since you aren't getting an OpenGL error earlier in your execution you need to trim down your rendering until you isolate exactly the sequence of calls provoking the error. It isn't obvious from the code you posted where the error is (or in fact if the error is there or in another part of your code, for example the texture handling code).
well, it more or less is. the queue loop (almost) directly calls the texture binding code. I'll try to get it all in a sequence like you said, though. Thanks for helping 
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / INVALID_OPERATION
|
on: 2006-08-03 20:00:43
|
Okay... I got this error, and I have absolutely no clue what it might be caused by. My code is more or less directly taken from NeHe tutorial jogl example code, since I've gone back step by step in order to track that bug. Didn't work out. Some code: init function, should be self-explaining 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| this.drawable = drawable; drawable.setAutoSwapBufferMode(false);
this.glu = new GLU();
drawable.setGL(new DebugGL(drawable.getGL())); this.gl = drawable.getGL();
gl.glEnable(GL.GL_TEXTURE_2D); gl.glShadeModel(GL.GL_SMOOTH); gl.glClearDepth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LEQUAL);
this.gl = null; |
display method, interesting comments with !!! 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
| gl = drawable.getGL(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
if(blah == null) while(!queue.isEmpty()) queue.remove().draw(this);
try {
gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f,0.0f,-5.0f);
if(blah == null) {
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
gl.glBegin(GL.GL_QUADS); { gl.glColor3f(1.0f, 0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f); } gl.glEnd();
} else {
gl.glColor3f(0.0f, 1.0f, 1.0f); blah.bind(gl);
gl.glBegin(GL.GL_QUADS); {
gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, -1.0f, 1.0f);
gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, -1.0f, 1.0f);
gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f);
gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f);
} gl.glEnd(); } } catch (GLException e) { e.printStackTrace(); }
gl.glFlush();
gl = null; |
reshape 1 2 3 4 5 6 7 8 9 10 11
| this.gl = drawable.getGL();
final float h = (float)width / (float)height;
gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 20.0); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity();
this.gl = null; |
texture making code, only the important bits. everything else is a-ok. 1 2 3 4 5 6 7
| imageBuffer = ByteBuffer.allocateDirect(data.length); imageBuffer.order(ByteOrder.nativeOrder()); imageBuffer.put(data, 0, data.length);
imageBuffer.rewind(); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, texWidth, texHeight, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, imageBuffer); |
given error 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
| javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glEnd(): GL_INVALID_OPERATION at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:11724) at javax.media.opengl.DebugGL.glEnd(DebugGL.java:1816) at com.mugenguild.vMugen.graphics.OglDisplay.display(OglDisplay.java:244) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) 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) javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glEnd(): GL_INVALID_OPERATION at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:11724) at javax.media.opengl.DebugGL.glEnd(DebugGL.java:1816) at com.mugenguild.vMugen.graphics.OglDisplay.display(OglDisplay.java:266) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298) at java.awt.event.InvocationEvent.dispatch(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) |
wtf?! I've been shooting trouble for like, 5 hours now, and I can't seem to find any error. the only difference left, is that the texture is bound during the display routine instead of the init routine. but that can't be it... nuh?  ...anyone? 
|
|
|
|
|
8
|
Discussions / Miscellaneous Topics / project stats
|
on: 2006-02-20 21:30:01
|
hey  does any of you know of any program that calculates some statistics of a java project? like, count of words, count of words in comments, most referenced field, most instantiated class, stuff like that... no runtime information, just plain sourcecode statistics... searching google for words like "text statistics" or "java project statistics" doesn't work, the words are use in other contexts too often 
|
|
|
|
|
10
|
Game Development / Performance Tuning / Re: which collection to use?
|
on: 2006-02-03 00:25:08
|
I never said this was my bottleneck, it's just that there are about 30000 values stored in hashmaps out of which about ~1000 need to be called per tick (1/60 second) or more, so I thought there might be a better way than boxing. It's not critical at all, but why not optimize it  My bottleneck is - surprise, surprise - java2d 
|
|
|
|
|
13
|
Game Development / Performance Tuning / Re: which collection to use?
|
on: 2006-01-30 14:35:51
|
|
I know, but still using a direct int->object association is faster (saves one boxing and two hash calls per get, and I need tons of gets) than using a boxed int, that's why I asked if there was any specific implementation for that.
|
|
|
|
|
17
|
Discussions / Miscellaneous Topics / Re: if(i < j < k) ...
|
on: 2006-01-29 10:29:33
|
also, that would be slower than i < j && j < k, since if i < j evaluates to false, the whole expression can't be true anymore and it stops operating (try 0 && i++, it won't increment). you lose that edge with your idea 
|
|
|
|
|
18
|
Game Development / Performance Tuning / Re: which collection to use?
|
on: 2006-01-29 08:34:43
|
As I said in my first post, I can't use arraylist or the like because the indices aren't incremental. anyways, thanks for the javolution link, I didn't know about that before and it seems pretty nifty  that whole page seems to be an advertisement for those libs, though. any experiences? o_O
|
|
|
|
|
19
|
Game Development / Performance Tuning / Re: calling methods using reflection
|
on: 2006-01-29 08:27:58
|
|
if I cache the methods in a HashMap<String, Method>, it's 40% slower than using getMethod, so sticking with getMethod is definitely the better solution.
but, during my tests, this line getClass().getMethod("__" + input.sval, new Class[] { HashMap.class }).invoke(this, new Object[] { data } ); several times actually performed better than this line, even if only by a small margin (10%) ((AbstractInstance) caller).__out(data);
huh, wacky.
|
|
|
|
|
21
|
Game Development / Performance Tuning / which collection to use?
|
on: 2006-01-14 11:00:14
|
hey there  The game I'm working on heavily depends on non-incremental numbers associated with objects (for many different purposes), and I can't find a good type of collection for this. ArrayList, Vector and LinkedList all depend on incremental indices, all other collections associate Objects with Objects. Right now I'm using HashMap<Integer, Object>, but I guess that's far from being the optimal solution. Is there any int -> Object collection implementation which I simply overlooked? If that's not the case, is HashMap<Integer, Object> a good enough solution or should I write my own collection for this purpose?
|
|
|
|
|
22
|
Java Game APIs & Engines / JOGL Development / Re: crashes :(
|
on: 2005-12-25 03:47:32
|
yay, it doesn't crash anymore  is this common knowledge I just missed?? I mean, this invalidates all jogl tutorials etc and I didn't find any note about this, not even in the release notes... might want to fix that to avoid more questions 
|
|
|
|
|
24
|
Java Game APIs & Engines / JOGL Development / crashes :(
|
on: 2005-12-24 08:00:03
|
hey guys  I'm having some problems with random crashes, and hope someone here can help me out  My gameloop is not handled by an animator, autoswapbuffer mode is 0, and each tick (after processing game logic), drawable.display() is called which calls display(), which calls the draw callbacks (and loads textures etc). after stuff is rendered, the game loop sleeps until end of tick (1/60 second) and swaps the buffer. the loading routine for the texture is this: 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
| private void makeTexture(GL gl) {
bind(gl); int srcPixelFormat; if (bi.getColorModel().hasAlpha()) srcPixelFormat = GL.GL_RGBA; else srcPixelFormat = GL.GL_RGB;
ByteBuffer textureBuffer = convertImageData(bi, texWidth, texHeight);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, texWidth, texHeight, 0, srcPixelFormat, GL.GL_UNSIGNED_BYTE, textureBuffer);
}
private static ByteBuffer convertImageData(BufferedImage bi, int texWidth, int texHeight) { ByteBuffer imageBuffer = null; WritableRaster raster; BufferedImage texImage;
if (bi.getColorModel().hasAlpha()) { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null); texImage = new BufferedImage(glAlphaColorModel, raster, false, null); } else { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null); texImage = new BufferedImage(glColorModel, raster, false, null); }
Graphics2D g = (Graphics2D) texImage.getGraphics(); g.setColor(new Color(0f, 0f, 0f, 0f)); g.fillRect(0, 0, texWidth, texHeight); g.drawImage(bi, 0, 0, null);
byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData();
imageBuffer = ByteBuffer.allocateDirect(data.length); imageBuffer.order(ByteOrder.nativeOrder()); imageBuffer.put(data, 0, data.length);
return imageBuffer; } |
texwidth and texheight are the closest potence of 2 of the image's width/height, glColorModel/glAlphacolorModel are obviously the color models needed for the conversion, as you can see a good part of the code is taken from the known tutorials  the crashes occur at the glTexImage2D call, error is this: # An unexpected error has been detected by HotSpot Virtual Machine: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x697553d5, pid=1756, tid=1500 # # Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode) # Problematic frame: # C [nvoglnt.dll+0x2553d5] # # An error report file with more information is saved as hs_err_pid1756.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp #
ideas, anyone? 
|
|
|
|
|