Java-Gaming.org Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
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  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 07:03:04
Best I have: it seems removing the if(value != 0) allows removal of zeroing as well.
Reaches the same fixpoint in my random board test at least, so it appears valid, and is about 1.75x faster than with fill().

I'm done for the night.

Cool cool. Thanks a lot for the help! This has been fun.
2  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:57:47
Does this help?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
private static void fill(final byte[] array, final byte value)
        {
            final int len = array.length;

            if (len > 0)
                array[0] = value;

            for (int i = 1; i < len; i += i)
            {
                System.arraycopy(array, 0, array, i, ((len - i) < i) ? (len - i) : i);
            }
        }


Doesn't seem to make much difference for me... er... maybe it's a bit slower actually... probably due to the JNI calls from arraycopy...

Anyway, I found that online and thought I would give it a shot...
3  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:47:09
I figured it out too, but fill() slows it down a good bit, trying to find a better way.

What about that memory usage though? Can't go around churning >1Gb heaps for no reason.  Pointing

This is true...

So we've made little progress overall really... I mean, better memory use is good but it's basically the same speed still Tongue

Progress is progress I suppose.
4  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:38:54
I figured it out.

you can't do this:

1  
newGrid[idx] = 0;


in the loop. I put Arrays.fill and it works.

BUT: 512x512? pfft. Try 1600x900!

At that size, this doesn't seem much different than my original code...

EDIT: with a little testing, comparing your code to mine, with a grid size of 2000x2000, it seems that they perform NEARLY the same..
5  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:19:06
Mmm? Why doesn't it work? Is the interchange in set() not valid?
Let me investigate...

Eh, I can't see what's wrong...

but...

everything just fades out after a few cyces...

I'm actually really confused... I can't see why your code isn't working...
6  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:08:59
Lol I was writing my findings: 7x faster, 190x less memory usage  Pointing
I knew there was no way the buffer swap was slower...

Note I didn't ever render anything or check validity, but here's the code I wound up with if you're curious: http://pastebin.java-gaming.org/d79cd49133917

See that's why I was rendering: to check validity! Tongue

Dumb me. Anyway, *checks out ur code*

WHAT THE FREAK? How is it so fast?!?

EDIT: well, I see why it's so fast: it doesn't work! I tried rendering it... and... yeah, it doesn't work. Tongue
7  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 06:02:10
Okay, I hate to admit this, but I derped HARD.

This algorithm is a LOT faster than I originally thought.

This is going to make make look like a total idiot, but I wrote a program to test the speed without rendering... and it gets like 900 cycles a second.


Now, I was able to improve the rendered one by quite a bit by changing the x and y.

But yeah... I'm dumb. Now what I need to is 1. figure out how to speed up my rendering, and 2. figure out how to implement hashlife.
8  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 05:44:36
But that's the weird part: there's almost no work involved to keep a 2-pool.
Frequent alloc/gc for large chunks of memory (+ zeroing unless your OS keeps pre-zeroed pages, although those will run out) should be much more work.

I can only guess that some optimization analysis (like alias analysis) doesn't like the buffer swap.
Does the cpu profile change much?

Nah, the profiling results look almost identical...
9  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 05:17:20
Forgot about this:
It's not semantically equivalent until the grid is getting zeroed somewhere in the process.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public void cycle() {
    byte[] grid = useGridB ? this.gridB : this.gridA;
    byte[] newGrid = useGridB ? this.gridA : this.gridB;
    this.useGridB = !this.useGridB;
+    Arrays.fill(newGrid, (byte) 0); // to make up for not having a freshly allocated (and thus zeroed) array

    for (int j = 0; j < this.height; j++) {
        for (int i = 0; i < this.width; i++) {
            final int idx = this.encode(i, j);
            final int value = grid[idx];
            if (value != 0) // put this back in place, although it sounds like it isn't very beneficial
                this.set(newGrid, i, j, LOOKUP_TABLE[value]);
        }
    }
}


This still doesn't even come close to beating my original code! Tongue

What this tells me: it must be faster to allocate a new byte[] than to do all the work we have to do in order to switch between the two that we save.
10  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 05:04:21
If you remove the if(value != 0) from the original code, does it slow down by roughly the same amount?

To my GREAT surprise, NO.

To my even greater surprise, it doesn't seem to make THAT much of a difference...
the only difference removing it from the original code makes is that it can't get to quite the same speed as it could when most of the cells are dead.
11  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:54:46
Okay, uh...

I guess I'm kind of confused as to why using two buffers seems to slow the program down... a lot...

Any ideas on this?
12  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:48:11
I think this method just adds too much branching... but maybe a pool world help? Who knows.

Whether you do it or the compiler does it (as BurntPizza mentioned), there should only be a couple branches needed at most, so I don't think the branches will be a problem. There are other ways to swap the grids though, such as by swapping a pair of indices (untested):

1  
2  
i = (i + 1) % 2;
j = (i + 1) % 2;

As for pooling, I think you only need a pool of two grids, which is what you have now (maybe that's what you meant). In any case, other than having the conditionals in the inner loop, it seems like you have the right idea with respect to the grid-swapping.

I'm not sure what you mean by that exactly...

I tried having a pointer to each grid and swapping them at the end of cycle(). Er... what do you mean with those indicies?
13  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:37:34
Profiling is probably the way to go here (optimizing via forum posts is a bit speculative). But, it seems worth mentioning that your new cycle() function has introduced multiple conditionals in the inner loop that weren't there before, which it seems likely could offset any gains from pooling the grids. Since the results of the conditionals are the same each time though, you should just be able to grab references to the grids at the beginning of the function, at which point your inner loop can go back to the way it was previously.

Lifting the conditionals out of the loop is almost certainly done by the jit, but I agree it would make the code clearer.
See: https://en.wikipedia.org/wiki/Loop-invariant_code_motion

Double-ninjad. Gosh, ya'll are too fast for me!

I am going to try a slightly different way to do this... with less branching but still using two arrays.

EDIT: it seems that storing two arrays in the Grid class just isn't really a good way to do this...

Are we sure we can't optimize the set(byte[], int, int, boolean) method? If not, I guess this probably can't really be optimized much.
14  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:33:20
Huh. The line:

1  
if(value != 0)


needed to be commented out to fix it.

This may be a surprise, but performance is actually a fair bit worse using two buffers and a boolean switch. Likely due to all the extra branching. I may try another method...

EDIT: ninjad. Yes, you're right about the conditionals and whatnot. Changing that doesn't really improve performance.

I think this method just adds too much branching... but maybe a pool world help? Who knows.

As for profiling: not a LOT can be done... I know that the set(byte[], int, int, boolean) method takes the most CPU time... but... eh... how helpful is that?
15  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:24:37
Two things: first, I'm not sure why this isn't working, I'm probably being retarded... can ya look at it:

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  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
public static class Grid
    {
        private static final boolean[] LOOKUP_TABLE = new boolean[32];

        private static final int STATE_BIT = 4;

        static
        {
            for (byte i = 0; i < Grid.LOOKUP_TABLE.length; i++)
            {
                final boolean live = i < 16;
                final byte index = setBit(i, STATE_BIT, live);
                final int neighbors = i >= 16 ? i - 16 : i;
                Grid.LOOKUP_TABLE[index] = live && neighbors == 2 || neighbors == 3;
            }
        }

        private final int width;
        private final int height;
        private byte[] gridA;
        private byte[] gridB;
        private boolean useGridB;

        public Grid(final int width, final int height)
        {
            this.width = width;
            this.height = height;
            this.gridA = new byte[this.width * this.height];
            this.gridB = new byte[this.width * this.height];
        }

        public int getWidth()
        {
            return this.width;
        }

        public int getHeight()
        {
            return this.height;
        }

        public boolean get(final int x, final int y)
        {
            if (this.useGridB)
                return getBit(this.gridB[this.encode(x, y)], STATE_BIT);
            return getBit(this.gridA[this.encode(x, y)], STATE_BIT);
        }

        public void set(final int x, final int y, final boolean state)
        {
            if (this.useGridB)
                this.set(this.gridB, x, y, state);
            this.set(this.gridA, x, y, state);
        }

        public void cycle()
        {
            for (int j = 0; j < this.height; j++)
            {
                for (int i = 0; i < this.width; i++)
                {
                    final int idx = this.encode(i, j);
                    final int value = this.useGridB ? this.gridB[idx] : this.gridA[idx];
                    if (value != 0)
                        this.set(this.useGridB ? this.gridA : this.gridB, i, j, LOOKUP_TABLE[value]);
                }
            }
            this.useGridB = !this.useGridB;
        }

        public void clear()
        {
            Arrays.fill(this.gridA, (byte) 0);
            Arrays.fill(this.gridB, (byte) 0);
            this.useGridB = false;
        }

        private void set(final byte[] grid, final int x, final int y, final boolean state)
        {
            final int idx = this.encode(x, y);
            final boolean oldState = getBit(grid[idx], STATE_BIT);

            if (oldState == state) return;

            grid[idx] = setBit(grid[idx], STATE_BIT, state);

            for (int i = x - 1; i <= x + 1; i++)
            {
                for (int j = y - 1; j <= y + 1; j++)
                {
                    if (i == x && j == y) continue;

                    int px = i;
                    int py = j;

                    if (i < 0)
                        px += this.width;
                    if (j < 0)
                        py += this.height;
                    if (i >= this.width)
                        px -= this.width;
                    if (j >= this.height)
                        py -= this.height;

                    final int k = this.encode(px, py);
                    final byte pixel = grid[k];
                    final byte neighbors = setBit(pixel, STATE_BIT, false);
                    final boolean currentState = getBit(pixel, STATE_BIT);

                    grid[k] = setBit((byte) (neighbors + (state ? 1 : -1)), STATE_BIT, currentState);
                }
            }
        }

        private int encode(final int x, final int y)
        {
            return y * this.width + x;
        }

        private static byte setBit(final byte value, final int bit, final boolean state)
        {
            if (state)
                return (byte) (value | (1 << bit));
            else
                return (byte) (value & ~(1 << bit));
        }

        private static boolean getBit(final byte value, final int bit)
        {
            return (value & (1 << bit)) != 0;
        }
    }


Second, to answer your question, what? Tongue Uh... The first 4 bits are storing how many neighbors a cell has, the next one is the cell's state. Then I can just zip through them with the LUT...

Not sure if I properly understood your question tbh Tongue
16  Game Development / Performance Tuning / Re: Optimizing Conway's Game of Life on: 2015-07-24 04:12:21
Can't believe I missed the y-axis thing.

So, to reuse an old array, should I simply have two arrays in my grid class and a boolean telling which is in use, or should I use something more like an actual object pool?
17  Game Development / Performance Tuning / Optimizing Conway's Game of Life on: 2015-07-24 03:57:05
Hey ya'll. So I have implemented Conway's Game of Life. I have since optimized it as much as I can... but I still want faster. I am well aware of hashlife, but I don't understand it. Until I can figure hashlife out, I would like to try to improve my current implementation as much as possible.

Here's my code:

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  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
public static class Grid {
  private static final boolean[] LOOKUP_TABLE = new boolean[32];
 
  private static final int STATE_BIT = 4;
 
  static {
    for(byte i = 0; i < Grid.LOOKUP_TABLE.length; i++) {
      final boolean live = i < 16;
      final byte index = setBit(i, STATE_BIT, live);
      final int neighbors = i >= 16 ? i - 16 : i;
      Grid.LOOKUP_TABLE[index] = live && neighbors == 2 || neighbors == 3;
    }
  }
 
  private final int width;
  private final int height;
  private byte[] grid;
 
  public Grid(final int width, final int height) {
    this.width = width;
    this.height = height;
    this.grid = new byte[this.width * this.width];
  }
 
  public int getWidth() {
    return this.width;
  }
 
  public int getHeight() {
    return this.height;
  }
 
  public boolean get(final int x, final int y) {
    return getBit(this.grid[this.encode(x, y)], STATE_BIT);
  }
 
  public void set(final int x, final int y, final boolean state) {
    this.set(this.grid, x, y, state);
  }
 
  public void cycle() {
    byte[] newGrid = new byte[this.width * this.height];
    for(int i = 0; i < this.width; i++) {
      for(int j = 0; j < this.height; j++) {
        final int idx = this.encode(i, j);
        final int value = this.grid[idx];
        if(value != 0)
          this.set(newGrid, i, j, LOOKUP_TABLE[value]);
      }
    }
    this.grid = newGrid;
  }
 
  public void clear() {
    for(int x = 0; x < this.grid.length; x++) {
      this.grid[x] = 0;
    }
  }
 
  private void set(final byte[] grid, final int x, final int y, final boolean state) {
    final int idx = this.encode(x, y);
    final boolean oldState = getBit(grid[idx], STATE_BIT);
   
    if(oldState == state) return;
   
    grid[idx] = setBit(grid[idx], STATE_BIT, state);
   
    for(int i = x - 1; i <= x + 1; i++) {
      for(int j = y - 1; j <= y + 1; j++) {
        if(i == x && j == y) continue;  
       
        int px = i;
        int py = j;

        // wrapping around - I prefer wrapping to infinite world/edged world
        if(i < 0)
          px += this.width;
        if(j < 0)
          py += this.height;
        if(i >= this.width)
          px -= this.width;
        if(j >= this.height)
          py -= this.height;
       
        final int k = this.encode(px, py);
        final byte pixel = grid[k];
        final byte neighbors = setBit(pixel, STATE_BIT, false);        
        final boolean currentState = getBit(pixel, STATE_BIT);
       
        grid[k] = setBit((byte) (neighbors + (state ? 1 : -1)), STATE_BIT, currentState);
      }
    }
  }
 
  private int encode(final int x, final int y) {
    return y * this.width + x;
  }
 
  private static byte setBit(final byte value, final int bit, final boolean state) {
    if(state)
      return (byte) (value | (1 << bit));
    else
      return (byte) (value & ~(1 << bit));
  }
 
  private static boolean getBit(final byte value, final int bit) {
    return (value & (1 << bit)) != 0;
  }
}


I suppose I could manually inline functions like encode, getBit, and setBit, but I suspect the JVM does that anyway (if not the Java compiler). So, how else could I improve this? Can I make it more cache friendly perhaps?

Let me know what you think of my current implementation and how I can improve it. Thanks!
18  Game Development / Game Mechanics / Re: Voxel Collisions? on: 2015-05-08 12:07:52
My world is divided into chunks which are 16x256x16. Those are then divided into subchunks which are 16x16x16.

Really what I'm unsure of is which math (there's multiple ways to do collision as far as I have seen) should I use and how should I use it?
19  Game Development / Game Mechanics / Voxel Collisions? on: 2015-05-08 04:52:09
Hey guys! So over the past few days I have been working on my own "Minecraft clone" as some would call it. I have block rendering working and I now would like to implement collisions. In Minecraft there are bounding boxes, and for blocks that have irregular shapes (hopper, torch, lever, button, fence, etc.) the block can define one or more custom bounding boxes instead of just a single one meter squared box. I would like this same functionality in my game since it seems easiest to use to me.

My question is how? What strategy do I use to implement this? I really have NO IDEA.

EDIT: it somehow slipped my mind to mention that I am using LWJGL for this.
20  Game Development / Performance Tuning / Fastest SHA256 Hash Function Possible? on: 2015-03-08 05:11:19
Hey guys! So, I have done my profiling and found that the SHA256.digest function (shown below) is taking the most time to execute out of all other functions in my program. Not that it isn't fast enough but I need this to be AS FAST AS POSSIBLE (without OpenCL/CUDA/anything like that). Like... if I can't make this function faster than it means that this program is as fast as it can ever be... so... yeah... if there is a faster implementation than this, LET ME KNOW!!!

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  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
public final class SHA256
{
    private static final int[] K = {
            0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
            0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
            0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
            0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
            0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
            0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
            0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
            0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};

    private SHA256()
    {
    }

    public static byte[] digest(byte[] message)
    {
        byte[] hashed = new byte[32], block = new byte[64], padded = padMessage(message);

        int[] H = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};

        for (int i = 0; i < padded.length / 64; i++)
        {
            int[] words = new int[64];
            int a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7], s0, s1, maj, t1, t2, ch;

            System.arraycopy(padded, 64 * i, block, 0, 64);
            for (int j = 0; j < 16; j++)
            {
                words[j] = 0;
                for (int k = 0; k < 4; k++)
                {
                    words[j] |= ((block[j * 4 + k] & 0x000000FF) << (24 - k * 8));
                }
            }

            for (int j = 16; j < 64; j++)
            {
                s0 = Integer.rotateRight(words[j - 15], 7) ^ Integer.rotateRight(words[j - 15], 18) ^ (words[j - 15] >>> 3);
                s1 = Integer.rotateRight(words[j - 2], 17) ^ Integer.rotateRight(words[j - 2], 19) ^ (words[j - 2] >>> 10);
                words[j] = words[j - 16] + s0 + words[j - 7] + s1;
            }

            for (int j = 0; j < 64; j++)
            {
                s0 = Integer.rotateRight(a, 2) ^ Integer.rotateRight(a, 13) ^ Integer.rotateRight(a, 22);
                maj = (a & b) ^ (a & c) ^ (b & c);
                t2 = s0 + maj;
                s1 = Integer.rotateRight(e, 6) ^ Integer.rotateRight(e, 11) ^ Integer.rotateRight(e, 25);
                ch = (e & f) ^ (~e & g);
                t1 = h + s1 + ch + SHA256.K[j] + words[j];

                h = g;
                g = f;
                f = e;
                e = d + t1;
                d = c;
                c = b;
                b = a;
                a = t1 + t2;
            }

            H[0] += a;
            H[1] += b;
            H[2] += c;
            H[3] += d;
            H[4] += e;
            H[5] += f;
            H[6] += g;
            H[7] += h;
        }

        for (int i = 0; i < 8; i++)
            System.arraycopy(intToBytes(H[i]), 0, hashed, 4 * i, 4);

        return hashed;
    }

    private static byte[] intToBytes(int i)
    {
        byte[] b = new byte[4];
        for (int c = 0; c < 4; c++)
            b[c] = (byte) ((i >>> (56 - 8 * c)) & 0xff);
        return b;
    }

    private static byte[] padMessage(byte[] data)
    {
        int origLength = data.length;
        int tailLength = origLength % 64;
        int padLength;
        if ((64 - tailLength >= 9))
            padLength = 64 - tailLength;
        else
            padLength = 128 - tailLength;
        byte[] thePad = new byte[padLength];
        thePad[0] = (byte) 0x80;
        long lengthInBits = origLength * 8;
        for (int i = 0; i < 8; i++)
        {
            thePad[thePad.length - 1 - i] = (byte) ((lengthInBits >>> (8 * i)) & 0xFF);
        }

        byte[] output = new byte[origLength + padLength];

        System.arraycopy(data, 0, output, 0, origLength);
        System.arraycopy(thePad, 0, output, origLength, thePad.length);
        return output;
    }
}
21  Game Development / Newbie & Debugging Questions / Re: Learning to create a 3D game in Java! on: 2014-07-21 04:17:45
So, I should work on one (or more) small 3D games to build my skill set...
Okay. Tongue
22  Game Development / Newbie & Debugging Questions / Learning to create a 3D game in Java! on: 2014-07-20 21:58:15
Hey guys! So, I am a Java programmer. I would say I am fairly .. well.. excluding Java EE, I would say I'm a professional. I do not really know a whole lot about 3D and things like that... but I REALLY want to create a 3D game. I understand the challenge, and intend to spend years on it. Not 24/7 development, but years of development.

My question is: where can I find ALL the information I will need? I mean, I want a fairly nice looking game... and I don't want glitchtastic physics...
I have seen some tutorials on 3D games... but none of them have really gotten me to a point where I can start working on my game and get somewhere...

Looking for pointers, tips, tricks, tutorials, resources, anything. Anything that will help. I intend to use LWJGL by the way.
23  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 12:58:32
I removed all those... the issue is now with my texture coords or the sprite sheet...
24  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 06:03:19
Okay, I got it working... but my textures are 16x16 and i have it in a 512x512 sheet, so i use 0.03125 for my tex coords, but that doesnt correctly line up... its VERY close.. but its a tiny bit off, and i cant seem to make it any better... ideas?      

http://i.imgur.com/Ddw21Xe.png

See how they dont line up? Hmm..
25  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 05:25:06
Okay, how do I do the coordinates? Still haven't figured that out...
26  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 05:20:07
I removed the translates but I still get the error... check the cube method?
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  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
private void cube(int x, int y, int z)
   {
      Block b = Block.blockList[blocks[(x / 2) - this.x][(y / 2) - this.y][(z / 2) - this.z]];
      if(b == null)
         return;

      GL11.glBegin(GL11.GL_QUADS);
      {
         Texture t = b.getTexture(Side.TOP);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, 1+y, 1+z);

         t = b.getTexture(Side.BOTTOM);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, -1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, -1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);

         t = b.getTexture(Side.NORTH);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, 1+z);

         t = b.getTexture(Side.SOUTH);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);

         t = b.getTexture(Side.EAST);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(-1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(-1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(-1+x, -1+y, -1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(-1+x, -1+y, 1+z);

         t = b.getTexture(Side.WEST);
         if(t != null)
            t.bind();
         else
            GL11.glColor3f(1, 1, 1);
         GL11.glTexCoord2f(0, 0);
         GL11.glVertex3f(1+x, 1+y, -1+z);
         GL11.glTexCoord2f(1, 0);
         GL11.glVertex3f(1+x, 1+y, 1+z);
         GL11.glTexCoord2f(1, 1);
         GL11.glVertex3f(1+x, -1+y, 1+z);
         GL11.glTexCoord2f(0, 1);
         GL11.glVertex3f(1+x, -1+y, -1+z);
      }
      GL11.glEnd();
   }
27  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 05:16:01
hmm.. that will be a lot of changing but that will work. Tongue didnt think of that... thx, ill try.
28  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 05:11:53
I still don't understand how to do that..
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
GL11.glNewList(listID, GL11.GL_COMPILE);
      for(int xx = x; xx < x + 16; xx++)
      {
         for(int yy = y; yy < y + 256; yy++)
         {
            for(int zz = z; zz < z + 16; zz++)
            {
               cube(xx * 2, yy * 2, zz * 2);
            }
         }
      }
      GL11.glEndList();

in the cube method, i do translations and drawing... so.. I don't see how that could be done outside of the list..
29  Java Game APIs & Engines / OpenGL Development / Re: LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 05:05:04
But.. how could that work... how can the blocks be at the right position in the list...
30  Java Game APIs & Engines / OpenGL Development / LWJGL glCallLists OpenGL error 1282? on: 2013-11-14 04:09:36
Hey guys! So, basically when I call glCallLists and pass my IntBuffer of lists to render, it gives OpenGL error 1282... and I can't figure out why. I am fairly certain that this is a texture issue... I am using slick 2d's texture loader. If I remove the Util.checkGLError(), I can get it to render, but the textures aren't correct.. which is the main reason I think it's a texture issue... any ideas? I know that I am not calling any glBegin()/glEnd() pairs during the glCallLists... so.. don't know what else it could be.   
Pages: [1] 2 3
 
Coldstream24 (15 views)
2015-09-03 00:41:28

Andrew_3ds (24 views)
2015-09-01 19:08:10

afikri (16 views)
2015-08-31 09:30:22

afikri (24 views)
2015-08-31 09:30:07

afikri (13 views)
2015-08-31 09:27:24

afikri (16 views)
2015-08-31 09:26:40

Roquen (24 views)
2015-08-29 11:30:54

GamerC4 (35 views)
2015-08-22 20:38:50

GamerC4 (33 views)
2015-08-22 20:37:18

GamerC4 (40 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37: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!