Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


TheChubu

Member Since 13 Sep 2012
Online Last Active Today, 07:58 PM

#5187038 Can I Make This Code Faster Without Over Complicating It ?

Posted by TheChubu on 14 October 2014 - 04:39 PM

 The way it is written works, but creates a memory leak at the same time
Then don't do a while(true) inside Connect.

 

Implement a timeout. Sleep the thread, see if there is new data, sleep a bit more, and if new data doesn't enters in X amount of time, close the connection. run() method ends and Thread is GC'd.

 

Also, don't 'new' Threads willy nilly. Use executors. Fix the amount of threads you want to make to handle connections. Threads aren't cheap to make, nor cheap to maintain (10Mb per Thread instance IIRC).




#5186769 Do you use UML or other diagrams when working without a team?

Posted by TheChubu on 13 October 2014 - 03:47 PM

When you are doing programming projects solo, do you use UML or other diagrams?

I want UML to die in a pit of suffering, poop, tears and fire. I despise it, and all that it entails. All the culture that surrounds it, all the "software engineering" processes developed around it. Fucking. Hate. It.

 

Then again, a lot of thought has been invested into UML. So it has its uses, for some people. I'd say class diagrams and entity-relationship diagrams are a nice tool IF you feel like doing them in the first place. I feel they're nice when you can have other people do the diagrams for you. You'd probably make their life miserable though.

 

For me? I don't like them. I only use them on uni courses when they're mandatory. I enjoy thinking about abstractions, how classes interact, etc. UML takes away all the fun I have while coding.




#5186587 Why do unused game assets get stored in the game?

Posted by TheChubu on 12 October 2014 - 07:13 PM


Won't RAM or CPU power be used in some way?
If they're never loaded, why would they?


#5186525 Collision Detection in a GTA-like Game

Posted by TheChubu on 12 October 2014 - 12:44 PM


. I've googled a lot but I didn't found any suitable solution
Use libGDX's box2d wrapper.


#5185882 Will OpenGL 4.3 work on a 4.0 machine?

Posted by TheChubu on 08 October 2014 - 06:41 PM


The chances are that if it supports opengl 4.0, it will support a higher version

Unless you have an Intel GPU... or you're using OSX. In both cases you'd be screwed.




#5185184 Knowing my REAL OpenGL version - RESOLVED

Posted by TheChubu on 05 October 2014 - 03:41 PM


This is a typical agnostic claim.
... the fuck?


#5185179 Is upper division Linear Algebra a good idea or necessary?

Posted by TheChubu on 05 October 2014 - 03:29 PM

You are not a career.  Study what you're most interested in.

This. You have a rare opportunity, make the most of it. You'll have time later in life to study things you're not interested on just to make it to the deadlines and/or practical targets.




#5184788 Knowing my REAL OpenGL version - RESOLVED

Posted by TheChubu on 03 October 2014 - 10:26 AM

Can't you like, use SDL or something? Instead of doing the context initialization on your own I mean...

 

BTW, that card should support up to OpenGL 4.5.




#5184425 Bad code or usefull ...

Posted by TheChubu on 01 October 2014 - 03:59 PM

 

 And that's why video games don't have bugs or crashes any more.

What are you talking about!?! I haven't played a video game since Baldurs Gate that didn't have a bug or crashed in some way! Don't even get me started on Skyrim.

Sarcasm maybe?




#5184155 GLSL debugger that lets you step through shader execution?

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

I'm down with giving up some of my "growth as a graphics developer" for a debugger that can step through GLSL 3.30+ and works in Linux.




#5183916 Database for Java?

Posted by TheChubu on 29 September 2014 - 05:43 PM

To connect to a database from Java all you need is a JDBC driver, establish a connection, and you can issue SQL queries right away.

 

Pretty much all big databases out there (MySQL, PostgreSQL, Oracle Database, etc) have a JDBC driver.

 

You can follow this tutorial on how to use JDBC http://docs.oracle.com/javase/tutorial/jdbc/




#5183551 Legal use of fonts

Posted by TheChubu on 28 September 2014 - 04:11 PM

Are all the fonts at the Google fonts page open source?

Just read:

 

https://www.google.com/fonts#AboutPlace:about

 

FYI, saying "but the GDNet dudes told me it was legal!" isn't a valid defense. So you prolly have to read and decide by yourself.




#5182944 Handling Uniform Locations?

Posted by TheChubu on 25 September 2014 - 12:03 PM


I'll look into, but from a glance (if it does require a buffer object to hold the data) idk if that is any easier, it just adds another thing to manage.
In combination with ARB_shading_language_420pack, it's quite easy.

 

Just set explicit binding locations for your UBO in all your shaders. You can fix those if you want, like, binding 0 is always for transforms, binding 1 is always for material, etc. Also you don't have to manage binding slots per program, because UBOs can have the same slots in all of them (and without having to carefully counting the  slots you assign like with regular uniform locations, which depend on the definition of the uniform).

 

If you used any sort of plain buffer like a VBO, you're already doing most of the work of handling UBOs already.

 

For example, I have a GLBuffer class which has methods to do pretty much what you usually do with buffers (allocate memory, upload data, bind/unbind, etc). My UBO class extends it and just adds UBO specific bindBufferRange method and a field to keep the UBO binding point (which is a fixed value).

 

I found more annoying to deal with per program location of regular uniforms and the various different calls to update their data than working with UBOs.




#5182291 New trends in gaming: voxels are the key to real-time raytracing in near-term...

Posted by TheChubu on 22 September 2014 - 08:15 PM


It appears a new very, very old rendering format, Raytracing, is becoming plausible for hardware in the near future.
Fix'd.


#5182169 Java - How to deal with Abstract Static functions

Posted by TheChubu on 22 September 2014 - 11:32 AM

void foo(Item i) {
 if(i.getId() == ItemA.getId()) {
       //Do Something
 }
}

First. That wouldn't even work. You're comparing if the two strings are the same, not if they're equal.

 

This would work (actually I'm lying since you have static method and regular method with the same signature, but talking about string comparison here...).

void foo(Item i) {
if(i.getId().equals(ItemA.getId())) {
    //Do Something
    }
}

Also. Say that you dislike using 'instanceof' for some reason, whats preventing you from defining two methods, one static, other not static and final, that return the "id" of the class/object?

class Item {
private static final String ID = "ID_01";
static final String classId() { return ID };
final String id() { return ID };
}
 
void foo(Item i) {
  if(i.id().equals(ItemA.classId()) {
    //Do Something
  }

}

Now, thats kinda ugly. Say that you want to get away from 'instanceof' AND don't like defining two methods per class.

enum TypeID {
ID01, ID02, ID03;
}
 
class Item {
final TypeID id() { return TypeID.ID01 };
}
 
void foo(Item i) {

  switch ( i.id() ) {
  case ID01 : // Do stuff.
                      break;
  case ID02 : // Do stuff.
                      break;
  default :  System.out.println("Something be wrong yo!");
                break;
  }
}

That's beautiful switch on enum that is nicer and faster (the JIT will decide if if/else chains or jump tables are better for each particular use case!), since comparing for string equality isn't the most efficient thing in the planet precisely.

 

EDIT: You can even put that "id()" method in an interface and make all classes that will use such IDs implement it. You could also return plain ints as ID if that's enough for your use case, then again, enums tend to be easier to handle for restricted values (and unlike ints, you can have methods in enums).






PARTNERS