Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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 ... 29
1  Game Development / Newbie & Debugging Questions / Re: Images + Libgdx + Loading in Android + NetBeans on: 2013-05-23 15:57:43
What is the LogCat output?

IMHO the easiest way to run LibGDX projects on Android is to use the Android Bundle:
http://developer.android.com/sdk/index.html

This is a version of Eclipse which is all set up for Android and includes various useful plugins. All you need to do is use the LibGDX setup tool, import the project into Eclipse, and run your project-android activity.

If you want to continue using NetBeans or another IDE, you just need to ensure that your "internal" files are in the class-path. Generally you would put a folder like "data" in your android project, then reference the file as so: "data/img.png".
2  Game Development / Newbie & Debugging Questions / Re: [Help] 2D Shadows/Image Modes on: 2013-05-22 00:56:18
If you are using LibGDX there is Box2DLights which will make your life easier. If you are using LWJGL then you have to learn about glBlendFunc to achieve the lighting in your screenshots; or shaders. And it won't be "dynamic" in the sense that objects won't affect the light -- for that you need to use meshes or shaders.
3  Game Development / Newbie & Debugging Questions / Re: [Request] "full" lwjgl example on: 2013-05-21 14:32:46
Look through the minimal lwjgl-basics library:
https://github.com/mattdesl/lwjgl-basics

It renders sprites using vertex arrays and a basic sprite batcher. It uses object-oriented patterns to wrap basic OpenGL and LWJGL concepts:
Display
Texture
Shader Program

Using glVertex is deprecated and part of the old fixed-function pipeline. Shaders are much more powerful to use and not too difficult to learn. The hard part is putting all the OpenGL boilerplate together -- this is why most people would suggest using LibGDX or another solution.

EDIT: For example, you could learn how shaders work with a higher-level framework (lwjgl-basics, LibGDX). Then you will have a much greater understanding of the OpenGL pipeline. When it comes time that you want to create your own sprite batch (with LWJGL or LibGDX), you will know what you are doing, rather than just copy-pasting GL calls blindly. Wink
4  Game Development / Newbie & Debugging Questions / Re: AWTException createBufferStratergy on: 2013-05-21 04:37:36
Why are you using AWT Window?

Why are you using Java2D at all? Why not a more modernized framework like JavaFX, or better yet, something based on OpenGL (hint: LibGDX).
5  Game Development / Newbie & Debugging Questions / Re: libgdx, Android crash when using Stencil? on: 2013-05-20 17:11:25
What does LogCat say?

There are two likely scenarios:

1. The gl11 object is null and you are getting a null pointer exception. If useGL20 is enabled, then gl10 and gl11 will be null. So the proper code is to do this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
//enable stencil testing
Gdx.gl.glEnable(GL10.GL_STENCIL_TEST);

//set the stencil clear color -- it is zero by default
//so this line is just to be safe
Gdx.gl.glClearStencil(0);

//clear the stencil buffer
Gdx.gl.glClear(GL10.GL_STENCIL_BUFFER_BIT);



If you need something specific to GL20 or GL10 you should use
Gdx.graphics.isGL20Available()


2. You didn't enable the stencil buffer during your application initialization:

Android:
1  
2  
3  
AndroidApplicationConfiguration Configuration = new  AndroidApplicationConfiguration();
Configuration.stencil = 8;  //stencil buffer size
initialize(new Game(), Configuration);   //pass it as parameter  


Desktop:
1  
2  
3  
LwjglApplicationConfiguration Configuration = new  LwjglApplicationConfiguration();
Configuration.stencil = 8;
new LwjglApplication(new Game(), Configuration);



Regarding your problem. Scissor stack does not use the stencil buffer. What kind of masking do you need? Arbitrary shapes? You can always use images and mask via a shader; this allows for anti-aliasing (unlike stencil testing).

Here is an example of using a shader to mask arbitrary shapes, with a mask texture:
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson4

If you're new to shaders, you should start from the beginning:
https://github.com/mattdesl/lwjgl-basics/wiki/Shaders

And here is an example of computing a mask in the shader, which means it is resolution-independent:
http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=8540&p=38862&hilit=rotated+rectangle+mask#p38862
6  Game Development / Performance Tuning / Re: Anyone else here get a major kick out of refactoring and optimizing regularly? on: 2013-05-20 04:20:22
Why is SpriteBatch.draw a memory hog? All it does it places vertices in an array and moves a pointer forward.

Optimization is important to learn; but optimizing blindly is useless and a waste of your time. It would be much better to focus your energy optimizing practical and demonstrated bottlenecks. Especially bottlenecks on the GPU side of things; for example, something like this on desktop, or taking advantage of bilinear filtering and non-dependent texture reads for mobile blurs.
7  Game Development / Newbie & Debugging Questions / Re: How to manage several Explosions Drawing/Happening ? on: 2013-05-19 03:05:53
Have you thought about using particles? Smiley
https://code.google.com/p/libgdx/wiki/ParticleEditor
8  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-17 18:22:41
Also needed:
1  
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
9  Game Development / Newbie & Debugging Questions / Re: Tween functions? on: 2013-05-16 17:57:09
If you just need simple easing functions in Java, you can use my Easing utility class:
https://github.com/mattdesl/cisc226game/blob/master/SpaceGame/src/space/engine/easing/Easing.java

Here is an example of how you can wrap it for convenience:
https://github.com/mattdesl/cisc226game/blob/master/SpaceGame/src/space/engine/easing/SimpleFX.java


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
private SimpleFX fx = new SimpleFX(1f, 0f, 1000, Easing.QUAD_OUT);


   //update method...
     fx.update(delta); /** your game might use a float delta in seconds, instead of int in ms */
      if (fx.finished()){
         //do something when finished..
     }

   //render....
     //gets the tweened value between start (in this case 1.0) and end (0.0)
     float tween = fx.getValue();

      //.. do something with the value ..
10  Game Development / Game Mechanics / Re: Libgdx 2D lights on: 2013-05-16 03:08:04
Pixmaps are performed on CPU. Before rendering something to the screen, you need to upload the Pixmap RGBA data to the GPU onto a Texture. This is explained here:

https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

Maybe you could explain your situation in more detail, with screenshots of what you're trying to do. If you just want masks, see here:
http://stackoverflow.com/a/5098999

If you just want feathered circles for point lights, you could use a simple PNG sprite or shaders:
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson3

Ultimately box2dlights is really the best choice for 2D lights. It uses a disc geometry to reduce fill rate which means that multiple lights will perform better on Android. And it should be easy to make it dynamic later on in your game, via box2d.
11  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LibGDX: No Box2DLights shadows on scene2d Stage Actors on: 2013-05-15 21:52:01
Draw the sprite on top of the shadow?
12  Java Game APIs & Engines / OpenGL Development / Re: Multiple shader passes LWJGL on: 2013-05-14 21:47:41
You need to use FBOs. See my tutorials here on the subject:
https://github.com/mattdesl/lwjgl-basics/wiki/FrameBufferObjects
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson5
13  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 21:06:40
-snip-

Wow, thanks for the advice. And it was number 5 that caused the problem. The shader program is fixed, but I now have an issue with my texture loader.
Welcome to OpenGL. Grin This is why a framework like LibGDX is often a better choice; it allows you to utilize OpenGL and learn graphics programming without writing a lot of error-prone and low-level boilerplate.

Anyways, here is another tutorial that should help you with textures. If you're still running into problems, you need to post your code and any errors... otherwise we can't do much to help. Wink

https://github.com/mattdesl/lwjgl-basics/wiki/Textures
14  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-12 20:46:50
Also glGetProgram expects a program handle (from glCreateProgram). If you are trying to get the log of the shader object (from glCreateShader) you need to use glGetShaderi and glGetShaderInfoLog.

This is likely the source of your error since your stack trace is showing the glGetProgram call is coming from your createVertShader() method.
15  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 19:15:39
Ah, you are correct. Cool
16  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-12 19:13:36
What is the crash? If it is an exception, post the stack trace.

And why are you using that horribly convoluted method? Look at the code I posted earlier:

1  
2  
int len = glGetProgrami(programHandle, GL_INFO_LOG_LENGTH);
String errLog = glGetProgramInfoLog(programHandle, len);


Don't rely on the String to determine whether compilation was successful (sometimes a log will exist even if the shader is valid). Instead do something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
   ... compile shaders and attach them ...

   //link our program
  glLinkProgram(program);

   //grab our info log
  String infoLog = glGetProgramInfoLog(program, glGetProgrami(program, GL_INFO_LOG_LENGTH));
   
   //if some log exists, print it to sys err
  if (infoLog!=null && infoLog.trim().length()!=0)
      System.err.println(infoLog);
   
   //if the link failed, throw some sort of exception
  if (glGetProgrami(program, GL_LINK_STATUS) == GL_FALSE)
      throw new LWJGLException(
            "Failure in linking program. Error log:\n" + infoLog);


Like I said... Read the link I posted. Roll Eyes
17  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 19:08:09
texture2D is deprecated.
Only as of #version 330. See here.

To the OP... Here are some suggestions to clean up your shader handling.

1. Check to see if glCompileShader failed, and print the log if it is a non-zero string. Also do the same after glLinkProgram.

2. Check to see if glCreateProgram returns zero. If so, shaders are not supported.

3. You need to call glBindAttribLocation before glLinkProgram for it to have an effect.

4. You don't need new line characters when passing to glShaderSource. You can just read the String fully like this.

5. You aren't using the return values from loadShader() -- therefore you are using zero as the second parameter to glAttachShader. This is probably the cause of your error.

6. You don't need to call glValidateProgram. Right now the call is useless since you aren't checking the status of the validation.

7. In the programmable pipeline there is no "default" shader program; so it would be cleaner and more OpenGL-like to get rid of your deselect() method. You can see in my shader utility, I just have a single method to select the program: use().

8. If you plan to target GL 2.x (which you probably should for better compatibility), you should not use #version 150.

Read through my tutorial to get a better idea of how to put everything together:
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderProgram-Utility

Also next time you get a runtime exception, be sure to include the stack trace. Smiley
18  Game Development / Newbie & Debugging Questions / Re: Is this the best way to work VBOs? on: 2013-05-12 16:32:51
You should use glGenBuffers to get the VBO handle.

glBufferData uploads the float buffer data to your VBO. You don't need to call it every frame unless your data is changing every frame. In your render function, you just need to enable client states, setup vertex pointers, and draw arrays.

VBOs is core as of GL 1.5 so you really should not be using ARB unless you are targeting computers from the 90s. Tongue

Also I'm not sure why you are flipping buffers like that. You can read more about buffers here:
https://github.com/mattdesl/lwjgl-basics/wiki/Java-NIO-Buffers
19  Game Development / Game Mechanics / Re: Faster tile drawing. on: 2013-05-12 01:56:21
theagentd's technique is fast but not always practical and requires texture arrays, which are only present in about 58% of cards. And since the tiles are drawn on GPU, it is not practical to add particular game-specific features like changing a tile when a player walks on it.

A faster technique than what Slick offers is to use VBOs or vertex arrays to batch the data. Slick includes a basic vertex array mode (see here) but it isn't highly optimized. A better alternative would be to use a batcher i.e. from lwjgl-basics or to write your own.

Further; your "lighting layer" might require a significant amount of blending and fill rate.  

FPS does not drop linearly with each new feature you add. You shouldn't start worrying about FPS unless it drops under 60. Also note that small drops of high FPS should not be a huge concern, see here.


Ultimately if you are not happy with Slick's performance, you should change libraries. Slick was not really designed for critical performance or memory usage (it uses glBegin/glEnd for christ's sake!). Slick is dead tech and no longer maintained -- nowadays LibGDX is a more powerful and more optimized alternative.
20  Game Development / Newbie & Debugging Questions / Re: LWJGL - Draw section of texture on: 2013-05-11 04:40:30
FBOs are supported in 93% of cards. If the card supports shaders, it most likely supports FBOs. VAOs are supported in at least 84% of cards.

http://feedback.wildfiregames.com/report/opengl/

Quote
but for high performance OpenGL 3.x or above is needed
Not at all true...
21  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-10 23:20:31
The handle for your shader program object which you created with glCreateProgram().

Read the docs and tutorial and you will see... Smiley
22  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-10 21:21:04
What is the error? You can query the log with the following code, post-link:

1  
2  
int len = glGetProgrami(programHandle, GL_INFO_LOG_LENGTH);
String errLog = glGetProgramInfoLog(programHandle, len);


For a full tutorial on compiling your own shaders, see here:
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderProgram-Utility
23  Game Development / Newbie & Debugging Questions / Re: LWJGL - Draw section of texture on: 2013-05-10 21:07:46
All of this and more should be explained in my Textures tutorial:
https://github.com/mattdesl/lwjgl-basics/wiki/Textures

Let me know if you have more questions. Smiley
24  Games Center / Cube World Projects / Re: Voxel - a start on: 2013-05-09 18:22:32
Programmable pipeline is pretty much supported everywhere: see here. Keep in mind shaders became core in GL 2.0.

GL 3.0+ (and thus GLSL that uses in/out, etc) is not as widely supported. This is why I would recommend GL 2.0+ as your target. You can see my code and tutorials are all compatible with GL 2.0, but use the programmable pipeline and do away with (most) deprecated techniques.
https://github.com/mattdesl/lwjgl-basics/wiki

Shaders are not difficult to learn. The matrix/vector math might be tricky, but it's not necessary to understand it very deeply as long as you have a nice utility library like LWJGL or LibGDX. Lighting is a little more difficult but there is so much on the web that you should be able to pick it up relatively quickly.

If you ever hope to target Android or iOS you should definitely learn the programmable pipeline.

Further; I would suggest LibGDX regardless of wether you plan to support mobile. This will give you a lot of control over GL (as with LWJGL), but will also give you a lot of extra features (like vector math, image decoding, 3D model loading, a powerful GUI toolkit, freetype font rendering, VBO/mesh utilities, etc). It handles all the crappy Android/iOS specific stuff for you (like audio, managing context loss, compressed textures, etc).
25  Java Game APIs & Engines / Engines, Libraries and Tools / Re: 2d game with libgdx where to start? on: 2013-05-09 16:53:28
so how would you guys go about doing this? cause im probably just going to look for a working project and just start modifying it to make it work the way i want.
all this copying and pasting code has been nothing but problems  Emo
You need to understand how to program. Start by writing some Java programs that aren't related to graphics/games. Learn what Object Oriented programming is. Read some books about programming paradigms and design patterns. Take some courses, either at school or online.

Copy-pasting random code is like copy-pasting random English language sentences and hoping it forms a coherent essay.
26  Java Game APIs & Engines / Java 2D / Re: Slick Text in LWJGL on: 2013-05-09 16:48:02
This is because Slick uses a y-down rendering system while your game uses a y-up.

Do you really need unicode fonts? Why not just use a bitmap font that includes all the ASCII glyphs?

It's fairly straight-forward to write a bitmap font renderer that should be compatible with Hiero, BMFont, and Matthias' TWL font tool. See the source code here for reference:
https://github.com/mattdesl/lwjgl-basics/blob/master/src/mdesl/graphics/text/BitmapFont.java
27  Game Development / Performance Tuning / Re: Fast/Efficient method to filter a numeric Value on: 2013-05-09 16:12:11
get rid of the method calling overhead too
Seriously; this is the very definition of premature optimization. It leads to shitty code and poor programming practices. If you apply this kind of thought to all aspects of your game/software, it will be a bitch to debug later down the line, will take you several times longer to develop, and ultimately will perform no better.

"Method overhead" is extremely negligible. If you benchmark and find that the algorithm needs optimization, it will most likely not do anything to inline your methods except further obfuscate your program.

Are you using OpenGL? Why aren't you using shaders? Are you using PBOs to allow for async transfer of pixel data? etc. These are the optimizations you should be considering. (If you're using Java2D; then maybe you're using the wrong library for the job.)
28  Game Development / Performance Tuning / Re: Fast/Efficient method to filter a numeric Value on: 2013-05-09 00:18:32
Premature optimization....? persecutioncomplex
29  Discussions / General Discussions / Re: Why don't many of you use JMonkey Engine? on: 2013-05-06 02:56:56
The look of the game is dictated through art direction, 3D modeling, shader effects, etc. The reason most of the JMonkeyEngine games look the same is because they use standard shading models (like Phong instead of something more original) and sub-par placeholder artwork.
30  Game Development / Newbie & Debugging Questions / Re: Does anyone have the slightest idea how to read audio/music files as game data? on: 2013-05-06 02:53:08
You can decompress to raw PCM float data (from WAV/OGG/MP3), i.e. in the range 0.0 .. 1.0, and then potentially do something interesting with the data.

A more practical application is to use a Fast Fourier Transform to split the frequencies of the sound data, i.e. to create a visualizer that reacts to bass hits. Or you can use onset detection:
https://code.google.com/p/audio-analysis/

If you just want to play the audio files in your game, you should use a solution like TinySound:
https://github.com/finnkuusisto/TinySound

Or if you are using LibGDX, it should be fairly simple to include audio in your game.
Pages: [1] 2 3 ... 29
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (94 views)
2013-05-17 21:29:12

alaslipknot (102 views)
2013-05-16 21:24:48

gouessej (132 views)
2013-05-16 00:53:38

gouessej (127 views)
2013-05-16 00:17:58

theagentd (138 views)
2013-05-15 15:01:13

theagentd (126 views)
2013-05-15 15:00:54

StreetDoggy (168 views)
2013-05-14 15:56:26

kutucuk (189 views)
2013-05-12 17:10:36

kutucuk (192 views)
2013-05-12 15:36:09

UnluckyDevil (199 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.252 seconds with 20 queries.