Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3
1  Java Game APIs & Engines / Tools Discussion / Re: Sun's big netbeans strategy and why it will fail on: 2006-06-08 14:36:43
Not to judge those online, but I have yet to meet a Netbeans user in real life who I'd trust a project to.  Grin  I've also yet to come accross a local business which uses Netbeans over Eclipse, Powerbuilder, or IntelliJ. 

The way Sun promotes Netbeans seems like they're desperate for users.  It's better now, but a little while ago you had to be on your toes when downloading the JDK or you'd accidentally end up getting Netbeans along with it.  I'd like to shoot whoever decided to bury the link to vanilla JDK downloads in favor of the JDK/IDE bundle.  I think I remember reading an article where Sun said Netbeans had more users than Eclipse simply because more people were downloading it (curiously, this was after the "dreaded bundle").  Every now and then I'm guilty of accidentally downloading Netbeans when It's bundled with something else.  Apparantly this makes me a Netbeans developer?!    Huh

It is arrogant of Sun to maintain that their vision for the language is superior to any other.  Developers will always create their own niche standards depending on what is required of them.  The best thing Sun can do with Netbeans is provide a strong core product to support the base vision of the language.  If people want to fragment the technology via SWT and other means, then let them, but on their own terms.  Rogue technologies always have to return to "home base" to maintain a good foundation.  It is in Sun's best interest to focus on that foundation rather than attempt to control the evolution of everything around it. 

I like to think of Sun as the nucleus of an atom.  See, they've got all these electrons (rogue flying technologies) under their control.  Like any nucleus, they try to hold onto these electrons.  However, there's a problem: more electrons are added every day.  Sun keeps trying to grab control of these electrons as they spin around, but eventually there become too many electrons for their core's charge to hold onto.  Sun becomes unstable as technolgies begin flying off in every which direction and they can't reach far enough away to hold onto them any longer.  To fix this, an atom needs is to increase its core's charge- Sun needs to bolster their core.  If they did this, they wouldn't need to attract users from Eclipse because, being an electron, Eclipse would naturally be attracted to them.
2  Game Development / Shared Code / Re: Ultratron on: 2006-05-22 21:18:42
PM me with your email dragon and I'll send the zips out to you.  That is, assuming Cas has no problem with it!  Grin
3  Discussions / General Discussions / Re: Puppygames competition total flop! on: 2006-05-03 15:04:43
I'll have to agree with the others about the theme.  That and bad timing for me(end of semester).

4  Discussions / General Discussions / Re: "Project Darkstar" teaser site.... on: 2006-03-22 20:14:33
Unlocked!  Enjoy!
http://www.projectdarkstar.com
-Chris

FYI: Link to "Andrew Leker’s Stomping Grounds" (http://download.java.net/games/SG83.zip) is broken.

Otherwise: Hooray!  Can't wait to look into this further.   Grin
5  Discussions / General Discussions / Re: Yet some more GDC Goodness! on: 2006-03-20 18:43:25
Java is suposed to compete with other languages in any market and not just the medium market?
This stuff is good but i think we need a Java Quake 4 to show people that Java games can sell anywhere.

The problem is that there are too many people making engines and too little people making games.  Everyone is reinventing the wheel.  Unfortunatly, the people capable of developing such a AAA are too segregated- busy with their own endeavors.  This isn't a Java specific problem, rather, a problem which exists with the development community as a whole.  We'd see a lot more games in the indie scene if people stopped trying to make engines.  Java games in particular would flourish under this mentality, simply because of quicker development cycles. 

I should be one to talk though... I am guilty of this offense.  Anyway, gotta go!  I've got to get back to work on my engine...    Wink
6  Java Game APIs & Engines / OpenGL Development / Re: AWTGLCanvas demo? on: 2006-03-20 02:23:57
Download the lwjgl source and look under the folder "\src\java\org\lwjgl\test\opengl\awt".  It has example code.

7  Java Game APIs & Engines / OpenGL Development / Re: Transition from PBuffers to FBOs breaks shaders on: 2006-02-28 21:43:21
Well, I solved the issue, but you'll never guess what it was...

I was disabling GL_TEXTURE_2D in a line of code I overlooked.    Shocked
All I had to do was get rid of that line... everything functions normally.  Silly how I can be dealing with shaders and FBOs and all these other things... but the small stuff still catches me off guard.

Yep.  I'm a genious.   Undecided Roll Eyes

Side note: I still use glVertex3f and glTexCoord2f- doesn't seem to mess things up.
Sorry to waste your time Spasi, I appreciate your help.  Good work on the FBO context too, this will really speed things up from PBuffers.
8  Java Game APIs & Engines / OpenGL Development / Re: Transition from PBuffers to FBOs breaks shaders on: 2006-02-28 04:12:09
Using updated drivers now - same effect :/
9  Java Game APIs & Engines / OpenGL Development / Re: Transition from PBuffers to FBOs breaks shaders on: 2006-02-28 02:51:12
Sure thing.

Shader Enable
1  
2  
3  
4  
5  
6  
7  
ARBShaderObjects.glUseProgramObjectARB(programID);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, Engine.fbo.getTextureID()); // Quick and dirty- fbo is static in the engine.
GL11.glEnable(GL11.GL_TEXTURE_2D);
ARBShaderObjects.glUniform1iARB(texture1, 0); //texture1 = getUniformLocation(programID, "tex");
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glDisable(GL11.GL_TEXTURE_2D);


Fragment Shader
1  
2  
3  
4  
5  
6  
7  
8  
9  
uniform sampler2D tex;

void main()
{
vec2 verts = gl_TexCoord[0].xy;
vec4 color = texture2D(tex, verts);
color += color;
gl_FragColor = color;
}


Vertex Shader
1  
2  
3  
4  
5  
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}


Drawing
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
fbo.enable();
   float width = 512.0f;
        float height = 512.0f;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, RANDOMTEXTUREID);  // Texture ID of some picture      
   GL11.glBegin(GL11.GL_QUADS);
      GL11.glVertex3f(-width/2, -height/2, 0.0f);     GL11.glTexCoord2f(0.0f, 0.0f);
      GL11.glVertex3f(width/2, -height/2, 0.0f);   GL11.glTexCoord2f(1.0f, 0.0f);
      GL11.glVertex3f(width/2, height/2, 0.0f);   GL11.glTexCoord2f(1.0f, 1.0f);
      GL11.glVertex3f(-width/2, height/2, 0.0f);   GL11.glTexCoord2f(0.0f, 1.0f);      
   GL11.glEnd();
fbo.disable();

// Note: Enabling the fbo texture here does nothing
shader.enable();
// Note: Enabling here does nothing either
    GL11.glBegin(GL11.GL_QUADS);
      GL11.glVertex3f(-width/2, -height/2, 0.0f);     GL11.glTexCoord2f(0.0f, 0.0f);
      GL11.glVertex3f(width/2, -height/2, 0.0f);   GL11.glTexCoord2f(1.0f, 0.0f);
      GL11.glVertex3f(width/2, height/2, 0.0f);   GL11.glTexCoord2f(1.0f, 1.0f);
      GL11.glVertex3f(-width/2, height/2, 0.0f);   GL11.glTexCoord2f(0.0f, 1.0f);      
   GL11.glEnd();
shader.disable();


I think that's everything.  I simplified parts that would (i should hope not!) have no effect on things(translates, rotates).  Thanks for your help on this by the way. 
10  Java Game APIs & Engines / OpenGL Development / Re: Transition from PBuffers to FBOs breaks shaders on: 2006-02-27 22:34:06
GL_LINEAR->GL_NEAREST has no effect.  Updating drivers seems to cause more problems than good- the entire display slows down on a whole (Even in windows!  Wierd!)

I'll just post my code to see if there's anything wrong:

FBO Initialize
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
EXTFramebufferObject.glGenFramebuffersEXT(fbID);
EXTFramebufferObject.glGenRenderbuffersEXT(rbID);
EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbID.get(0));
EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_DEPTH_COMPONENT, width, height);

GL11.glGenTextures(intBuffer);
textureID = intBuffer.get(0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST );
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST );


Enable FBO
1  
2  
3  
EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbID.get(0));
EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0 );
EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, rbID.get(0) );
   

Pseudocode of what I Do
1  
2  
3  
4  
5  
6  
7  
enableFBO();
// Draw Some Random Scene
disableFBO();

enableShader(); // Set the shader's sampler2D to the FBO's texture.
// Draw Quad
disableShader();


Like I said, if I skipt he shader part and instead bind the FBO's texture via glBindTexture() the quad is drawn fine with the random scene's result.  Ugh.
11  Java Game APIs & Engines / OpenGL Development / Re: Transition from PBuffers to FBOs breaks shaders on: 2006-02-27 14:24:07
Thanks for the suggestion.  That's odd how GL_NEAREST can mess things up.  I'll have to test things when I get home.  Also, I've noticed that the OpenGL specification sets up the texture like this:

1  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_RGB, GL_INT, NULL);


The difference from LWJGL is the NULL final parameter.  LWJGL of course, doesn't like this, so I do the following:

1  
2  
ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 4);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);


Could this perhaps be the issue?

12  Java Game APIs & Engines / OpenGL Development / Transition from PBuffers to FBOs breaks shaders [solved] on: 2006-02-27 07:58:26
Just as the title implies, I've transitioned from PBuffers to FBOs in my engine.

I can draw to a FBO and render to a texture just fine.  Drawing the texture is no problem either.  I get problems however, when I try to send the FBO's texture ID to a shader via uniform variable.  The shader is receiving the texture ID as a sampler2D.  The result is blank pixels. 

If I mess with the texture format of the FBO, I am able to get the shader to spit out pixels *somewhat* representative of what it should.  For example, if I draw a blank green screen to the FBO, a piece of the shader's ouput will be green.  I can change the color and the end result will follow suit.  This tells me that the texture format the shader expects is different than what's created by the FBO.  Unfortunatly, this is the point where things are over my head.

Anybody care to share their FBO implementation who's resulting texture can be correctly fed into a sampler2D?

FYI: Radeon 9800, Driver Date 3rd of October 2005, WinXPsp2
13  Discussions / General Discussions / Re: Games in Introductory Computer Science on: 2006-01-23 18:48:49
For my second CS course in college, the final project was to edit a very basic 2D engine into a game.  The professor alternated each semester, assigning Space Invaders one, and Centipede another.  Everything was pre-written except the game's logic.  It was up to the student to glue all the pieces together. 

The game was managed by a 2 dimentional array.  Objects were placed in the array according to their location.  The array was very small (15x15), so locations were limited, and thus the game was very simple.  The pre-written code received the array and drew graphics to the screen.  The array actually held Image objects (java.awt.Image).  An element was null if there was nothing to be drawn.

Not many students finished the final project.  I think there were 2 or 3 out of 50 who completed it.  (Hell yeah I completed it- with an A!)  The project definatly turned me on to game programming.  Right after I finished the project I ripped apart the pre-written engine files and decompiled them.  I used them as a starting point for my own engine.  I eventually  found my way here and the rest is history.

The final project wasn't just plunked down on students.  Every assignment throughout the semester had some graphical component.  The class's first assignment had students move a "Dog" to its "Bone".  The assignment's premise was to teach students about objects and how to talk to them.  Adding a small graphical component to simple assignments really seems to help make things click with beginning students.  It doesn't have to be much.  Sometimes students just need to "see" that their code is doing something.  Even a simple "Hello World" assignment can be made more interesting if the program displays "Hi!" as a graphic rather than a text dump.  What's even better is if you expose the advanced code so students can play around with things.  Perhaps give extra credit to those who figure out how to do special things.  Idealy, assignments should have basic requirements for an A grade, but also have additional criteria students can look into if they are interested.  This gives curious people something to wet their appetite. 
14  Java Game APIs & Engines / OpenGL Development / Re: Hiding the mouse cursor on: 2005-08-11 16:17:24
You can create your own Cursor object and set that as the native cursor.  Meaning, you can change the pointer's graphic to be whatever you want. 

However, I've never actually used it myself.  I got the information from:

http://www.lwjgl.org/javadoc/org/lwjgl/input/Cursor.html
http://www.lwjgl.org/javadoc/org/lwjgl/input/Mouse.html
15  Java Game APIs & Engines / OpenGL Development / Re: PbufferTest on: 2005-08-09 16:38:02
Although it uses PBuffers, you might find this useful anarchotron:  http://www.funkapotamus.org/crssource.zip  (Uses LWJGL .97)

This is a demo I made using PBuffers that does exactly what you want.  The demo effect is more like a "watergun", however, heat shimmers and bloom effects is right along the same line.
16  Java Game APIs & Engines / JOGL Development / Re: Can't reduce cpu usage to able to play music? on: 2005-07-26 19:44:43
I found a bottleneck.
When I want to play a music file, i have to open it, and the java can't open it without enoug process time.
Should I cache every music file to the memory? (about 30 music file). If a music file's size is 5Megabyte, i alloc 150Megabyte?

Do you really need to load 150 megs of music at once?  Are you really running things that fast for so long?  How about loading things in between levels and such?  Preloading is the way to go, but you shouldn't have to preload that much at the start.  Space it out at logical points throughout gameplay.
17  Java Game APIs & Engines / JOGL Development / Re: Nice setup on: 2005-07-26 01:16:59
There are two ways to make 1 unit = 1 pixel:

1)  Use Ortho mode.
2)  Do this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
 
public static void initGL()
{
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   ...
   // More enabling/disabling junk  
   ...  
   GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());            
   GL11.glMatrixMode(GL11.GL_PROJECTION);
   GL11.glLoadIdentity();
   GL11.glFrustum(
   -Display.getDisplayMode().getWidth() / 64.0,
   Display.getDisplayMode().getWidth() / 64.0,
   -Display.getDisplayMode().getHeight() / 64.0,
   Display.getDisplayMode().getHeight() / 64.0,
   8,
   65536);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);        
}


What this does is make 1 OpenGL unit = 1 pixel at a depth of -256.0f.  It also sets the center of the screen as (0, 0).
So, if you're resolution is 800x600, to draw a quad the size of the screen you'd do:

1  
2  
3  
4  
5  
6  
GL11.glBegin(GL11.GL_QUADS);
   GL11.glVertex3f(-400, 300, 0.0f);
   GL11.glVertex3f( 400, 300, 0.0f);
   GL11.glVertex3f( 400, -300, 0.0f);
   GL11.glVertex3f(-400, -300, 0.0f);
GL11.glEnd();


Anyway, this will get you what you want.  The math in glFrustrum was taken from a post by princec.  He said it was up for grabs, so I'm just recycling it. 
18  Java Game APIs & Engines / JOGL Development / Re: High Resolution Timer in Windows on: 2005-07-26 01:04:04
Does anyone know of a way to do this in code, rather than as a command-line parameter?

If you're using Java 1.5 you don't have to worry about this.  In 1.5 you can use System.nanoTimer(), which will use the highest precision timer available.

There is a way to use "System.nanoTime()" in 1.4- as the code used to make this method is "hidden" in an existing package.  Something along the lines of "sun.perf"- I'm not entirely sure, but searching around the Java2D forum for "high res timer" will be sure to get you the answer.
19  Games Center / 16K LWJGL Competition - 2005 / Re: Volunteer to be a judge here on: 2005-06-27 13:35:41
I don't think I'll have time to enter either.  I would be able to judge though- I can test on the following:

"The Ferrari with a lawnmower engine" @ Work (8-4pm USCentral)
Intel 3.8
2g ram
Radeon X300 128

"The lawnmower with a Ferrari engine"@ Home
Athlon 1800XP
512 ram
Radeon 9800Pro 256

20  Game Development / Game Play & Game Design / Re: Game Profiling on: 2005-06-14 18:08:09
I use Eclipse with this plugin: http://eclipsecolorer.sourceforge.net/index_profiler.html

It works great.
21  Java Game APIs & Engines / OpenGL Development / Re: Example Space Invaders game jerky on: 2005-03-16 14:20:48
Does the freuqency LWJGL is initialized at reflect the frequency of your monitor and the fps of the game?

If i mess up those values, I can sometimes see some desync in the form of a scanline moving down the screen.  If the background's black, I can't see the scanline unless it goes over something, which might cause the problems you describe.
22  Java Game APIs & Engines / Java 2D / Re: different speeds on: 2005-02-24 16:14:03
Quote
funk: the gamelogic loop only moves the player once per frame... >_>


Well damn.  Guess I was tired yesterday Sad
23  Java Game APIs & Engines / Java 2D / Re: different speeds on: 2005-02-23 20:08:57
The repeat rates for keys on the keyboard are different for each key/keyboard.  It depends on what circuit the key you're pressing lies on or what programs you're running in the background.

In this case, it seems like the repeat rate for the key is faster than your framerate.  Write a small limiter that prevents more than one keypress of the same key per frame.
24  Java Game APIs & Engines / OpenGL Development / Re: Simple example for using DevIL on: 2004-12-18 03:48:13
Excellent!  I had no idea it would be so easy!  

I've never even heard of DevIL until the newest LWJGL release.  This will surely make my clunky custom texture loader obsolete.

Great job Captain Jester- and great job LWJGL team!
25  Java Game APIs & Engines / OpenGL Development / Re: How does LWJGL compare to native C in performa on: 2004-12-17 13:41:44
Quote
tom,

what I'm simply asking is do we a demo that has 2 implementations: one in DirectX (as an example) and the other with LWJGL? This way we could benchmark both implementations and see what's the real performance difference.

As princec mentionned multiple times, LWJGL is supposed to be very performing but how does it compare for a game with a C implentation (with DirectX for example)?


I think that we've come to the conclution that LWJGL is comparable to a similar program written in c++ and using OpenGL.  Given that, the demo you're asking for is basically a comparison between DirectX and OpenGL.  At this point in time, both APIs are pretty much the same in terms of speed.  It all comes down to your personal preference and intended platform.  (For example, DirectX is Windows only for all practical purposes.)

Thanks guys for catching my mistakes in my suggestions.  I should have clarified the examples a bit more to something along the lines of what tom wrote.
26  Java Game APIs & Engines / OpenGL Development / Re: OpenGL GUI on: 2004-12-17 02:06:13
Why not switch to ortho mode for the GUI?

As far as a global alpha channel goes...

pushState()
switchtoOrthoMode()
setAlpha()
setColor()  
drawGUITextures()
popState()

The "setColor()" method could be used to give the GUI a specific color saturation.  For example, in your image editor, make all your HUD graphics white.  Then, with setColor() you can dynamically change the color of the whole GUI using glColor3f(float, float, float).  Just an example I suppose.  In my mind, it'd be easier than messing with the Z axis.
27  Java Game APIs & Engines / OpenGL Development / Re: How does LWJGL compare to native C in performa on: 2004-12-17 01:44:44
Before I jumped into LWJGL, I ran a few tests with NeHe Tutorials in both c++ and LWJGL.  I used Fraps as an external method of recording the fps.  I found that Java/LWJGL performed within +/- 10% of c++.  However, the tutorials noticably took longer to load in Java.  I think this is because LWJGL requires files to be loaded into a higher order data type (buffers) rather than a primitive array.  While notable, the difference in load times was not significant enough for me to think much of it.  Though, this could be because the tutorials didn't load much data.  I expect the loadtime gap to grow as the amount of loaded media does.

It's important to note that I optimized the Java tutorials to minimize work on the garbage collector.  Without this, Java simulations lost to c++ by a significant amount (-40%!!).  I wouldn't worry too much about this- the tutorials were written with c++'s memory management in mind, not Java's.  

Here's some optimization techniques:

1)  Don't use thread sensitive objects.  I.E. use ArrayList rather than Vector unless you have to worry about the synchronization of the add/remove methods.  If your game logic is sound, this won't be an issue.  Especially considering the fact that most games arn't multithreaded anyway.  

2)  Lessen your number of "on instance" objects.  For example:
Don't do this:
1  
2  
3  
4  
5  
6  
7  
8  
class Swapper{
   public static void swap(Object a, Object b){
      Object temp;   // Hi, I'm an "on instance" variable!
      temp = a;
      a = b;
      b = temp;
   }
}


Do this instead:
1  
2  
3  
4  
5  
6  
7  
8  
class Swapper{
   private static Object temp;
   public static void swap(Object a, Object b){
      temp = a;
      a = b;
      b = a;
   }
}


This might not seem like much, but consider the scenario of calling the swap() method 100s of times a frame.  That's 100 new Objects and 100 dead Objects.  If you remove the "on instance" variable, you remove a potentially huge workload for the garbage collector.  BTW... I made up the name "on instance" variable - is there a formal name for this technique?

3)  Avoid casting.  Don't use an ArrayList/Vector to hold your game's entities unless you're storing a small number.  The computation time it takes to cast an object out of an ArrayList is a huge performance hit.  Instead, create a custom collection class that emulates the effects of an ArrayList.
28  Java Game APIs & Engines / OpenGL Development / Re: FSOUND_Sample_Load on: 2004-12-07 02:07:26
Last time I tried to use the Fmod with LWJGL, the FSOUNDSample_Load(bytebuffer) wasn't working properly.    On top of that, because you're using webstart, you can't just give Fmod a the file's path as a string because FMOD (c++) doesn't know how to get things out of jars.  This is where I got the idea to pack my sounds into a module.  

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  
            else if(ref.endsWith(".it"))
            {
                  ByteBuffer buffer = null;

                  try
                  {
                        BufferedInputStream in = new BufferedInputStream(StreamSound.class.getClassLoader().getResourceAsStream(ref));
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                 
                        int bufferLength = 4096;
                        byte[] readBuffer = new byte[bufferLength];
                        int read = -1;
                 
                        while ((read = in.read(readBuffer, 0, bufferLength)) != -1)
                              out.write(readBuffer, 0, read);
                                         
                        in.close();
                 
                        buffer = ByteBuffer.allocateDirect(out.size());
                        buffer.order(ByteOrder.nativeOrder());
                        buffer.put(out.toByteArray());
                        buffer.flip();
            }
                  catch(Exception ioe)
                  {
                        ioe.printStackTrace();
                  }
                 
                  FMusicModule module = FMusic.FMUSIC_LoadSongEx(buffer, 0, buffer.remaining(), FSound.FSOUND_LOADMEMORY, null);


Since FModules/FSoundStreams can be loaded via bytebuffer, this works for loading them.  As for sounds, I keep all my wavs in an .it file and grab them using the code I gave you in the first post.  Right now you'll have to use this workaround until the native code is updated.
29  Java Game APIs & Engines / OpenGL Development / Re: FSOUND_Sample_Load on: 2004-12-04 01:57:39
Yes and no.  

The sample is completely loaded and played from memory at the time of playback.  Loading a sample does not prime the sound for this.  Instead, it merely tells FMOD what file and playback properties to use.  This is fine though as samples are meant to be small.  Thus, you shouldn't take a huge performance hit when doing this.

If you're a speed fanatic, or if you're trying to load a big sample and don't want to stream it, there are tricks you can use.

1)  The FMOD community has a few open source projects revolving around this.  The projects involve loading samples into ram for faster playback.  You can take a look around the web.  Unfortunatly, I don't have any more information than this... I read too much and remember so little on where it came from.

2)  Although it's more of a hack than a fix, you could put a sample into a module (filetype .it, .mod, .s3m) using a freeware tracker of some sort.  (Impulse Tracker, FastTracker, Modplug Tracker)  FMOD loads modules into a memory buffer, including it's samples.  It is faster to load a sample from a module than it is to load a sample off of your disk.  You can do it like this:

1  
2  
3  
4  
5  
6  
// Modue containing the sample desired.
FMusicModule module = A VALID MODULE
// Index is the instrument number that the sample is assigned in the module.
int index = 0;
// Get the sample from the module.
FSoundSample sample = FMusic.FMUSIC_GetSample(module, index);


Messing around with a tracker might be a bit more work than what you're looking for.  However, if for some reason you want to go out of your way and make FMOD faster than it already is, you're probably crazy enough to do just about anything.
30  Java Game APIs & Engines / OpenGL Development / Re: Vertex buffers and particle engines. on: 2004-10-27 21:49:23
Do vertex buffers even work in ortho mode?  I've tried all I could and I can't quite seem to get things going.  I ported a working test into ortho mode and things broke.  

InitGL:
1  
2  
3  
4  
5  
      GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();

            GL11.glOrtho(0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), 0, -1000, 1000);
     


Called Each Frame:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
                  GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                  GL11.glLoadIdentity();

GL11.glLoadIdentity();

              // Transformations
            GL11.glTranslatef(200.0f, 200.0f, 0.0f);
            //GL11.glRotatef(rot, 1.0f, 0.75f, 0.30f);

              // Send float buffers to LWJGL.
            GL11.glVertexPointer(3, 0, bufferVertex);
            GL11.glColorPointer(3, 0, bufferColor);

              // Draw elements :)
            GL11.glDrawElements(GL11.GL_QUADS, bufferIndice);

              // Inscrease rotation angle.
            rot += 0.4f;


Buffer Setup:
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  
      public final float cube_vertices[] =
            {
                              -2.0f,      2.0f, 0.0f,                                    // Front Face Top Left.
                               2.0f,      2.0f, 0.0f,                                    // Front Face Top Right.
                               2.0f, -2.0f, 0.0f,                                    // Front Face Bottom Right.
                              -2.0f, -2.0f, 0.0f,                                    // Front Face Bottom Left.

                              -2.0f,      2.0f, 0.0f,                              // Back Face Top Left.
                               2.0f,      2.0f, 0.0f,                              // Back Face Top Right.
                               2.0f, -2.0f, 0.0f,                              // Back Face Bottom Right.
                              -2.0f, -2.0f, 0.0f,                              // Back Face Bottom Left.
            };

              // Color array.
            public final float cube_colors[] =
            {
                               1.0f,      0.0f,   0.0f,
                               0.0f,      1.0f,   0.0f,
                               0.0f,      0.0f,      1.0f,
                               1.0f,      1.0f,      0.0f,

                               1.0f,      0.0f,      1.0f,
                               0.0f,      1.0f,      1.0f,
                               0.0f,      0.0f,      0.0f,
                               1.0f,      1.0f,      1.0f,
            };

              // Cube indexes to tell OpenGL how to draw vertices.
            public final int cube_indexes[] =
            {
                               0, 3, 2, 1,                                          // Front Face
                               5, 6, 7, 4,                                          // Back Face
                               4, 0, 1, 5,                                          // Top Face
                               3, 7, 6, 2,                                          // Bottom Face
                               4, 0, 3, 7,                                          // Left Face
                               1, 2, 6, 5,                                          // Right Face
      };

      public FloatBuffer bufferVertex = BufferUtils.createFloatBuffer(24);
      public FloatBuffer bufferColor      = BufferUtils.createFloa      public FloatBuffer bufferVertex = BufferUtils.createFloatBuffer(24);
      public FloatBuffer bufferColor      = BufferUtils.createFloatBuffer(24);
      public IntBuffer bufferIndice      = BufferUtils.createIntBuffer(24);tBuffer(24);
      public IntBuffer bufferIndice      = BufferUtils.createIntBuffer(24);


A little side question.  Is there a way to take an ortho X/Y coordinate and translate it into a projection coordinate?  My game is 2D but my particle engine exists in projection mode so I can make some niftier effects.  I want to position particle systems relative to objects drawn on the screen in ortho mode but I don't know the way to make them line up correctly.
Pages: [1] 2 3
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (33 views)
2014-10-27 03:28:38

TehJavaDev (27 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (59 views)
2014-10-16 15:22:06

Norakomi (48 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!