Show Posts
|
|
Pages: [1] 2
|
|
2
|
Java Game APIs & Engines / OpenGL Development / Re: JOGL and glNormal performance
|
on: 2013-03-02 18:37:37
|
hi theagentd , thanks for the answer but for mistake i post only half of my question so i modified it and in meanwhile you was answering to my half post!!!  i hope that now you can read and answer reading the complete question thanks Using the float version of glNormal (glNormal3f()) should be a bit faster, but you want really good performance you should look into display lists or VBOs. Your data seems to be static, so you should be able to generate your geometry and store it in a display list or VBO, and use glTranslatef() to position your objects when rendering.
|
|
|
|
|
3
|
Java Game APIs & Engines / OpenGL Development / JOGL and glNormal performance
|
on: 2013-03-02 18:04:37
|
hi guys i would like to understand more in deep how works jogl so that i can use the correct chose during my implementation. during one of my exercise i find out a strange behavior that can change the performance of the program that i wrote. this is the question look at this code, that i use to draw a surface flat divided in square 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| private void flatSurface(GL2 gl,int size,int sizeUnit) {
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, new float[]{0.2f, 0.2f, 0.2f, 1f},0); gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, new float[]{0.1f, 0.1f, 0.1f, 1f},0); gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE,new float[]{0.6f, 0.6f, 0.5f, 1f},0 );
gl.glPushMatrix(); gl.glTranslated(-size/2, 1, -size/2);
for (float x = size; x >= 0; x=x-sizeUnit) { gl.glBegin(GL2.GL_QUAD_STRIP); gl.glNormal3d(0, 1, 0); for (float z = size; z >= 0; z=z-sizeUnit) { gl.glVertex3f(x, 0,z); gl.glVertex3f(x+sizeUnit, 0,z); } gl.glEnd(); } gl.glPopMatrix(); } |
I just read that if the glNormal is called one time instead that repeat for each vertex performance are better. Becouse there are less call to GL system. i did the test and in my program the fps are increased 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| gl.glNormal3d(0, 1, 0); for (float z = size; z >= 0; z=z-sizeUnit) { gl.glVertex3f(x, 0,z); gl.glVertex3f(x+sizeUnit, 0,z); }
for (float z = size; z >= 0; z=z-sizeUnit) { gl.glVertex3f(x, 0,z); gl.glNormal3d(0, 1, 0); gl.glVertex3f(x+sizeUnit, 0,z); gl.glNormal3d(0, 1, 0); } |
after that i studied the display list and moved the firs function in a display list to increase more the performance 1 2 3 4
| superficieList = gl.glGenLists(1); gl.glNewList(superficieList, GL2.GL_COMPILE); flatSurface(gl,dimensione,dimensioneUnita); gl.glEndList(); |
so now performance are increased more but with big surprise i noted that: with the display list i can increase more the performance if in the function that draw the surface i use the old code!!! 1 2 3 4 5 6 7
| for (float z = size; z >= 0; z=z-sizeUnit) { gl.glVertex3f(x, 0,z); gl.glNormal3d(0, 1, 0); gl.glVertex3f(x+sizeUnit, 0,z); gl.glNormal3d(0, 1, 0); } |
this has not sense for me and my knowledge can not help my to undestand why. can u help me to understand this beaviour? 
|
|
|
|
|
5
|
Java Game APIs & Engines / OpenGL Development / display list with solid sphere in error
|
on: 2013-03-01 13:36:24
|
hi guys I'm trying to understand how use the display list and i have create a very easy code just to draw a sphere this is my code in the init 1 2 3 4 5 6 7 8 9 10
| public void init(GLAutoDrawable drawable) {
............ ............
sp = gl.glGenLists(1); gl.glNewList(sp, GL2.GL_COMPILE); glut.glutSolidSphere (0.4, 16, 16); gl.glEndList(); } |
bat during the execution of glut.glutSolidSphere (0.4, 16, 16); i take this exception 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
| Exception in thread "Timer-0" java.lang.RuntimeException: java.lang.NullPointerException at jogamp.common.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206) at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172) at javax.media.opengl.Threading.invoke(Threading.java:191) at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:428) at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74) at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:142) at com.jogamp.opengl.util.FPSAnimator$1.run(FPSAnimator.java:128) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) Caused by: java.lang.NullPointerException at it.spaghettisource.cap6.exn6p3.init(exn6p3.java:78) at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:201) at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:222) at javax.media.opengl.awt.GLCanvas$6.run(GLCanvas.java:926) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:521) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:462) at javax.media.opengl.awt.GLCanvas$9.run(GLCanvas.java:964) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646) at java.awt.EventQueue.access$000(EventQueue.java:84) at java.awt.EventQueue$1.run(EventQueue.java:607) at java.awt.EventQueue$1.run(EventQueue.java:605) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:616) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) |
can i use the glut function in the display list? or i have to activate same flag that i forgot? thanks
|
|
|
|
|
6
|
Java Game APIs & Engines / OpenGL Development / make a Porting: Java2D to JOGL
|
on: 2013-01-31 17:54:03
|
|
hi guys
i have a game implemented completely in Java2D, i would like now study jogl and make a complete porting,
my game is a side scrolling shooter. it is mainly based on direct draw of the images using the primitive of java2D --> Graphics2D.drawImage The engine is provided of functionality to modify color and transparent and rotation of the images, finally i have final effect over the final image create drawing directly over it that allow my to make effect like darkness (used for example in the transition between the level etc..), send storm, rain etc....
now studding same tutorial of jogl I undestood that is completely based on a 3D concepts. So to create a flat 2D word i have to: A) create a 3D word with the Z coordinate constant and use the Orthographic Projection B) to print an image create a rectangle/square and load the image as a texture over it
is there another approach "more 2D" that this one, or this is the correct path that i have to follow to reach my target? thanks guys
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Re: How do play a midi file?
|
on: 2013-01-20 19:02:43
|
hi man this is the easy answer to your question, pure java no other libs hire i'm using the old applet lib, you can run wiht JVM 1.1 until JVM 1.7 mcdonald.mid is an old midi file, susbtitute with your if u what to use pure java but you need something little more complex, you have to use JSA (java sound api) JSA this is the official doc http://docs.oracle.com/javase/tutorial/sound/index.htmlthis is a complex demo for ORACLE that will show to use the power of JSA http://www.oracle.com/technetwork/java/index-139508.htmlremeber you have to create a separate a thread to run the music in loop 1 2 3 4 5 6 7 8 9 10 11 12
| public class McDonald {
public static void main(String[] args){ AudioClip mcdClip = Applet.newAudioClip( McDonald.class.getClassLoader().getResource("mcdonald.mid") ); mcdClip.play(); while(true){ System.out.println("manage music in a separate thread not in the main thread like this"); } } } |
|
|
|
|
|
10
|
Games Center / Showcase / Tiger Supply - Java2D space scrolling shoter - my first demo
|
on: 2013-01-10 00:50:55
|
Hi guys this is my first game, finally!!!! (yet demo version  ) To create a game was been always one of my dream when i start to make develop. Actually i do business software professionally since 10 year, so this year i decided to let my (kid) dream become true this is only my you tube demo http://www.youtube.com/v/Wg6lgxjf0jI?version=3&hl=en_US&start= images and graphic is copy from the www just to take same images and give a shape to it. it is very basic, i would like to improve it, specially graphically, but unfortunately i'm not a graphic design and my capabilities in this field are very bad if you want to give any commend bad a good will be appreciated also because this mean that someone is look this video  thanks to all of you, specially to all the answer that i received in this forum that help me to solve problem and find new solutions another question: how to add image to the topic in the showcases?
|
|
|
|
|
12
|
Game Development / Game Play & Game Design / Re: Initial Sprite Location
|
on: 2013-01-09 14:46:43
|
|
I work with more tiled map layer
i use different tiled map based on different scope, this give you a flexibility to manage this stuff separate also in the code instead to have a bundle of code that have to think of all, you ave different pieces for specific scope
1 tile for background 1 tile for solid items 1 tile for enemy ..... ..... ..... 1 tile for final grafica effect
and if you manage all this logic with the pattern chain and the pattern command together, you can introduce every time more layer with little effort
|
|
|
|
|
16
|
Java Game APIs & Engines / Java 2D / Re: OpenGL VM flag degrade performance on Java2D???
|
on: 2013-01-08 00:55:20
|
Next thanks to you regarding the optimization i want to answer to all your idea just to share our knowledge firs of all The chose of the JPanel happen for one specific reason the method JPanel.createImage(pWidth, pHeight) hire the official link to java doc http://docs.oracle.com/javase/6/docs/api/java/awt/Component.html#createImage(java.awt.image.ImageProducer) this method must be called each time in the cycle, because it manage automatically for you the double buffering strategy increasing the performance, so for this reason this object is used by double buffering i can not reuse the same object clearing the immage never tried to do it by canvas, is there a specific method to do it automatically? the old AWT expose something to do it? if exsist let me know i want to try it Ok, then you apply a set of affineTransforms, right?, so you create an intermediate BufferedImage called "filtered" with all the changes. Do you tried directly to draw the image to dbg without creating that "filtered" image?
this part of the code is already optimized, the solution applied is this: every image transformed in the chain of effect is stored in a repository keeping with it information of the kind of transformation performed over it, so every time that on a image is required to execute same effect, first of all I look in the repository if that image with that kind of transformation already exists in this case this image is get and reused, other ways a new image with effect is created and saved in the repository. this make in my case a huge increasing of the performance and aloud to me to work on image modification on the fly but the back side of this solution is the memory used to store images in the repository instead regarding this fact (davedes please don't take it personally, but i have to write this) General consensus is: if you need reliable performance, Java2D is the wrong choice
the fact that exist technologies that are better of the Java2D is something that also the kids know, so if i use this specific section of the forum called Java2D, and not OpenGL Development may be ther is a reason what u think? http://www.java-gaming.org/boards/java-2d/15/view.htmlif i can get 1 euro for all the guys that write in this forum, General consensus is: if you need reliable performance, Java2D is the wrong choice
i will become one of the most reach person in the word (ok i will open a topic for this  ) regarding the real discussion of this topic, Setting flags like that always screams to me
me too!!! i want to try to set the variable J2D_D3D_NO_HWCHECK=true and try to activate the direct3D. i will let to know how it works
|
|
|
|
|
19
|
Java Game APIs & Engines / Java 2D / OpenGL VM flag degrade performance on Java2D???
|
on: 2013-01-07 10:51:20
|
And without the "OpenGL" VM flag?
my situation was to have a game implemented without the flag for the OpenGL. my framework (done in java2D) is completely based on the BufferedImageOp to draw on the fly effect! how my frameworks works is this just create to any cycle the next immage and then the the drawable: 1 2
| dbImage = JPanel.createImage(pWidth, pHeight); dbg = (Graphics2D) dbImage.getGraphics(); |
after that it is pass to the rendering that are 2D sprite based on the bufferedImmage internalRenderGame(dbg); any sprite before to be render on the dbg ( that i s the Graphics2D) is passed to a chain of effect that execute specific effect implemented as BufferedImageOp brightness, and transparence or affine trasfomration for scale and rotation 1 2 3
| BufferedImage filtered = EffectManager.getInstance().chain(filtersToApply,image, position, size, color); dbg.drawImage(filtered, (int)(position.getPosX() - filtered.getWidth()/2), (int)(position.getPosY() - size.getHeigh()/2), null); |
in the end finally draw the final immage with all the sprite and background painted over 1 2
| g = (Graphics2D) gamePanel.getGraphics(); g.drawImage(doFinalEffect(dbImage), 0, 0,pWidth,pHeight, null); |
but before is possible to pass the final image (that is the immage with the background and all the sprites) again to a chain of effect (that is implemented has before as BufferedImageOp brightness to make obscuration of all the immage) ALL this story to explane that it is very easy nothing complex, and when i have activated the "OpenGL" VM flag -Dsun.java2d.opengl=True, my application is start to be very slow!!! it become a disaster, lost 30% of the frames!!!! i would like to understand why, or at list to understand how to analyze
|
|
|
|
|
20
|
Java Game APIs & Engines / Java 2D / Re: quickest most effecient way to darken/lighten image on the fly?
|
on: 2013-01-06 21:39:54
|
ok now is clear, thanks in your example you use on the top of your image a rectangle filled with a RadialGradientPaint and you change just the alpha channel of the color, now comparing the two solutions: - 1) LookUpOp (that works at the pixel level so is for any pixel the operation must be performed) - 2) rectangle filled with same Paint (like Gradient) what is the best solution? your experience say the first one, without your response my natural answer instead is the second, because I imagine that at low level the second one must use same low level directive to draw the rect. but i don't know,i never tryed the second solution. Do you know how works Graphics2D.fillRect method? regarding the verify of the Garbage collection try to pass this parameter to your java command -verbose:gc this is the official link http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.htmlif u works with eclipse in the console you will see the output of the GC
|
|
|
|
|
21
|
Java Game APIs & Engines / Java 2D / Re: quickest most effecient way to darken/lighten image on the fly?
|
on: 2013-01-06 20:06:36
|
In this video I use two techniques for changing object brightness on the fly.
whot are the two techniques that you mentioned?  In my experiences with Java2D, working with buffere images operation like LookupOp to perform process of the immage on the fly is extremely heavy! looking at the Garbage collection log, my games was using more that 10-15 time the memory with the effect!!!! for sure, depend from the use that u did of the effect, but it is without doubt a heavy operation
|
|
|
|
|
22
|
Game Development / Newbie & Debugging Questions / Re: Need help moving projectiles with math...
|
on: 2013-01-02 02:17:19
|
hey guys just being curious why cant i do this using the method i first attempted?
I think that is clear for you that we use trigonometry to do this, (and trust me, try to learn at list this 2 function sin and cos they will change your point of view) if u want to do with your code 1 2 3
| float bulletX, bulletY; float slope = (mY - sY) / (mX - sX); bulletY = slope * (bulletX - sX) + sY; |
you can do if u have the speed separate in the x component and y component: at this point conside that your speed is expressed in pixel for seconds if your speed at x components is vX the value of next x of the bullet is bulletX = bulletX + vX*T where T is the time (in second) pass since last loop so your code become calucalte the slope the first time 1 2
| float bulletX, bulletY; float slope = (mY - sY) / (mX - sX); |
and after, in any cicle do this 1 2
| bulletX = bulletX + vX*T bulletY = slope * (bulletX - sX) + sY; |
remember this is valid only if sX and sY don't change otherways save it when u calculate the slope
|
|
|
|
|
23
|
Discussions / Miscellaneous Topics / Re: What's your favorite game.
|
on: 2012-12-27 19:33:15
|
|
best games of the past: another world (it will be part of the 10 games that will enter in the gugenaim museum forever) flashback
best games of my 25-30 ages good of war 2
strategy games homeworld (very innovative interface, also if now is old)
but there are 1000 games in my mind in this moment, that is very strange make a classific of the top game, taste of games is something of personal, more than food (and i'm italian)
may be if i will answer to this question tomorrow the response could be different
|
|
|
|
|
24
|
Game Development / Newbie & Debugging Questions / Re: Dialog Box System
|
on: 2012-12-23 12:39:28
|
how can i do for "dialog jumps" i.e "First" show the first ten lines of dialogs,
first, what technologies are u using? Java2D or other? because the solution can give yoou completely different answers for Java2D for example exists already API to support text management but i f you are using UI component (Jtext etc...) is a completely different story. Ok hire i will suppose that you are using JAva2D. in this case you can find hire the official tutorial of the Oracle that show how to use the text in a Java2D graphic context they are no more of 4-5 capiton very easy to undestand http://docs.oracle.com/javase/tutorial/2d/text/index.htmlwhat you have to look is this caption http://docs.oracle.com/javase/tutorial/2d/text/drawmulstring.htmlit will solve your problem to fix in you dialog box (drawing area) the text that you want to insert after you need press enter to show more lines. :S How can i do that?
instead regarding the way to insert dialog box that evolve the internal text after return press, can be easy and there are 1000 solution, but each one of this solution will be incorrect if it is not easy adaptable to the framework that you implemented. for example if u have the text in the file you can do like this - 1-load the text that you want to print and transform in a array of chars
- 2-give this array as parameter to your dialog box
- 3-the dialog box contain an internal state that is the index where to start to use the character in the array, for example when it will start for the first time the index will be 0,
- 4-the dialog box print the x characted that are possible in concordance with its size and update the index
- 5-at each press enter continue the iteration 3 and 4 until the text is finish
but be carefull this solution has a problem for example its eat chatacters!!!! immagin that you want to write this string in your dialog "test string, i like write text in java" that is 38 chars and your dialog write only 10 characters the result after any press return is 1 return "test strin" 2 return "g, i like w" 3 return "rite text i" 4 return "n java" so take care to raffinate the algorithm to don't cut the words, for exaple you can use a StringTokenizer to reconize words bye
|
|
|
|
|
28
|
Discussions / Miscellaneous Topics / Re: Create a new font/glyph in java2D
|
on: 2012-12-12 21:36:53
|
|
thanks man was very easy
String fName = "/fonts/" + name; try { InputStream is = DemoFonts.class.getResourceAsStream(fName); font = Font.createFont(Font.TRUETYPE_FONT, is); } catch (Exception ex) { ex.printStackTrace(); System.err.println(fName + " not loaded. Using serif font."); font = new Font("serif", Font.PLAIN, 24); } return font;
|
|
|
|
|
30
|
Discussions / Miscellaneous Topics / Create a new font/glyph in java2D
|
on: 2012-12-12 21:03:53
|
How to create my specific glyph to use in ma game in java2D? hi would like to generate the string in my style just using the standard java how to create my own font? 1 2 3 4 5 6 7 8 9 10
| Graphics2D dbg .... ... ...
Font font = new Font("MyFontWithmySpeficiGlyph", Font.PLAIN, 20); dbg.setFont(font);
String myString = "string that use my glyph " dbg.drawString(myString , x, y); |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|