However, if you absolutely
need to send the OpenGL commands via networking, you can do much better than a giant if/else loop. The option I would recommend would be thus:
Use an
InputStream (definitely NOT a scanner or similar parser) to read the data.
Have an interface
GLCall. Give it one method,
callGL(InputStream is).
For every OpenGL method you want to support, define an implementation of this interface that performs the operation, reading whatever parameters it needs from the InputStream. So, to have an object that performs glColor4f, the associated java class would read like:
public class GlColor4f implements GLCall
{
public void callGL(InputStream is)
{
glColor4f(is.read() / 255f, is.read() / 255f, is.read() / 255f, is.read() / 255f);
}
}
The result is that you execute the correct command in minimal time with only 5-6 bytes of data, and there's virtually no overhead for selecting the correct command. You'll get as fast performance as is possible, and it won't slow down with the more commands you add.