Show Posts
|
|
Pages: [1] 2 3 ... 29
|
|
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-basicsIt renders sprites using vertex arrays and a basic sprite batcher. It uses object-oriented patterns to wrap basic OpenGL and LWJGL concepts: DisplayTextureShader ProgramUsing 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. 
|
|
|
|
|
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
| Gdx.gl.glEnable(GL10.GL_STENCIL_TEST);
Gdx.gl.glClearStencil(0);
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; initialize(new Game(), Configuration); |
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/ShaderLesson4If you're new to shaders, you should start from the beginning: https://github.com/mattdesl/lwjgl-basics/wiki/ShadersAnd 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
|
|
|
|
|
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.  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. 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.
|
|
|
|
|
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 ...
glLinkProgram(program);
String infoLog = glGetProgramInfoLog(program, glGetProgrami(program, GL_INFO_LOG_LENGTH)); if (infoLog!=null && infoLog.trim().length()!=0) System.err.println(infoLog); 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. 
|
|
|
|
|
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-UtilityAlso next time you get a runtime exception, be sure to include the stack trace.
|
|
|
|
|
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.
|
|
|
|
|
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/wikiShaders 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  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.
|
|
|
|
|
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.)
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|