Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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 ... 81
1  Discussions / Miscellaneous Topics / Re: f.lux on: 2014-04-17 00:14:50
As a graphics programmer, I would never ever use any program that messes with the colors of my screen.
2  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-13 02:59:09
In most cases theagentd's second option is enough. Try that one out. There is also another pixel-perfect lighting techneque that davedes implemented, see this post: http://www.java-gaming.org/topics/starbound-lighting-techneques/26363/msg/230988/view.html#msg230988
Step 4 in that technique is essentially a raycast.  persecutioncomplex
3  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-13 00:40:20
Well, a tip for next time: First tell us what you're trying to achieve and what the problem is, THEN tell us what you're trying to solve it with. "I'm trying to make a texture with transparent texels cast shadows" tells us more than all your previous posts combined.

The problem is quite complex, since as you're saying the shadows rely on the transparency of the texture you're using. Even worse, how much light is blocked at any point X in the shadow depends not on one texel in the shadow casting texture but on all texels in a line from the light to the point X. I see a number of solutions:

1. Fake it.

2. Approximate the opaque parts of the texture with a mesh of vertices. For complex shapes this is difficult to implement, slow as hell due to the massively inflated vertex count and shadow overdraw and has low quality. Not recommended unless you have shapes that can be very easily approximated with a mesh.

3. Raycast through the texture on rendering. This technique (and variations of it) are the only techniques that can handle arbitrary textures without any preprocessing or vertex shapes, but it can also be very GPU intensive due to the raycasting. You can do this in two different ways. The first one is to simply read a number of texels from the texture along a line going from the light to the point you're testing:



This is pretty hard to implement in a good way and can be extremely slow since the raycasting is wastefully done for each shadowed pixel. A better approach would be to construct a 1D shadow map by raycasting through the texture and simply sample the shadow map for each pixel that is potentially shadowed and multiplying its color with the value in the shadow map. This should be more than fast enough and relatively simple to implement. There are multiple techniques that you can find via Google that use this approach.
4  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-12 20:25:32
So you want only opaque pixels in the texture to cast shadows?
5  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-12 18:59:07
Judging from your picture, this might be relevant: http://archive.gamedev.net/archive/reference/programming/features/2dsoftshadow/page3.html
6  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-12 02:04:29
A picture might help?
7  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-11 04:15:49
You're not making any sense at all. I don't think anyone has understood what you're after. I can't even find a real question. What is the problem?

I should have mentioned I wanted the mesh to line-up with the texture.
Huh? Line up?

So the lighting engine is aware that there is a alpha pixel in the texture, and makes the vector array understand that.
What? What does the vector array have to do with what texture data you have in your texture? Why does your vector array need to "understand" if there's transparency in your texture?
8  Game Development / Newbie & Debugging Questions / Re: Listening to Keyboard while using OpenGL on: 2014-04-10 02:47:11
You shouldn't be using getEventCharacter() for identifying which key is being pressed or released. Use getEventKey() instead and compare it to the constants in Keyboard (Keyboard.KEY_UP for example).

Code that does the same as the code in your first post (untested):
1  
2  
3  
while(Keyboard.next()){
    buttonsPressed[Keyboard.getEventKey()] = Keyboard.getEventKeyState();
}
9  Game Development / Newbie & Debugging Questions / Re: Almost Completely Static Class Design on: 2014-04-10 00:25:45
Hmm, that's true actually. Holy shit, view of life changed.
10  Game Development / Newbie & Debugging Questions / Re: Almost Completely Static Class Design on: 2014-04-09 23:20:39
I've yet to see any reason at all for why singletons are better less horrible, or even in any way different from static fields.

1  
2  
3  
Singleton.getInstance().function()
vs
Singleton.function()


You will never need to pass it in as an argument anywhere since any class can just fetch the instance through getInstance() so there's no need for it to be an object in the first place.
11  Java Game APIs & Engines / OpenGL Development / Re: GL_MAX / LibGDX problem on: 2014-04-09 03:33:26
When blending is enabled, this is what is written to the framebuffer:

1  
framebuffer = func(sourceColor * sourceFactor, destinationColor * destinationFactor)


func = the function set by glBlendEquation(). This defaults to addition, in which case func() is a function that takes in two values and adds them together. GL_MAX = max() instead of addition.
sourceColor = the raw color you're writing (RGBA).
sourceFactor = the first argument to glBlendFunc().
destinationColor = the color already in the framebuffer.
destinationFactor = the second argument to glBlendFunc().

If you change the alpha value of the source color, the resulting RGB values are completely unaffected. To me it sounds like you want to multiply the source RGB values by the source alpha, which means you need to call glBlendFunc() with these arguments:

1  
glBlendFunc(GL_SRC_ALPHA, GL_ONE);


This results in the following blending equation:
1  
framebuffer = max(sourceColor * sourceColor.alpha, destinationColor * 1)

12  Game Development / Newbie & Debugging Questions / Re: LWJGL Orthographic projection render order based on Z on: 2014-04-07 18:49:16
You generally don't want to use depth testing with 2D due to the transparency problem. The most common solution for rendering transparent stuff with a depth buffer (regardless of 2D or 3D) is to disable depth writes and sort your objects. If you only need additive blending you don't need to sort your objects, but this is rarely the case.

What if I have two seperate lists:
1. Sprites that only have pixels with alpha 1 or alpha 0 or Sprites that are supposed to be rendered with additive blending,
2. Sprites that have pixels with other alpha values between 1 and 0.

Now, all sprites have some kind of "layer" variable, or in other words: A Z-position.
I don't need to sort list 1. I can simply render it non-sorted with additive blending, alpha test and depth testing enabled.
I sort list 2, then render it with normal blending and depth testing disabled.

Transparency should work and everything should be faster, no? Smiley
The problem with this approach is that usually you'd want blending on all your sprites to get nice and smooth edges as alpha testing leads to clearly visible aliasing. You could enable multisampling and alpha-to-coverage to improve that, but that'd make the second pass do blending into a multisampled buffer which is significantly slower.
13  Game Development / Newbie & Debugging Questions / Re: LWJGL Orthographic projection render order based on Z on: 2014-04-07 15:51:48
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
import java.util.Comparator;

public class InsertionSort {
   
   public static <T> void sort(T[] array, int start, int end, Comparator<T> comparator){
     
      for(int i = start + 1; i < end; i++){

         T current = array[i];
         
         int j = i-1;
         while(j >= start && comparator.compare(array[j], current) < 0){
            array[j+1] = array[j];
            j--;
         }
         array[j+1] = current;
      }
     
   }
   
}


Sorting 1 000 objects
Quote
Insertion sort unsorted: 0.275 ms
Insertion sort sorted:   0.003 ms
Java sort unsorted: 0.083 ms
Java sort sorted:   0.002 ms
Java parallel sort unsorted: 0.084 ms
Java parallel sort sorted:   0.002 ms
First elements: 19369, 19369, 19369

Sorting 10 000 objects
Quote
Insertion sort unsorted: 56.627 ms
Insertion sort sorted:   0.156 ms
Java sort unsorted: 1.912 ms
Java sort sorted:   0.05 ms
Java parallel sort unsorted: 0.718 ms
Java parallel sort sorted:   0.11 ms
First elements: 15, 15, 15

Sorting 100 000 objects
Quote
Insertion sort unsorted: 5576.639 ms
Insertion sort sorted:   1.349 ms
Java sort unsorted: 15.842 ms
Java sort sorted:   0.459 ms
Java parallel sort unsorted: 4.505 ms
Java parallel sort sorted:   0.742 ms
First elements: 45, 45, 45

As you can see, insertion sort scales horribly with the number of objects when they are unsorted, but linearly when they are already sorted. Although Java's Arrays.sort() method is faster in all cases, it generates a large amount of garbage which may cause problems with garbage collection pauses.
14  Game Development / Newbie & Debugging Questions / Re: LWJGL Orthographic projection render order based on Z on: 2014-04-07 14:39:43
You generally don't want to use depth testing with 2D due to the transparency problem. The most common solution for rendering transparent stuff with a depth buffer (regardless of 2D or 3D) is to disable depth writes and sort your objects. If you only need additive blending you don't need to sort your objects, but this is rarely the case.

Concerning sorting performance, I wouldn't worry that much. The order of your objects will not change much between frames, so I'd strongly recommend implementing a simple insertion sort. Insertion sort has the advantage of being O(n) if the list is already sorted and requires no temporary memory. Since we can assume that the order does not change much from frame to frame insertion sort will be extremely fast (except for the first frame when your objects are completely unsorted).
15  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 21:56:20
Disable all texturing and coloring and see if the actual geometry disappears. That way you can rule out a lot of stuff.
16  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-05 15:15:14
I was serious!  Grin
17  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-05 01:29:24
1. Buy AMD processor.
2. Realize you have to multithread your game to get good performance on AMD processors.
3. Multithread game.
4. Profit for the world!
18  Discussions / General Discussions / Re: JGO Kickstarter on: 2014-04-01 21:36:01
I guess I'll keep these 25 dollars then... ._.
19  Discussions / General Discussions / Re: JGO Kickstarter on: 2014-04-01 20:08:12
Still getting internal server error when I click a medal...
20  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-01 13:38:23
I got a 60 GB SSD when they were pretty new and expensive. I used it only as a boot drive for Windows and graphics drivers and stuff like that since I couldn't fit my games in such a small drive. Even if I could fit a game was currently playing on it, it wasn't worth the work to move files temporarily to the SSD for faster load times.

Currently I have a 128GB SSD which I bought for less than half of what my original 60 GB SSD cost, and I'm using it as a cache drive for a 4TB harddrive. This worked incredibly well, basically giving me the simplicity of a single drive with around 90% of the performance of an SSD after the first time I load something. It's also extremely easy to set up; just install Windows to your harddrive, install Intel Rapid Storage Technology, click a button to activate caching. In my opinion I get a lot more out of my SSD when I use it as a cache, but if you can fit everything you have into your SSD and don't have any large files (games, completely legally acquired anime, etc) then obviously just skip the cache and dump it all on your SSD.
21  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-03-31 20:07:46
How is nVidia vs ATI/AMD these days? nVidia used to be overheating power hungry junk comparatively afaik.
That was true for the 400 series, and to some extent the 500 series as well. The 600 series uses slightly less power than AMD's equivalent cards at the moment.
Source: http://www.tomshardware.com/reviews/geforce-gtx-780-ti-review-benchmarks,3663-17.html

EDIT: They've basically been focusing 100% on power efficiency since the Fermi disaster. The biggest change from the 500 series to the 600 series was that they tripled the number of shader cores and removed the doubled shader clock, which is so ridiculously more efficient that they should've done that long ago just like AMD's been doing for a while now, but at least they've caught back up when it comes to power consumption.
22  Discussions / Miscellaneous Topics / Re: Your pushing your luck eclipse... on: 2014-03-31 10:03:09
That's a nice .classpath file you have there. It'd be a shame if something were to happen to it...
23  Game Development / Newbie & Debugging Questions / Re: UnicodeFonts and Anti-Aliasing on: 2014-03-29 17:19:58
Texture filtering? Sorry, I don't know much about Unicode fonts. All I can tell you is why MSAA probably isn't working.  Emo
24  Java Game APIs & Engines / Engines, Libraries and Tools / Re: modify the contents of VBO on: 2014-03-29 17:15:55
Always use
glBufferSubData
to update the entire data. It just updates the data whereas
glBufferData
will delete the previous data, allocate new memory and then copy the data. With
glBufferSubData
there is some increase in performance since the same memory will be reused.
This is not entirely true. glBufferData() doesn't immediately delete the previous data since the GPU might still be using it. However, you're right that it  reallocates the memory on each call. This is called orphaning and it has some useful characteristics. Let's say you have a small VBO which you update multiple times per frame. In this case, glBufferSubData() and glMapBuffer() will have terrible performance since each time you update the buffer you basically stall the entire OpenGL pipeline since the GPU has to finish using the old data before it's overwritten. If you instead use glBufferData(), the driver is smart enough to not immediately delete the old buffer and the driver may keep multiple internal buffers for each call to glBufferData(). In this case, there is no stall since the driver isn't forced to overwrite the old data of the buffer and can just keep the old buffers in memory and deallocate them when they no longer have a use. In the case of a buffer being updated only once per frame, the overhead of glBufferData() is a bad thing and glBufferSubData() or (even better) glMapBuffer() is preferred to glBufferData() like you said.
25  Game Development / Newbie & Debugging Questions / Re: UnicodeFonts and Anti-Aliasing on: 2014-03-29 17:07:18
I assume this is LibGDX...

The anti-aliasing you're enabling is MSAA, multisample anti-aliasing. It only works on geometric edges, not on shader aliasing. I don't know how LibGDX renders those fonts, but it probably doesn't construct a mesh for each letter. Instead it renders the font to a texture and samples it, or it calculates the color of each pixel in a fragment shader. In either case, it's still just a quad for each letter, so MSAA does nothing at all.
26  Java Game APIs & Engines / OpenGL Development / Re: Debugging OpenGL code on: 2014-03-26 11:34:39
@theagentd

Yes I've added calls to
checkForErrors()
before and after each opengl call. I've added them even before creation of buffers too. The errors only start to appear when the
end()
method is called on the batcher where I update the buffers and render them.

Either you're developing on an Intel card or you have really outdated drivers for your Nvidia/AMD card.

My card is NVIDIA GeForce 210 (I know it's old, saving my pocket money for a new card) and I'm using a hackintosh so I'm limited to compatibility mode (OpenGL 2.1 but supports 95% of OpenGL 3.3 functions as well). The driver version is 310.84, is old too, but there isn't a new release for mac. Any ideas on what to do?

The only thing left then is to look at the documentation of each of your failing methods and see what those errors are caused by. I'm pretty sure debug mode doesn't work on Macs regardless of profile.
27  Java Game APIs & Engines / OpenGL Development / Re: Debugging OpenGL code on: 2014-03-26 09:54:07
It's impossible to say what the problem is with just this code.

1. Look at the official documentation pages for the functions you're calling and you'll see what the different errors mean. From http://www.opengl.org/sdk/docs/man2/xhtml/glBufferSubData.xml:
Quote
GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.

2. You should always call glGetError() BEFORE what you're trying to debug as well as after to ensure that no error was already present when the function was called. Remember that if an error occurs, glGetError() will be locked to that error code until you clear it with glGetError(). I suspect this is why you're detecting a "Invalid enum" error on glBindBuffer() since GL_ARRAY_BUFFER is a valid enum.

That didn't work out. It said that "the function is not supported" on the glDebugMessageCallbackARB line.
Either you're developing on an Intel card or you have really outdated drivers for your Nvidia/AMD card. It's a good idea to get this working as it gives much more detailed information about errors.
28  Discussions / Miscellaneous Topics / Re: Advice on dealing with internet trolls? on: 2014-03-25 19:42:56
I'd like to give some advice on handling criticism.

First of all, you need to have your expectations right. If you aren't looking for honest opinions and criticism and just want to show people what you've accomplished, then say so. There's nothing wrong with being proud with what you've accomplished no matter how small it is. If you however ARE looking for constructive criticism, then be ready to actually consider other's opinions. What some people seem to do wrong here is that they believe that any criticism is an attack that they need to defend themselves against. First they deny or downplay the importance of the problem, and if they're proved wrong they start making weird excuses like "I have no idea what I thought when I wrote that" and stuff like that. The thing is that this completely misses the original goal of asking for opinions: opinions. >_>

When I give criticism on something I generally don't blatantly point out something as a problem. For example, if something is confusing, then it is a potential problem that the person receiving criticism may not have taken into consideration. For the person receiving criticism, such a statement should be taken as something to be considered and further analyze, not a challenge to disprove that statement. If you do not reach the same conclusion as the person who complained, then the person A: is either wrong or B: haven't managed to explain the problem in such a way that you understood it. Obviously you can't just dismiss criticism on the basis of not understanding what they meant, but sometimes simply asking for clarification can make a person who just wrote "ur gaem sux" to think through what they meant and actually come up with something constructive. If they can't or refuse to clarify what they mean, you can just safely ignore them, since they won't ever help you become better at what you're doing. This is a really nice mentality to have, since it can help you a lot when trying to ignore flaming against you.


TL;DR: Try to understand what people are criticizing you about, and if something is unclear ask for clarification. If the person refuses to come up with understandable criticism, you can safely ignore them since they're not helping you get any better. Remember, the goal is to expand your own knowledge; not to defend your honor.
29  Java Game APIs & Engines / OpenGL Development / Re: Debugging OpenGL code on: 2014-03-25 18:31:42
Enable OpenGL debug mode.
1  
2  
            Display.create(new PixelFormat(), new ContextAttribs().withDebug(true));
            glDebugMessageCallbackARB(new ARBDebugOutputCallback());
30  Game Development / Shared Code / Re: 2-to-1 mappings, Fractals and thanks for all the fish on: 2014-03-24 23:30:43
What are these for?
Pages: [1] 2 3 ... 81
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (25 views)
2014-04-14 17:35:47

Porlus (42 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (223 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!