Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Object Management  (Read 1450 times)
0 Members and 1 Guest are viewing this topic.
Offline Harris6310

Senior Newbie





« Posted 2013-05-21 06: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.
Offline Troncoso

JGO Coder


Medals: 20



« Reply #1 - Posted 2013-05-21 06:38:38 »

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.
Offline Harris6310

Senior Newbie





« Reply #2 - Posted 2013-05-21 06: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?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Troncoso

JGO Coder


Medals: 20



« Reply #3 - Posted 2013-05-21 06:47:11 »

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.
Offline Harris6310

Senior Newbie





« Reply #4 - Posted 2013-05-21 06: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.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #5 - Posted 2013-05-21 07:06:03 »

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.
Offline Harris6310

Senior Newbie





« Reply #6 - Posted 2013-05-21 07: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.
Offline Harris6310

Senior Newbie





« Reply #7 - Posted 2013-05-22 21: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?
Offline xsvenson
« Reply #8 - Posted 2013-05-22 22:25:05 »

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.

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline Harris6310

Senior Newbie





« Reply #9 - Posted 2013-05-23 07: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.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

xFryIx (59 views)
2014-11-13 12:34:49

digdugdiggy (38 views)
2014-11-12 21:11:50

digdugdiggy (31 views)
2014-11-12 21:10:15

digdugdiggy (27 views)
2014-11-12 21:09:33

kovacsa (49 views)
2014-11-07 19:57:14

TehJavaDev (52 views)
2014-11-03 22:04:50

BurntPizza (52 views)
2014-11-03 18:54:52

moogie (67 views)
2014-11-03 06:22:04

CopyableCougar4 (66 views)
2014-11-01 23:36:41

DarkCart (152 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!