Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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 ... 6
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: SpriteBatch setProjectionMatrix woes... on: 2014-08-06 02:51:36
Aaaaand I solve my own problem only after I post something and make myself look like an idiot xD.  I should have extracted the matrix and transformed it BEFORE calling begin/end.  Like this:

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  
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;

import scenegraph.*;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Matrix4;


/**
 * Object representing the core of the game.  Which platform it compiles for
 * varies
 * @author William Andrew Cahill
 */

public class GameLauncher extends ApplicationAdapter
{
   // Rendering variables
  private SpriteBatch batch;         // Object that renders all the sprites
 
   // Region to draw
  TextureRegion region;
   
   
   @Override
   public void create()
   {
      // Initializes batch
     batch = new SpriteBatch();
     
      // Stores first image
     region = new TextureRegion(new Texture(Gdx.files.internal("res/entities/wiggles/wigglesIdle.png")));
   }

   
   @Override
   public void render()
   {
      // Clears the screen
     Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     
      // Begins drawing
     // Gets matrix and copy
     Matrix4 m = batch.getProjectionMatrix();
      Matrix4 c = m.cpy();
     
      // Draws
     m.translate(100, 1, 0);
      batch.begin();
     
      batch.draw(region,0,0);
     
      // Restores matrix
     batch.setProjectionMatrix(c);
     
      // Ends drawing
     batch.end();
   }
}


As you were...
2  Java Game APIs & Engines / Engines, Libraries and Tools / SpriteBatch setProjectionMatrix woes... on: 2014-08-06 02:46:03
I want to render an image at coordinates 100, 50, 0.  Consider the following 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  
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;

import scenegraph.*;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Matrix4;


/**
 * Object representing the core of the game.  Which platform it compiles for
 * varies
 * @author William Andrew Cahill
 */

public class GameLauncher extends ApplicationAdapter
{
   // Rendering variables
  private SpriteBatch batch;         // Object that renders all the sprites
 
   // Region to draw
  TextureRegion region;
   
   
   @Override
   public void create()
   {
      // Initializes batch
     batch = new SpriteBatch();
     
      // Stores first image
     region = new TextureRegion(new Texture(Gdx.files.internal("res/entities/wiggles/wigglesIdle.png")));
   }

   
   @Override
   public void render()
   {
      // Clears the screen
     Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     
      // Begins drawing
     batch.begin();
     
      // Gets matrix and copy
     Matrix4 m = batch.getProjectionMatrix();
      Matrix4 c = m.cpy();
     
      // Draws
     m.translate(100, 50, 0);
      batch.draw(region,0,0);
     
      // Restores matrix
     batch.setProjectionMatrix(c);
     
      // Ends drawing
     batch.end();
   }
}


No matter what transformations I make, it stays in the same place.  I know that there is a draw method in SpriteBatch that lets me specify where to draw it, but I am trying to set up a scene-graph, and that requires me to translate, rotate, etc using SpriteBatch's Matrix4 extracted from batch.getProjectionMatrix().  I can make it look like the image slides across the screen if I remove the line that restores the matrix to it's original form, but I can't make it shift and stay there.  Is my understanding of the projection matrix incorrect?  I always have this problem with LibGDX, but I can never remember how to solve it.  The docs don't really explain its behavior.
3  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-07-04 21:11:14
Similarly, you might also check out Light Bot: http://light-bot.com/hocflash.html

More generally, you can check out the Hour of Code tutorials that are designed to be a little more fun than old-school teaching: http://csedweek.org/learn

It seems to me that the OP simply was not prepared to teach this class. It's not too late to turn it around, OP!

I'd also be curious to hear how you got this gig. Where are you located? I'd love to do something similar, so I'd love any detail you can give us.

To answer your question, I got this job because my roommate worked there last summer, and his employer asked him if he could find other programmers willing to teach.  He was on the athletics side of teaching, but he knew that I was an avid-ish programmer.  Getting the job was pretty easy after that because of the demand for them.

I currently work at ONE of the three TIC sites.  I've learned that I need to remember what it was like picking up programming for the first time, because I keep forgetting to explain what every little piece of syntax means.  Also, when I write example code on the board, even my smarter seniors have trouble realizing that the code I gave them was just an EXAMPLE!  Far too often, they'll complain that they copied everything I wrote, and it still wouldn't run!  Uuuuuggggghhh......  I'm not trying to raise a bunch of code monkeys here!

If you find kids that are just not interested in programming, I recommend that you don't try to teach them Java.  We have a choice in deciding what language we teach, and I recommend that the less motivated students learn Microworlds.  It still warms my heart when I hear the kids say that they WANT to learn Java.

Another thing I've learned is that you don't have your student's attention unless they're looking at you or the board.  Even today, one of my campers kept telling me that he was paying attention, but the exact instant that I continued writing on the board was the instant that he looked at the floor again.  I asked him if he could explain what I just said.  Of course, he couldn't xD.  I'm still talking about my smarties, by the way.  They're geniuses, for sure, but still have their bad days.  I've learned to stay away from visual programming with swing components, because I am just not capable of teaching them something like that within the span of two weeks.

So, yeah.  Creating a main method, basic data types, object types, loops, recursion, and classes are what I am trying to restrict myself too.  This first week, they've almost completed the framework for their grid-based console adventure in which the grid is made out of ascii characters.  I just hope we have enough time next week to finish something up.  It's taking a while to teach abstraction, which is going to be necessary for their game, but they're getting it.
4  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-07-04 20:53:59
I have to figure out how to get the less motivated students to get into programming.
How about Logo? Online here.
It was specifically designed to get less involved students doing some programming without realising it.
They immediately get something to show for their work. Even if it is just a square, they did it!


We actually use Microworlds EX which uses Logo.  It's SUPPOSED to be for the juniors who are 7 - 9.  Our seniors are 11 and up, and the ones I had last session would have probably benefited from learning Microworlds instead of Java.  They were not really that interested in it.  This session is better.  They would rather learn about file processing and console-based programming than making visual games.  They want to know how programming works.  By the way, a session is two weeks for our camp.  One more week with these seniors.
5  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-06-16 23:00:05
Depends on how much you have time and how experienced your audience is. For beginners, forget too complicated systems and games. Teach them variables, if-else, loops and how to grab input and how to display outcome. Then show how to make a simple text based game. Like questions and player must answer A, B or C.

That's for programming, for teaching how to make games I guess it could be better to use programs like Game Maker. Or Flash like I did.


Teach them how to write their own programs for their multiple choice quizes as part of the course. Then challenge them to make a fair quiz to give to their other students, let them use any programming related questions they want and low-ball the total value of their quiz as part of their final assignment grade.

That way they can "give" their classmates extra credit by giving them easy questions, but forces them to think outside the box and write a very simple actually-useful application. Make the majority of the total grade (100%) for the project the actual program they wrote and +10% extra credit the quiz points they get from taking *other* people's quizes with *their* programs.

Ah, sneaky sneaky!  Make them write a quiz for me, and call it a "text based game"!  Hah, well, these kids aren't really graded on their performance.  It's just a summer camp that both advocates physical activity, and tech literacy.  There is no REAL pressure on the students or counselors.  I'm still considering making a basic API that allows game creation to be that much less painful.  I think I can do this.  I just have to figure out what to do with the less-willing students.  I've know that after a few years of programming that you don't have to be a super genius to become a programmer.  A moron can become an elegant coder if he/she is motivated.  Which I am xD  It's all about dedication, and I have to figure out how to get the less motivated students to get into programming.
6  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-06-16 22:53:14
Depends on how much you have time and how experienced your audience is. For beginners, forget too complicated systems and games. Teach them variables, if-else, loops and how to grab input and how to display outcome. Then show how to make a simple text based game. Like questions and player must answer A, B or C.

That's for programming, for teaching how to make games I guess it could be better to use programs like Game Maker. Or Flash like I did.


I just got back from my first day.  It's funny.  I came to the same conclusion today.  I had enough trouble explaining what if-else statements did.  Most of them are not ready to be learning loops and lists.  Still, I feel that know-it-all of my group is.  He already has some experience in programming in other languages, so he's not to hard to work with.  It's the ones that have little experience and motivation to learn Java that make this job tricky.  One of the less experienced ones felt the need to write down every little thing.  That shows that he has a great work ethic, but it takes a while for him to write it down.  I'm glad that he's willing to learn and is patient, though.  I think that I will write a lesson plan that explains all of the basics before I get to any of the harder stuff.  There is another Java counselor that is new like me, so this could benefit both of us.  My goal now is to create as many examples demonstrating the basics of Java as possible all while heavily documenting every line to explain what is happening.  I believe that I can at least create a basic text-based game by the end of next week.
7  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-06-15 19:45:49
Dont underestimate these children, not "I may be, I may not", because children can be quite bright people. I am no puppy games or notch making $$$ off of indie games, but I sir, am I a child; and I have made a halfway decent, but still unfinished, prototype of a game called Project NAH. It may not be the coolest thing ever but it shows that kids can do a thing or two; [showoff] however- I scored 10% higher percentile on average than the average student that goes to one of the hardest prep schools in Illinois and my mommy was so proud Cheesy [/showoff]

As far as teaching them, I seriously think if its possible you should teach them more low level stuff, if they are really serious about it they will enjoy it, they will benefit more from it, and they will have a greater sense of "omg i made something" by the end of everything.


I'm guessing that you are a fan of Minecraft.  I have heard that the majority of the kids I will be teaching are also a fan of that game.  Well, I am as well, of course xD.  So addicting!  Anyway, your post interested me because I used to be a child programmer as well.  Started when I was 11.  I began my programming career making basic games in Flash using ActionScript 2.0.  I never had to deal with low level rendering because everything in flash was a scene graph.  I would always be confounded by advanced programmer's code, even though I considered myself to be a veteran coder.  I didn't know what I was talking about, of course.  These kids likely have no experience at programming in Java, and cramming low level Java2D over the course of one summer might be a little daunting.
8  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-06-15 19:39:12
Is this going to be a school for kids who already know java, and want to make games, or just a general school where kids will make games using java? If its the latter, you should drop the idea of using generics. Besides, there is a huge difference between roles in game development. One might be artist, musician, sound designer, level designer, story writer, lead designer, programmer and probably a lot more.

So what are they learning exactly? Programming? Or game making?

Most of these kids don't know Java yet, but many specifically asked to be taught Java.  This school is an athletics/tech summer camp, and my group is learning game programming.  Other groups are doing digital arts and music making.  We are not collaborating, necessarily.

I don't think utilizing generics should be too difficult.  I'm not teaching them to MAKE generic classes, after all.  Any beginning Java programmer should be able to understand how to use an ArrayList<SomeType> which I will teach them to do before I get to any actual game programming.  The first block of code I wrote will not be something I expect them to write.  I will be writing it.  They just use it, like in the second block.

I think they should be able to set up a JFrame, and create an instance of my GamePanel, which extends JPanel and provides basic management for game objects and rendering.
9  Game Development / Newbie & Debugging Questions / Teaching Java Game Programming to Children on: 2014-06-15 18:33:49
I just got a job about a week ago that will involve me teaching children how to program games this summer.  The juniors are going to be learning MicroWorlds, which is a very basic game making software aimed at children about 7-9 years old.  The seniors I'll be teaching are about 11-12.  They will be learning Java.  I have a reasonable amount of game-making experience using Java, but I've never come across a library that allows making 2D games to be particularly easy for a newbie.  Slick2D is incredibly easy from the perspective of an adult programmer, and LibGDX is alright once you get the hang of it.  Still, I'd like these kids to be able to use something simpler.  Something that already has defined what a game object is, preferably.

I may be underestimating these kids, since I've heard that many of the seniors are quite bright.  I am planning on teaching them how to make basic 2D games using Java2D since I think it would be a hassle to install an external library on each of their machines.  Still, I WANT to define what a game object is for them, and WANT to have those game objects easily attachable to a world.  I also WANT to be able to have those game objects communicate with each other easily.  I might write something like this so that they can access all game objects of a certain type.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public <T> List<T> getAll(Class<T> c)
{
    List<T> list = new ArrayList<>();
    for(GameObject go : gameObjects)
    {
        if(c.isAssignableFrom(go.getClass()))
            list.add((T)c);
    }
    return list;
}


Using this method would be as simple as this...
1  
2  
3  
4  
5  
6  
7  
8  
9  
List<Wall> walls = world.getAll(Wall.class);
List<Collidable> collidables = world.getAll(Collidable.class);
for(Wall w : walls)
{
    for(Collidable c : collidables)
    {
        w.enforceCollision(c);
    }
}


This should make it much easier to get their ideas implemented as quickly as possible.  Since they're young, I'm not expecting them to create anything too cpu-intensive, so such an ugly design would be perfectly suitable and simple for these novices.  Nevertheless, I will expect them to write their own game object implementations.  They will have to write the code for their spaceship, or they will have to write the code for their jumping player.  The basic library I'm writing won't take long to make, and mostly just handles rendering for them as well as attaching game objects to a world.  It also simplifies game object communication.

If anyone has any experience in teaching game programming to children 11-12, or just programming in general, could you tell me if I am I overreacting in assuming that these children will have a hard time understanding Java2D?  Am I making it too easy for them by making this library?  I know another programming counselor is teaching Python to his students using PyGame, although I've never actually used it myself.  I'm assuming that it's much simpler to use for making basic games than making a game straight from Java2D.
10  Java Game APIs & Engines / OpenGL Development / Re: VBOs in LWJGL on: 2014-05-27 01:18:17
I have the successfuls!  My class now appears to function without any quirky behavior.  I had to replace

GL11.glDrawElements(GL11.GL_TRIANGLE_STRIPS, indices.capacity(), GL11.GL_UNSIGNED_INT, 0);

with

GL11.glDrawElements(GL11.GL_TRIANGLE_FAN, indices.capacity(), GL11.GL_UNSIGNED_INT, 0);

to make it draw a quad, and not just a triangle.  Probably going to have to look into how those draw methods work.  Now, to dispose of the Mesh, I just need to delete all of the buffers, and destroy the underlying texture.  Then life should be good forever!
11  Java Game APIs & Engines / OpenGL Development / Re: VBOs in LWJGL on: 2014-05-27 01:06:53
Try replacing

1  
2  
3  
4  
//    (line 124-126)
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);


with

1  
2  
3  
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);


I could be totally wrong, I don't have this totally memorized.

Woah!  That!  Almost worked!  It actually displayed something!  Three of the verticies of my texture, in fact!  Ah, well, now I have to figure out why THAT'S happening, but it works!  Man, this all reminds me of my assembly class, where type information does not exist, and the program can exit inexplicably due to limited runtime checks.  Can't believe I missed that.  I understand what I did wrong.  Thanks for your help!  I'll make another post once I get this class working...  Or if I fail and need help again Smiley
12  Java Game APIs & Engines / OpenGL Development / Re: VBOs in LWJGL on: 2014-05-27 00:22:31
I maaaaaaay have forgotten to flip the buffers.  I shall see if I can fix this...

Edit:  Ok, so now instead of giving an error message, it just crashes.  Windows forces it to close, and I am given no indication as to why this happens.  Ugh...  Here is my updated 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  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
package render;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import core.Disposable;
import core.Renderable;
import core.Texture;


/**
 * 2-Dimensional Mesh object that can be rendered.  Uses VBOs to render data.
 * @author William Andrew Cahill
 */

public class TexturedMesh2D implements Renderable, Disposable
{
   // Buffered objects
  private Texture tex;         // Texture to use
  private int vbo;            // Verticies to draw
  private int ibo;            // Index buffer to use
  private int tvbo;            // Texture vbo to use
 
   // Vertex buffers
  private FloatBuffer vertices, texCoords;      // Vertex and Texture coordinates
  private IntBuffer indices;                  // Indices
 
   
   /**
    * Constructs the mesh
    * @param vertices List of vertices to connect to
    * @param texCoords Texture coordinates for mapping
    * @param indices Order in which to connect vertices
    * @param tex Texture to map to Mesh2D
    */

   public TexturedMesh2D(FloatBuffer vertices, FloatBuffer texCoords, IntBuffer indices, Texture tex)
   {
      create(vertices, texCoords, indices, tex);
   }
   
   
   /**
    * Constructs a TexturedMesh with the mesh simply wrapping the entire texture.
    * @param tex Texture to use
    */

   public TexturedMesh2D(Texture tex)
   {
      // Creates vertices
     FloatBuffer vertices = BufferUtils.createFloatBuffer(8).put(new float[]
      {
         0, 0,
         tex.getWidth(), 0,
         tex.getWidth(), tex.getHeight(),
         0, tex.getHeight()
      });
      vertices.flip();
     
      // Creates texture coordinates
     FloatBuffer texCoords = BufferUtils.createFloatBuffer(8).put(new float[]
      {
         0, 0,
         1, 0,
         1, 1,
         0, 1
      });
      texCoords.flip();
     
      // Creates indices
     IntBuffer indices = BufferUtils.createIntBuffer(4).put(new int[]{0, 1, 2, 3});
      indices.flip();
     
      // Creates mesh
     create(vertices, texCoords, indices, tex);
   }
   
   
   /**
    * Creates the mesh
    */

   private void create(FloatBuffer vertices, FloatBuffer texCoords, IntBuffer indices, Texture tex)
   {
      // Checks arguments
     if(vertices == null || texCoords == null || indices == null || tex == null)
         throw new IllegalArgumentException("Arguments cannot be null");
     
      // Stores arguments
     this.vertices = vertices;
      this.texCoords = texCoords;
      this.indices = indices;
      this.tex = tex;
     
      // Creates coordinate vbo
     vbo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
     
      // Creates texture vbo
     tvbo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texCoords, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
      System.out.println(texCoords.capacity());
     
      // Creates ibo
     ibo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
      GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
   }
   
   
   /**
    * Sets up object pointers before using them
    */

   private void setupPointers()
   {
      // Points to vertices
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
     
      // Points to texture vertices
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
     
      // Points to indices
     GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
   }

   
   @Override
   public void render()
   {
      render(0, 0);
   }

   
   @Override
   public void render(float x, float y)
   {
      // Translates
     GL11.glTranslatef(x,  y,  0);
     
      // Sets up buffer pointers
     setupPointers();
     
      // Binds texture
     tex.bind();
     
      // Draws elements
     GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, indices.capacity(), GL11.GL_UNSIGNED_INT, 0);
     
     
      // Disables states
     GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
     
      // Translates back
     GL11.glTranslatef(-x, -y, 0);
   }
   
   
   @Override
   public boolean isDisposed()
   {
      // Later, later...
     return false;
   }

   
   @Override
   public void dispose()
   {
      // Later, later...
  }
   
   
   /**
    * Disposes of the TextureMesh2D's underlying resources
    * @param disposeChildren Flag that determines if underlying resources besides the Texture coordinates
    * should be disposed of
    */

   public void dispose(boolean disposeChildren)
   {
      // I'll get to this later...
  }
}


Buffers are now flipped.
13  Java Game APIs & Engines / OpenGL Development / VBOs in LWJGL on: 2014-05-26 22:20:44
AAAAAAH!  I spent hours looking up tutorials trying to understand vbos, ibos, and textures, and I can't even display a simple textured vbo!  I DID manage to get rendering working in immediate mode, but only because it is infinitely more simplistic.

I should probably tell you what I am trying to make.  I am making a class called TexturedMesh that will store a VBO for coordinates, another VBO for texture coordinates, and an IBO for vertex data.

Here is my class:
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  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
package render;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import core.Disposable;
import core.Renderable;
import core.Texture;


/**
 * 2-Dimensional Mesh object that can be rendered.  Uses VBOs to render data.
 * @author William Andrew Cahill
 */

public class TexturedMesh2D implements Renderable, Disposable
{
   // Buffered objects
  private Texture tex;         // Texture to use
  private int vbo;            // Verticies to draw
  private int ibo;            // Index buffer to use
  private int tvbo;            // Texture vbo to use
 
   // Vertex buffers
  private FloatBuffer vertices, texCoords;      // Vertex and Texture coordinates
  private IntBuffer indices;                  // Indices
 
   
   /**
    * Constructs the mesh
    * @param vertices List of vertices to connect to
    * @param texCoords Texture coordinates for mapping
    * @param indices Order in which to connect vertices
    * @param tex Texture to map to Mesh2D
    */

   public TexturedMesh2D(FloatBuffer vertices, FloatBuffer texCoords, IntBuffer indices, Texture tex)
   {
      create(vertices, texCoords, indices, tex);
   }
   
   
   /**
    * Constructs a TexturedMesh with the mesh simply wrapping the entire texture.
    * @param tex Texture to use
    */

   public TexturedMesh2D(Texture tex)
   {
      // Creates vertices
     FloatBuffer vertices = BufferUtils.createFloatBuffer(8).put(new float[]
      {
         0, 0,
         tex.getWidth(), 0,
         tex.getWidth(), tex.getHeight(),
         0, tex.getHeight()
      });
     
      // Creates texture coordinates
     FloatBuffer texCoords = BufferUtils.createFloatBuffer(8).put(new float[]
      {
         0, 0,
         1, 0,
         1, 1,
         0, 1
      });
     
      // Creates indices
     IntBuffer indices = BufferUtils.createIntBuffer(4).put(new int[]{0, 1, 2, 3});
     
      // Creates mesh
     create(vertices, texCoords, indices, tex);
   }
   
   
   /**
    * Creates the mesh
    */

   private void create(FloatBuffer vertices, FloatBuffer texCoords, IntBuffer indices, Texture tex)
   {
      // Checks arguments
     if(vertices == null || texCoords == null || indices == null || tex == null)
         throw new IllegalArgumentException("Arguments cannot be null");
     
      // Stores arguments
     this.vertices = vertices;
      this.texCoords = texCoords;
      this.indices = indices;
      this.tex = tex;
     
      // Creates coordinate vbo
     vbo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
     
      // Creates texture vbo
     tvbo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, texCoords, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
     
      // Creates ibo
     ibo = GL15.glGenBuffers();
      GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
      GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
   }
   
   
   /**
    * Sets up object pointers before using them
    */

   private void setupPointers()
   {
      // Points to vertices
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
     
      // Points to texture vertices
     GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tvbo);
      GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
      GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
     
      // Points to indices
     GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
   }

   
   @Override
   public void render()
   {
      render(0, 0);
   }

   
   @Override
   public void render(float x, float y)
   {
      // Translates
     GL11.glTranslatef(x,  y,  0);
     
      // Sets up buffer pointers
     setupPointers();
     
      // Binds texture
     tex.bind();
     
      // Draws elements
     GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, indices.capacity(), GL11.GL_UNSIGNED_INT, 0);
     
      // Disables states
     GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
      GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
     
      // Translates back
     GL11.glTranslatef(-x, -y, 0);
   }
   
   
   @Override
   public boolean isDisposed()
   {
      // Later, later...
     return false;
   }

   
   @Override
   public void dispose()
   {
      // Later, later...
  }
   
   
   /**
    * Disposes of the TextureMesh2D's underlying resources
    * @param disposeChildren Flag that determines if underlying resources besides the Texture coordinates
    * should be disposed of
    */

   public void dispose(boolean disposeChildren)
   {
      // I'll get to this later...
  }
}


I had to implement a lot of code before I could even think of testing it, so I'm not surprised that nothing shows up on my screen.  I don't even know where to look in order start fixing it, though.  Help?

Edit:  When testing, I use the constructor in which only the Texture is supplied.  I made a Texture class from scratch, and there haven't been any problems with it yet.  Oh, and a shout out to theagentd for helping in this post regarding binding textures: http://www.java-gaming.org/index.php?topic=25516.0  Helped me out a lot.

Edit2:  When I call GL11.glGetError(), I get an error code of 1285 which means out of memory.  Hrm...  It happens after GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, indices.capacity(), GL11.GL_UNSIGNED_INT, 0);
14  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Shadows. on: 2014-05-04 21:56:20
My question was more whether you want to give the models shadows based on light direction (which is pretty easy) or want them to cause shadows casted to something else, which is what you mean.
This is a little bit more complicated. Did you look into FBOs?

Uh, I don't understand the difference.  xD  I did not look into FBO's. although I've heard of them.  Light based shadow casting sounds fine, though.

Edit: Oh, uh, I think I already basic shading on my models.  Yes, what I want is to cast shadows onto other models in a way that is as painless as possible.  I just looked into FBO's (Frame buffer objects, correct?), and from what I can see, it is an object that renders offscreen before being rendered on screen.  How does this apply to shadows?
15  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Shadows. on: 2014-05-04 19:51:11
I'm hoping for something like this:




The shadow on the pokemon is casted on the ground, and not itself.  I'm assuming this is to increase performance, which is what I'm looking for.  I don't need anything fancy.  Just some basic shadows so the player knows when the character is rooted to the ground.  I know that Jmonkeyengine has something like this, but alas, I decided to work with LibGDX for its portability.
16  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Shadows. on: 2014-05-03 21:03:15
Shadows on the model or shadows in the whole scene?

I suppose shadows on a particular model.  I would like entities to cast shadows on an environment model, but not on themselves or other entities to keep the performance up.
17  Game Development / Newbie & Debugging Questions / [LibGDX] Shadows. on: 2014-05-03 20:50:13
So, I finally figured out how to export 3D models from Blender, and successfully load them into LibGDX.  My question is, is it possible to cast shadows with LibGDX that doesn't require me understand OpenGL extensively?  I don't want to have to use many classes outside of Environment, ModelBatch, etc for this.  Also, if this is possible, I'd like to selectively cast a shadow on certain surfaces.  Is there a painless way to do this in LibGDX?
18  Game Development / Newbie & Debugging Questions / Re: LibGDX import .obj and .g3db not showing textures on: 2014-05-02 03:41:48
I figured it out.  After exporting from blender, I have to convert the .fbx file to a .g3db file using fbx-con.  I forgot to include the command line argument -f when converting.  I SHOULD have typed...

fbx-conv -f wigglesModel.fbx

instead of...

fbx-conv wigglesModel.fbx
19  Game Development / Newbie & Debugging Questions / Re: LibGDX import .obj and .g3db not showing textures on: 2014-05-01 00:22:10
Try multiplying all your UV normalized coordinates by -1

Ah, ok, so it's something to do with how it's created in Blender.  Please excuse my ignorance, for I am new to Blender and LibGDX, but where can I find that in the UV editor?  Scratch that, what does multiplying the UV nomalized coordinates mean, exactly?  Will it flip the image in Blender?  I want what I see in Blender to be what I see when I import it into LibGDX, or at least, roughly the same.

Edit: I want to specify that the model looks fine in Blender, but is flipped in the LibGDX rendering.
20  Game Development / Newbie & Debugging Questions / Re: LibGDX import .obj and .g3db not showing textures on: 2014-04-30 20:40:10
I finally got it to work!  It may have been because my UV mapping went outside the borders of the texture I was using.  I still have one problem, though.  The texture is applied upside down!  How can I fix this?
21  Game Development / Newbie & Debugging Questions / LibGDX import .obj and .g3db not showing textures on: 2014-04-26 02:22:34
I have been spending hours trying to figure this out, but no tutorials that I've found have explained why this might be happening.  I just started 3D modeling in Blender, and I'm finally starting to understand how to created models.  I even managed to map a texture to my model in the program.  The problem is importing the model into LibGDX.  Whenever I do, the texture just doesn't load.  Here's a picture of what happens when I try to load my models:



Of course, a face texture should show up when there is a big rectangular blob.  This is what the model looks like in Blender:


Here is a copy of my blender file, and a couple of exported versions if anyone is interested in sifting through my files:

http://download1481.mediafire.com/obe8ke5zc1ag/17y9s20c8nl2onv/Models.zip

Last, but not least, here is a copy of my rendering 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  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
package display;
import java.util.ArrayList;
import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g3d.Environment;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
import com.badlogic.gdx.math.Matrix4;

import util.ResourceManager;

/**
 * Main screen used by project
 * @author William Andrew Cahill
 *
 */

public class DisplayScreen implements Screen
{
   // 3D environment variables
  private DisplayGame game;               // Reference to game
  private Environment environment;         // Environment of models
  private ModelBatch mBatch;               // Batch used for rendering models
  private PerspectiveCamera cam;            // Camera used
  private CameraInputController controller;   // Camera controller
  private AssetManager manager;            // Asset manager
 
   // Etc
  private List<Model> models;               // List of models loaded
  private List<ModelInstance>   instances;      // List of model instances loaded

   // Loading flag
  private boolean loading;
   
   /**
    * Constructs a DisplayScreen
    * @param game Game creating this Screen
    */

   public DisplayScreen(DisplayGame game)
   {
      // Keeps reference of game
     this.game = game;
     
      // Constructs fields
       mBatch = new ModelBatch();
      environment = new Environment();
      environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, .5f));
        environment.add(new DirectionalLight().set(0.4f, 0.4f, 0.4f, -1f, -0.8f, -0.2f));
       
        cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        cam.position.set(0f, 5f, 10f);
        //cam.lookAt(0,0,0);
       cam.near = 1f;
        cam.far = 300f;
        cam.update();
       
        controller = new CameraInputController(cam);
        Gdx.input.setInputProcessor(controller);
       
        // Loads main model
       manager = new AssetManager();
        manager.load("models/wigglesModel.g3db", Model.class);
        loading = true;
       
        // Constructs empty lists of models and their instances
       models = new ArrayList<Model>();
        instances = new ArrayList<ModelInstance>();
   }
   
   
   /**
    * Finishes loading
    */

   private void doneLoading()
   {
        // Loads models
       models.add(manager.get("models/wigglesModel.g3db", Model.class));
       
        // Particular instance
       ModelInstance instance;
       
        // Adds instances
       instance = new ModelInstance(models.get(0));
        instances.add(instance);
        instance = new ModelInstance(models.get(0));
        instance.transform.translate(5, 0, 0);
        instances.add(instance);
        loading = false;
   }
   
   @Override
   public void render(float delta)
   {
      // Brings in data to render whenever ready
     if(loading && manager.update())
         doneLoading();
      // Updates controller
     controller.update();
     
      // Camera clear data
     Gdx.gl.glViewport(0,  0,  Gdx.graphics.getWidth(),  Gdx.graphics.getHeight());
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
     
      // Begins rendering
     mBatch.begin(cam);
      mBatch.render(instances, environment);
      for(int i=0; i<instances.size(); i++)
         instances.get(i).transform.rotate(0, 1, 0, 1);
      mBatch.end();
   }

   
   @Override
   public void resize(int width, int height)
   {
     
   }

   
   @Override
   public void show()
   {
     
   }

   
   @Override
   public void hide()
   {
     
   }

   
   @Override
   public void pause()
   {
     
   }

   
   @Override
   public void resume()
   {
     
   }

   
   @Override
   public void dispose()
   {
      mBatch.dispose();
        instances.clear();
        manager.dispose();
   }
}


Halp?
22  Game Development / Performance Tuning / Re: Default JVM arguments for a particular jar? on: 2014-03-28 17:00:41
Any game will break when users start renaming files. Don't waste time on it.

Sure, if they rename internal files you're out of luck. But I'm talking about renaming a single runnable file, which is probably pretty common.
I've never heard of anyone doing that, and I've been surrounded by idiots for years.

Cas Smiley

I think I'm probably being unclear. I think what the OP is talking about is creating a single runnable .jar file that users can download. I can see a situation where, for example, a new version of the jar is released, and the user downloads it to the same place as the old one. The OS will probably append a (2) or something to the jar, or the jar will contain _v1.2.3 in the name. The user might think that's ugly and just want to have Game.jar somewhere, so he renames it. I'm not talking about getting into the internal files of the game, just the main shortcut that the user is actually going to use. It seems like a common enough case to worry about, especially since it's a one line fix!

Although this is all happening in theoretical land and the OP's code was just an example anyway, so I'm probably just being pedantic.

I'm mostly just writing this code for myself.  I'm not so noble as to write this code to make someone ELSE's life easier!  What kind of guy do you think I am?  xD  Yes, this is for my own purposes in the event that I want to make a particular game that runs with certain JVM arguments.  In my opinion, there should be a file in the jar that lets you specify this instead of doing this crazy indirection.  Even worse is having the user fire up a jar from the command line.  No everyday user should have to do that anymore!
23  Game Development / Performance Tuning / Re: Default JVM arguments for a particular jar? on: 2014-03-26 22:18:36
Oh!  You're talking about programming users.  This was just an example!  No need to do anything too fancy.  Just replace "jarlie.jar" with something more... suitable...
24  Game Development / Performance Tuning / Re: Default JVM arguments for a particular jar? on: 2014-03-26 20:45:16
Users are weirdos.  Why would they want to do that?  Actually, I just thought of something...  Are the commands I typed windows specific?
25  Game Development / Performance Tuning / Re: Default JVM arguments for a particular jar? on: 2014-03-26 19:25:03
This does what I want, as it turns out.

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  
package main;
import java.io.IOException;
import javax.swing.JOptionPane;


/**
 * Class that fires an external jar
 * @author William Andrew Cahill
 */

public class Main2
{
   /**
    * Main method that fires an external jar
    * @param args Derp :)
    */

   public static void main(String[] args)
   {
      try
      {
         Runtime.getRuntime().exec("java -jar -XX:+UseConcMarkSweepGC jarlie.jar");
      }
      catch (IOException e)
      {
         JOptionPane.showMessageDialog(null, "Oh noes!");
      }
   }
}


Edit:  I run a jar that runs another jar, in case this isn't obvious.  No batch files for me!
26  Game Development / Performance Tuning / Default JVM arguments for a particular jar? on: 2014-03-26 18:32:49
Quick question:  Is there a way to make my executable jar file run with certain jvm arguments by default?  I don't mean by tweaking my current vm, I mean having the arguments be there by default for a specific jar.  That way, I could maybe run the concurrent mark and sweep algorithm for my game jar, and not some other jar.  Haven't been able to find anything in a google search.  I know Minecraft lets you do this, but Minecraft first opens a launcher before firing up the jvm, and the launcher is a native executable.

Specifically, I want to pass -XX:+UseConcMarkSweepGC by default.
27  Game Development / Performance Tuning / Re: What is this OpenCL sorcery? on: 2014-02-01 02:00:22
Yikes!  You wrote more than I did!  That's some dedication.  To be honest with you, I don't know too much about the history of hardware in general.  I'm just a college student.  I DID know about the slowing down of Moore's law, though.  I've heard that modern transistor gate is... 20 atoms across unless I'm wrong.  

On an almost unrelated note, this flash submission has a transistor gate in there somewhere... among other mind blowing things...
http://htwins.net/scale2/

I couldn't resist.
28  Game Development / Performance Tuning / Re: What is this OpenCL sorcery? on: 2014-02-01 00:12:56
GPUs have uniform-architecture(Geforce 6000) for a long time now, which means that there are only a few special purpose calculation units left on these chips. And with DX10 cards these architecture was first accessible to the public.

That GPUs are better equipped than CPUs for graphic calculation, comes from the different type/concept of the architecture. Not like in the old times were you had some specialized hardware for a single purpose.

GPUs don't have thousands of cores, but a few hundreds which can handle a lot(here comes the thousands into play) of lightweight threads. Another difference is the fast memory access of a GPU. The gigabytes of VRAM are multiple factors faster to access by the GPU than the RAM is for the CPU. Combine this with multiple levels of intelligent caches and you have a beast of machine which can crunch extremely fast through gigabytes of data.


ps: there are OpenCL bindings for Java as there are ones for OpenGL. There is also a quite handy lib called Aparapi from AMD which can convert normal Java bytecode to OpenCL kernels on the fly with a fallback to a normal fork-join pool.

Ah!  I have heard of Aparapi.  I would still like to see OpenCL code to run on the JVM, though.  Then maybe the "Java is slow" myth would end?  Hah!  Just kidding...
29  Game Development / Performance Tuning / What is this OpenCL sorcery? on: 2014-01-31 23:39:54
Hah!  Okay, so I've finally got a decent handle on writing multithreaded game loops. I actually just finished a processor class similar the concurrent package's ExecutorService.  In my case, I can see a performance boost on tasks that take at least 1 millisecond to complete on a single core, but I digress.  I consider this relevant because graphics cards tend to have thousands of cores over my 'pitiful' oct core cpu.  Do they call them oct cores?  Meh...

What I'm confused about is how hardware that is created for the sole purpose of accelerating graphics can accelerate cpu instructions.  I've seen, for instance, that OpenCL can be used to process elements in an array assuming that order is arbitrary.  It's like a for loop with i as your index, but you don't really know what the value of i is.  You just know that i will go over all indices at some point, and you're free to do your processing utilizing this black box sorcery that we call OpenCL.

Now, I can't argue with results!  I think it would be interesting if Java were to include an OpenCL binding in its distributions for zealous performance freaks like myself.  However!  I always thought that the GPU was made for a more particular task (rendering), and that's why it has always been faster at rendering, and only rendering.  That's the only thing that perplexes me.

Edit:  I have seen a couple of OpenCL bindings.  Even LWJGL has it included, which I find interesting.  It's still not ideal seeing as it requires JNI, but it's still a perk.  I needed to make this relevant to Java somehow, so that's why I mentioned this xD
30  Game Development / Game Mechanics / Re: Multi threaded game loop on: 2013-11-01 17:25:38
What about Math.sqrt()?  Is that synchronized?  I get similar results with that. Undecided  I get what you're saying, of course.  I just wasn't expecting such an overhead.

Edit:  OH!  Printing!  I totally forgot about the fact that the jvm optimizes code like crazy!  I will try that with something simple like you suggested, and have it run a bazillion times assuming that the range of a long is -bazillion to bazillion.

Edit2:  We're back to favorable results!  Well, only when the task is cpu intensive, at least.  Your printing suggestion seems to have worked.
Pages: [1] 2 3 ... 6
 

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

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!