TheThinMatrix / LowPolyTerrain

A demonstration of 4 possible techniques for generating and rendering a low-poly terrain.
The Unlicense
63 stars 17 forks source link

Java newbies #2

Open tothpaul opened 2 years ago

tothpaul commented 2 years ago

Hello,

thank you very much for your videos they are great ! I'm french but I understand well what you says and I like it !

now I try to compile this project with the help of your OpenGL Tutorial 1...

from your tutorial, I've put the src folder of this project and renamed it to "main" because of an error about package main...I've used the Build Path option to move the jar to the Referenced Libraries...after a lot of try and fail, I have an application that do compile (yes !) but the application crash

Couldn't get reader for /geometryTerrain/terrainVertex.glsl Could not read file. java.lang.NullPointerException at java.base/java.io.Reader.(Reader.java:168) at java.base/java.io.InputStreamReader.(InputStreamReader.java:76) at utils.MyFile.getReader(MyFile.java:58) at shaders.ShaderProgram.loadShader(ShaderProgram.java:86) at shaders.ShaderProgram.(ShaderProgram.java:30) at rendering.TerrainShader.(TerrainShader.java:22) at geometryTerrain.GeometryTerrainGenerator.(GeometryTerrainGenerator.java:55) at main.LowPolyDemoApp.main(LowPolyDemoApp.java:31)

It's probably nothing complex but I don't know how Java handles file paths (where is the root ?), I've tried to copy the file in bin/main/geometryTerrain, in c:\geometryTerrain but it still don't work

in Eclipse I have this organisation

GameEngine
 /main
   /flatTerrain
   /generation
   /geometryTerrain
     GeometyTerrainGeneration.java
     terrainFragment.glsl
    ...
   /indicesGenerators
   ...

I can see also the file in the bin/geometryTerrain directory along with the class file, the main class is in bin/main

can you see the problem ?

Thanks Paul

tothpaul commented 2 years ago

well...this works but I don't know why the original code do not work :)

public InputStream getInputStream() throws Exception {
        return new FileInputStream("C:\\Users\\tothp\\Desktop\\TheThinMatrix\\LowPolyTerrain-master\\bin" + path);//Class.class.getResourceAsStream(path);
    }
DanielGilbert commented 2 years ago

well...this works but I don't know why the original code do not work :)

public InputStream getInputStream() throws Exception {
      return new FileInputStream("C:\\Users\\tothp\\Desktop\\TheThinMatrix\\LowPolyTerrain-master\\bin" + path);//Class.class.getResourceAsStream(path);
  }

I have the same issue has you - your quickfix helped me getting the code running. I'm working on C#, so I just use this tutorial as a "how could it be done" reference, but it would be awesome to know what we did wrong.

Also, when downloading the compiled jar files from the tutorial video, I get the same exception - this is the command line I use: PS C:\Dev\Java\Projects> java.exe -cp LowPolyTerrainDemo_Windows.jar main.LowPolyDemoApp

tothpaul commented 2 years ago

Hi Daniel,

I'm working under Delphi, so it was just to test the code. I have now a working Delphi version ;)

BTW the last change I've made is

    public InputStream getInputStream() throws Exception {
        return new FileInputStream("bin" + path);//Class.class.getResourceAsStream(path);
    }