Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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
1  Java Game APIs & Engines / OpenGL Development / Re: Sprite Batching on: 2013-06-28 23:18:06
I understand how Vertex Arrays, Vertex Buffers, Shaders and Textures work. I just didn't understand how a Sprite Batcher would incorporate all of these aspects. Though browsing through the first tutorial on meshes, that seems to be what I am looking for. I'll have a read through it and see if it can help me out.
2  Java Game APIs & Engines / OpenGL Development / Sprite Batching on: 2013-06-28 13:49:40
Hello, I am attempting to create my own Sprite Batcher for my game. Though I am having trouble understanding how they work. I understand their implementation, but not how they actually work. How do they manage vertex data and actually render the sprites? I have tried looking at Matt's examples but I cannot figure anything out. Could someone shed some light on the matter?
3  Java Game APIs & Engines / OpenGL Development / Re: Object Management on: 2013-05-23 09:28:49
Well given that libgdx is also an android platform and there are plenty of games and there is years of development behind the framework, I think it's quite safe to say that the performance is quite okay if not very good and those kind of obvious bottlenecks should come out very very fast.


Yeah, I figured that, that's why I don't think I have worked out what's going on in the code properly.
4  Java Game APIs & Engines / OpenGL Development / Re: Object Management on: 2013-05-22 23:44:46
I have been going through the code and the tutorials by mattdesl. Do they do it by loading new vertex data to the buffers at every frame? That's all that I can figure from it. Wouldn't that be very slow?
5  Games Center / WIP games, tools & toy projects / Re: 3D swimming pool on: 2013-05-21 16:44:23
I like the lights on the wooden panels. They look very realistic.
6  Java Game APIs & Engines / OpenGL Development / Re: Object Management on: 2013-05-21 09:57:06
Take a look at LibGDX, specifically the SpriteBatch class.  It's not the best-organized class (it fails to separate the GLES2 renderer from the other with anything other than a bunch of if/else statements sprinkled throughout) but you still get a good idea of how to do geometry batching.  You don't have to clone it, it's just an example of how you might do one particular sort of object management.

Object management is pretty specific to the sort of game you're writing, and it's one of the things that distinguishes a good engine from a great one (just ask princec about managing VBOs).  OpenGL makes it a lot harder than DirectX (where you have things like swap chains managed for you) but on the other hand, being forced down to a low level means you at least get control at that low level.


Okay, I am going through the class but I cannot tell what is going on. The SpriteBatch has a draw method which calculates vertices and then passes them to a mesh. Then the mesh has a render method which calls glDrawElements. I can't see were the vertex arrays and buffers are bound.
7  Java Game APIs & Engines / OpenGL Development / Re: Object Management on: 2013-05-21 08:53:25
Sorry, I've just started working with OpenGL recently. I'm not much help there. But, here is a link to the source code for Slick2D's Image class. Maybe that can give you a step in the right direction.

Yeah, that seems like it is using intermediate mode. I'm going for a different approach.
8  Java Game APIs & Engines / OpenGL Development / Re: Object Management on: 2013-05-21 08:42:41
I'd create an Image class to abstract what you have, so you can just do something like Graphics.drawImage(Image), and then you can have your Object class that contains an Image, as well as all the moving logic and whatnot.

Okay, what would be the best way to access a vertex buffer from the Image class?
9  Java Game APIs & Engines / OpenGL Development / Object Management on: 2013-05-21 08:17:03
Hello, I am developing an engine for a game that I want to create. Though I have hit a wall. So far, I have created many classes that implement vertex arrays, vertex buffers, shaders and textures. Though I am unsure how to organise these classes in to a working engine. I can construct single vertex arrays and buffers to display a simple textured quad, but I could not imagine how to manage a whole game's worth of objects. Any suggestions? Here is my code so far: https://github.com/Harris6310/Novum

I was thinking along the lines of having a Sprite class that would contain it's own vertex buffer. Though I wouldn't know how to go about this.
10  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-18 11:34:44
I understand how they work, I just can't find out where this bug is coming from.
11  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-17 21:28:10
I added both of those methods to my initialisation and the texture is still rendered with a white background.
12  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-17 15:58:57
I didn't know that was needed. How is it done?
13  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-17 11:55:26
Sorry to be a bother, but I have realised that my code doesn't actually work. The textures render, but transparency isn't working. Can someone suggest what the problem is? Here is my code: https://github.com/Harris6310/Dragonshire
14  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-13 09:45:54
I have fixed the minor texture problem. Here is the result:



Thanks again for all your help.
15  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-13 09:30:37
-snip-

Please stop snipping quotes like that. Smiley

It's hard to find what you're referring to.

Snipping is only neccessary for extremely long posts, or when you want to cut out certain parts.

Oh right, do you guys not do that here? It is quite common on another forum I am a member of.
16  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-13 08:23:32
-snip-

Thanks, this is the exact sort of thing I was looking for.
17  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 21:55:20
-snip-

Huh, I really am missing the simple errors here. Thanks, now the screen displays but the vertices are not textured. Weird.
18  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 21:45:09
-snip-

Well here is my current Texture 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  
public class Texture
{
   int objectID;
   
   int width;
   int height;
   
   String resourceReference;
   
   public Texture(String resourceReference)
   {
      this.resourceReference = resourceReference;
   }
   
   public void initialise()
   {
      ByteBuffer byteBuffer = null;
     
      try
      {
         InputStream inputStream = new FileInputStream(resourceReference);
         PNGDecoder pngDecoder = new PNGDecoder(inputStream);
         
         width = pngDecoder.getWidth();
         height = pngDecoder.getHeight();
         byteBuffer = ByteBuffer.allocate(width * height * 4);
         pngDecoder.decode(byteBuffer, width * 4, Format.RGBA);
         byteBuffer.flip();
         inputStream.close();
      }
      catch(IOException exception)
      {
         exception.printStackTrace();
      }
     
      glEnable(GL_TEXTURE_2D);
     
      objectID = glGenTextures();
     
      glBindTexture(GL_TEXTURE_2D, objectID);
      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, byteBuffer);
   }
   
   public void bind()
   {
      glBindTexture(GL_TEXTURE_2D, objectID);
   }
   
   public void terminate()
   {
      glDeleteTextures(objectID);
   }
}


And here is the console output:

1  
2  
3  
4  
5  
6  
7  
8  
Exception in thread "main" java.lang.IllegalArgumentException: ByteBuffer is not direct
   at org.lwjgl.BufferChecks.checkDirect(BufferChecks.java:115)
   at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:231)
   at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2845)
   at dragonshire.graphics.Texture.initialise(Texture.java:60)
   at dragonshire.graphics.Graphics.initialise(Graphics.java:26)
   at dragonshire.Game.initialise(Game.java:21)
   at dragonshire.Game.main(Game.java:14)
19  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 20:57:51
-snip-

Wow, thanks for the advice. And it was number 5 that caused the problem. The shader program is fixed, but I now have an issue with my texture loader.
20  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 18:41:54
-snip-

I have changed it and the problem still exists.
21  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 18:33:13
-snip-

There are no errors up until glValidateProgram.
22  Java Game APIs & Engines / OpenGL Development / Re: Shader Program Fatal Error on: 2013-05-12 17:45:55
Okay, here is the vertex shader:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
#version 150 core

in vec4 in_Position;
in vec4 in_Color;
in vec2 in_TextureCoord;

out vec4 pass_Color;
out vec2 pass_TextureCoord;

void main(void)
{
   gl_Position = in_Position;
   pass_Color = in_Color;
   pass_TextureCoord = in_TextureCoord;
}


And here is the fragment shader:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
#version 150 core

uniform sampler2D texture_diffuse;

in vec4 pass_Color;
in vec2 pass_TextureCoord;

out vec4 out_Color;

void main(void)
{
   out_Color = pass_Color;
   out_Color = texture2D(texture_diffuse, pass_TextureCoord);
}
23  Java Game APIs & Engines / OpenGL Development / Shader Program Fatal Error on: 2013-05-12 17:37:20
Hello, I was wondering if someone could help fix a fatal error I receive with my shader program. It is a run-time error that is thrown by the glValidateProgram method. Here is 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  
public class ShaderProgram
{
   int objectID;
   int vertexShaderID;
   int fragmentShaderID;
   
   public void initialise()
   {
      loadShader("shaders/vertex.shader", GL_VERTEX_SHADER);
      loadShader("shaders/fragment.shader", GL_FRAGMENT_SHADER);
     
      objectID = glCreateProgram();
     
      glAttachShader(objectID, vertexShaderID);
      glAttachShader(objectID, fragmentShaderID);
      glLinkProgram(objectID);
      glBindAttribLocation(objectID, 0, "in_Position");
      glBindAttribLocation(objectID, 1, "in_Color");
      glBindAttribLocation(objectID, 2, "in_TextureCoord");
      glValidateProgram(objectID);
   }
   
   public void terminate()
   {
      glUseProgram(0);
      glDetachShader(objectID, vertexShaderID);
      glDetachShader(objectID, fragmentShaderID);
      glDeleteShader(vertexShaderID);
      glDeleteShader(fragmentShaderID);
      glDeleteProgram(objectID);
   }
   
   public void select()
   {
      glUseProgram(objectID);
   }
   
   public void deselect()
   {
      glUseProgram(0);
   }
   
   public int loadShader(String fileLocation, int type)
   {
      StringBuilder stringBuilder = new StringBuilder();
      int shaderID = 0;
     
      try
      {
         BufferedReader bufferedReader = new BufferedReader(new FileReader(fileLocation));
         String line;
         
         while((line = bufferedReader.readLine()) != null)
         {
            stringBuilder.append(line);
            stringBuilder.append("\n");
         }
         
         bufferedReader.close();
      }
      catch(IOException exception)
      {
         exception.printStackTrace();
      }
     
      shaderID = glCreateShader(type);
     
      glShaderSource(shaderID, stringBuilder);
      glCompileShader(shaderID);
     
      return shaderID;
   }
}
24  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-12 08:53:52
But is there no tutorials or open source for 3D with just LWJGL?
25  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-11 13:30:02
-snip-

Yes, I don't what to use an engine that has everything done for me as I want to learn how everything is done.

I literately have no 3D programming experience at all. Therefore I want to know where to start.
26  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-11 09:06:41
Sorry for the late reply. What I mean is, I want to learn how to create 3D applications with LWJGL. Though I don't know what that involves. I've touched upon matrices and cameras, where can I learn more about these?
27  Game Development / Newbie & Debugging Questions / Where next? on: 2013-05-10 09:01:23
Hello, I have just finished following the LWJGL tutorials on proper rendering techniques. I know the process of using VAOs, VBOs and shaders. Though I am unsure what to do next. I want to follow the path of 3D graphics, but I don't know what the next important topic is. Could anyone suggest what I should do, or any good tutorials/documentation? I would be grateful for any advice.
28  Java Game APIs & Engines / OpenGL Development / Re: [LWJGL] Rendering Trouble on: 2013-01-25 08:50:54
-snip-

This has fixed the problem, thanks for your help.

-snip-

Yeah, I am now going to learn more about the proper use of OpenGL. I just wanted to get something to work first.
29  Java Game APIs & Engines / OpenGL Development / Re: [LWJGL] Rendering Trouble on: 2013-01-24 23:14:41
-snip-

Well that was because I wanted the bottom left to be the origin. Though it doesn't seem to work both ways.
30  Java Game APIs & Engines / OpenGL Development / Re: [LWJGL] Rendering Trouble on: 2013-01-24 23:09:29
-snip-

I have tried that and still nothing is displayed.
Pages: [1] 2
 

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 (72 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (220 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!