Results 1 to 9 of 9
  1. #1
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default Giving a text file containing GLSL to client

    I'm working with an Applet which is in the making of becoming a 3D game. Basically what I'm doing is writing in OpenGL SL (Open Graphics Library Shader Language) which is contained in a text file then read by Java as a ByteBuffer.

    Basically here's my questions:
    How can I download the text file to the client?
    What path would the filename be? (i.e., when calling GLShaders.class.getClassLoader().getResourceAsStre am(...), what would the ... be?)

    Thank you in advance!

    PS: I don't know why it put a space in "getResourceAsStream".

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    How can I download the text file to the client?
    Do you mean have the applet read the file
    or write the file to the client's local drive?

    Applets require permission to write to a client's disk.

    What path would the filename be?
    That could depend on the server. Would you put the file in the same folder with the applet jar file or where would it go?

  3. #3
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    The Applet just needs to read the file; I assumed it would be downloaded to the client's harddrive from a signed applet. It could perhaps be read from a server though--however, if there's a lot of shaders written in GLSL then this could increase bandwidth significantly.

    Well, I could have it in another *.jar file... this could be beneficial if I wanted to download shaders to the client separately from textures and models. Honestly I think that would be better; I assume that jar file would go in the same folder as the applet jar file.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    If your files are in a jar file, would the browser's JVM get them via the applet's use of the getResource() method? The jar file would be listed in the <APPLET's archive= attribute

  5. #5
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Except that you can only specify one *.jar file using the archive attribute. If there are potentially several *.jar files, then a problem arises.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    I think you can have more than one jar file in the archive= attribute.

  7. #7
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Ah yes, apparently so: Jar Guide

    So if I have my main project in x.jar, and the GLSL text files are in y.jar, how does x.jar reference the y.jar files?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    The jar files don't do the referencing. The classes in the jar files request resources from the ClassLoader which looks on the classpath to find them. See Post#4

    The classes don't know where the resources are located. The JVM finds them.

  9. #9
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Ahhhhhh. I think that little bit of info will get this all working together then. Thanks Norm!

Similar Threads

  1. Sending Text File --- Server-To-Client
    By nigamsir in forum Networking
    Replies: 1
    Last Post: 03-08-2010, 03:45 PM
  2. Replies: 8
    Last Post: 02-18-2010, 12:54 PM
  3. Replies: 8
    Last Post: 11-06-2009, 06:52 AM
  4. Replies: 3
    Last Post: 07-29-2009, 04:52 AM
  5. Simple server/client text problem
    By Singing Boyo in forum New To Java
    Replies: 5
    Last Post: 06-02-2009, 10:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •