Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Sep 2012
Online Last Active Today, 10:19 PM

#5178639 Reading external code

Posted by TheChubu on 06 September 2014 - 09:48 PM

The worst "performance hit" you could have is that the JVM has to load the .class file into memory the first time you reference it (wheter its a static field, or you initialize an object of that class, etc) and run any static initializer blocks you have in it.


But that operation is done only once per class and only when you do something with it, JVM won't load classes that you don't touch.


And as Diego said, its all memory accesses, as costly as any other memory access. ie, if you have two objects of different classes, and you access an int field of one object and an int field of the other object, access cost will be probably the same since they're memory accesses (or if you're lucky, the thing is in CPU cache and it will be much faster, it isn't something you can control precisely in Java).


So don't try to cram stuff into a single class because you think it will run faster.

#5178441 GOTO, why are you adverse to using it

Posted by TheChubu on 05 September 2014 - 10:05 PM

Let's not forget that goto fail; happened.

Braceless conditionals are eeeeevuuuuul!

#5177945 Mavericks

Posted by TheChubu on 03 September 2014 - 05:30 PM

Please help me!

someone please

Please Help.

Umm... Relax dude? You sound like you're getting knifed to death.

#5177627 Beginners Observation: Fundamental Lack of Source Code Examples?

Posted by TheChubu on 02 September 2014 - 03:41 AM

Specially on graphics programming. There is just so much stuff you have to learn before even starting to worry about how many draw calls are you making, how often you change state around and how the rest of the game communicates with the render system .


In most things at least, you can (should) learn basics first, then start to ask around how to make them fit in a bigger system, which is a whole issue on its own. Once you separate those two steps, you can learn new things in a more efficient manner (ie, first make them work, then make them fit).

#5177274 learning to render

Posted by TheChubu on 31 August 2014 - 02:58 PM

Unfortunately, the research I have done suggests to me that c# isn't a good language for this. OpenGL and DirectX don't tie in to c# without third party libraries like OpenTK (OpenGL) and SharpDX (DirectX) which I don't think using would benefit me in the long run.
Have you looked at the differences between OpenTK/SharpDX and OpenGL/D3D? They're bindings, they're supposed to look like the API they're binding to. The calls are the same. The rendering techniques will be the same. I don't see this as a valid concern at all.

#5175870 Vector3.Unproject return NAN [SharpDX]

Posted by TheChubu on 24 August 2014 - 03:45 PM

And your zNear is too small. Try 0.5 or 1.0 if you can.

#5174858 Apparently, no so simple Math.....

Posted by TheChubu on 19 August 2014 - 04:22 PM


I see your min/max ops and raise you blocking logic!

int damageTaken = attack - defense;
if (damageTaken > 0)
    health -= damageTaken;
    Console.WriteLine("Attack blocked!");

I wouldn't put game logic and (arguably) UI code in the same place. Just saiyan.

#5174854 Apparently, no so simple Math.....

Posted by TheChubu on 19 August 2014 - 04:16 PM


Something like this should do the trick:

int damageTaken = attack - defense;
if (damageTaken > 0)
    health -= damageTaken;

health -= max(attack - defense, 0)


Doing min/max ops is objectively prettier :P

#5172834 OpenGL 4.5 spec is out

Posted by TheChubu on 11 August 2014 - 11:31 AM

You can grab it from http://www.opengl.org/registry/


Khronos Next Generation OpenGL Initiative thread http://www.gamedev.net/topic/659754-next-generation-opengl/

#5172271 map borders in an open world game

Posted by TheChubu on 08 August 2014 - 08:11 AM

One word: Islands.


GTA has gotten away with that for generations of consoles and PCs.


GTA 2: Islands.

GTA 3: Islands (and impossible cliff to climb at the north of 3rd island).

GTA Vice City: Islands!

GTA San Andreas: Moar Islands!

GTA 4: Isla... Well, you get the point.


EDIT: Bethesda Game Studios  (creators of Fallout 3) have nice setups for Elder Scrolls in that respect.


Both Oblivion and Skyrim present challenges in the way of this since you got both land borders and sea borders in different places. They made the sea borders extend to the infinite, but for terrain borders, they actually have a heightmap of the whole continent, so thats what they show at the borders and beyond.

#5172220 Battleship in java

Posted by TheChubu on 08 August 2014 - 01:55 AM

I put everything in methods
Nono. You put everything in a method. We say, put separate things in methods. Notice the difference.

#5172131 Java and JOGL for serious Game development?

Posted by TheChubu on 07 August 2014 - 03:04 PM

Always specify the GLSL version you want to use by using:


#version 150


In your shader files. Replace 150 by whatever version you want to use (120, 330, etc)

#5172004 Best way to sort draw calls?

Posted by TheChubu on 07 August 2014 - 02:04 AM

Only the mesh needs a vertex buffer. Sub-meshes can do with an index buffer and an offset into the shared vertex buffer.
If you "collapsed" all the sub meshes into a single vertex buffer, why don't go all the way and "collapse" all sub mesh index buffers into a single one? Unless I'm missing something you'd only need to append each index buffer into a single one and it would work.


Then again, you'd need to store an offset (and size) into the index buffer then, so when setting parameters per submesh you can draw only the submesh rather than the whole buffer.

#5171558 Piece of advice when choosing a right book?

Posted by TheChubu on 04 August 2014 - 10:29 PM

I noticed, when I put more projects in the same workspace, especially while using Gradle/libgdx, everything is very messy, is it possible to separate these workspaces somehow?
Assuming Eclipse, you can switch workspaces if you want to, File -> Switch Workspaces. Note that all the IDE settings work per workspace, so it isn't a good workflow, just get used to close the projects you're not working on at the moment.


is it possible to make it do this?
[method parameters][method name]
Yup, go to Preferences, in Java, Code Style, Formatter, new or edit. You can use the search bar above Preferences window too.


Ctrl+A to select all, Ctrl+Shift+F to autoformat all selected things with your configured formatter.

#5171544 Piece of advice when choosing a right book?

Posted by TheChubu on 04 August 2014 - 08:33 PM

I am looking for a tutorial that explains everything in detail, in this book it's all about "add this huge method here, add this huge method there". I want to learn everything in details so I can do everything on my own,
Grab the sources (libGDX's and JDK's), right click on the method, see definition. There, all the detail you could ask for.


Seriously, do that. I'm not even joking.


One of the main aspects of Java that I like is this little thing here. You have all the standard Java library sources by default on the JDK, most of the important libraries for Java out there are open source so you can poke through their innards, and if you even need more details, you can always just download OpenJDK sources and look at all those obscure "sun.misc" classes and HotSpot implementation.


Whats even better, most of it is documented! Even those obscure classes have comments in them. So read that too.


After all of that is done, then you can acknowledge that you can't possibly do everything on your own. That's an important realization for every programmer.