Java-Gaming.org Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (732)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2016-05-27 14:15:41 
Started by noctarius - Last post by Spasi
Any mention of stack allocation and value types in the same sentence makes me wonder whether they're going to design what we actually need or whether they're just going to go off on one and make something almost but not quite entirely wrong.

The current Panama prototype supports "machine code snippets". You can write some code outside the JVM/JDK that makes the JVM inline and JIT-compile a method handle to one or more native CPU instructions (of your choice) that also play well with the JVM register allocator. This functionality alone could be used by a library to do amazing things.

API-wise, I wouldn't expect anything pretty without syntactic sugar. But it is true that it is designed under the assumption that Java 10 will have value types and any-generics. This, in theory, will allow Java-ish code to perform just like native C.

 2 
 on: 2016-05-27 14:06:07 
Started by useless - Last post by useless
The triangle is visible and i can change colors.

What exactly does this bit here do for you?

1  
2  
int shader = shader.getUniform("u_texture" + i); // get the texture variable
shader.bindUniformi(shader, i); // upload to texture unit 0


Im assuming it gets the location of the uniform u_texture0 and then sets the value for it to 0?

Why would that be neccessary if i activate the texture bank 0 with:
1  
glActiveTexture(GL_TEXTURE0);


and then bind my texture to that bank with:
1  
glBindTexture(GL_TEXTURE_2D, id);


shouldnt then the sampler in the fragment shader automatically look at the texture in the bank 0 if i say:
1  
layout (binding=0) uniform sampler2D sampler;


All the tutorials ive seen say that this sampler automatically takes what ever there is in the texture bank 0.

According to that there is no reason to be getting the location of my sampler uniform and setting it in the code. Is that what you are doing or I misunderstood?

 3 
 on: 2016-05-27 13:47:46 
Started by DrHalfway - Last post by princec
A bit input / output stream is surprisingly useful when you're dealing with native code (eg. reading codecs and such).

Cas Smiley

 4 
 on: 2016-05-27 13:45:03 
Started by DarkCart - Last post by princec
I'm being facetious really but I've not been overly impressed with Oracle's stewardship of Java for the last 10 years or so, though it could be worse. For the "how", they might simply abandon it to fully open-source development; the "why" would be... well they're not really make a lot of money for all the effort they're putting into developing Java. They could happily fob it off on some enthusiastic geeks and a bunch of other companies like Red Hat and Azure and get on with the business of making money off of someone else's efforts. A la Google Smiley

Cas Smiley

 5 
 on: 2016-05-27 13:17:46 
Started by DrHalfway - Last post by Hydroque
It is important to note that we CAN reduce file sizes by compacting numbers into eachother, but due to a lot of computer float issues, its hard.

However, I've managed to use a procedural fake system in my programming environment that square roots a whole file as one big number (converts bytes to number). Then I made a procedural multiplier which multiplies it out. It's pretty fast too. Takes the file size down a great 60%-80%.

 6 
 on: 2016-05-27 13:13:18 
Started by DrHalfway - Last post by DrHalfway
Greetings JGO!

I've come here to share some code which I've been using to feed my own personal arrogance and the need for exploration (in code of course).

So what is this code?

It's essentially a naive compact storage method which I've used in my own experiments. It's not really optimized but I've used it and continue to use it. It's become something of a small passion of mine. It did take some thought and time to put together properly.

Let's look at an example where something like this might come in handy.

Let's say you need to store a bunch of values into a file. These values range between 0 and 120. For this example it's simple, you can instantiate an array of bytes (8 bits) with each position in the array capable of holding all your values as long as they are between the original design of 0 and 120.

But what if?

Lets say you need to store a bunch of values into a file. These values range between 0 and 555. For this example it's also simple, you can instantiate an array of shorts (16 bits) with each position in the array capable of holding all your values as long as they are between the original design of 0 and 120.

In general, this will be of no problem, but there are scenarios where you may wish to squeeze every little saving in file size as you can, especially for cases where it will be transferred over a network.

The Binary Compactor was created to solve this problem. It essentially allows you to write and read values with variable bit lengths. In the case of the 2nd example, you can fit values of 0-555 into 10 bits, which will save you 6 bits of information per array position.

Let's look at some code on how this works.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
// first, we initialize a new writer with default write position at 0
// can also be used to load a previous stream from file
BitWriter writer = new BitWriter();

// let's write 3 boolean values, these will take a total storage of 3 bits
writer.write(true);
writer.write(false);
writer.write(true);

// let's write some integers. First argument is the value to be written,
// 2nd argument is the number of bits it will take.
writer.write(555, 10);
writer.write(62, 6);
writer.write(1792, 12);
writer.write(57892, 17);
writer.write(7658, 14);

// and just for fun, dump this stream into console
System.out.println("BITS: " + writer.getBitString());

// prints
// BITS: 10111010 10001011 11100000 00011100 01001000 10001110 01010111 10111000


Now to iterate those values back.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
// define a new iterator from the writer
BitIterator it = writer.getIterator();

// start iterating the previous variables. Notice how you have to tell
// the iterator how many bits to read

// the boolean values from before
System.out.println(it.getNext32(1));
System.out.println(it.getNext32(1));
System.out.println(it.getNext32(1));

// the integer values from before
System.out.println(it.getNext32(10));
System.out.println(it.getNext32(6));
System.out.println(it.getNext32(12));
System.out.println(it.getNext32(17));
System.out.println(it.getNext32(14));

// prints
// 1
// 0
// 1
// 555
// 62
// 1792
// 57892
// 7658


Unfortunately the entire method is too large to post in here however it is available free of charge (along with a C# implementation) at my github repository https://github.com/DavidArayan/EzyBits

Will most of you have any use for this? NO
Should you use this instead of normal int/short/longs? NO

However there will come a time, at some place, somewhere in your own experiments where you would say "I wish I had an easy method of reading and writing any variable in any bit length I want, cause of reasons".

Contributions, Feature Requests and Comments all welcome!

 7 
 on: 2016-05-27 13:09:15 
Started by DarkCart - Last post by Cero
This opens up the slim possibility that Oracle will mercifully divest itself of Java, on the other hand. Which would be nice.

How would they do this? Also why? considering their business.
And why do you think the implications would be favorable?

 8 
 on: 2016-05-27 13:03:46 
Started by useless - Last post by Hydroque
First, make sure that your quad or whatever your drawing pops up.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
#version 400 core

in vec3 pass_position;

out vec4 out_Color;

void main(void) {
   
   out_Color = vec4(1,1,1,1);
   
}

Then make sure that it pops up with color and change the 1's to decimals to make sure that the color changes.

This confirms that you are actually drawing something.

Adding uniform sampler2D u_texture; will allow you to get a texture in there to read the texel at the point and shade it. Thusly, you can add that variable.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
#version 400 core

in vec2 pass_texcoord;

uniform sampler2D u_texture0;

out vec4 out_Color;

void main(void) {
   
   out_Color = vec4(1,1,1,1);
   
}


As you can see, I just plopped it in there. I added a 0 at the end as per when I do multitexturing (u_texture1, u_texture2, etc). So now we have to set the texture in the shader.

First, you need to bind the shader, then get the variable.
// *binds shader*
int shader = shader.getUniform("u_texture" + i); // get the texture variable
GL13.glActiveTexture(GL13.GL_TEXTURE0 + i); // from texture unit 0, translated 0 because let's say i = 0 (on texture 0)
GL11.glBindTexture(GL11.GL_TEXTURE_2D, material.getTextureData().getId()); // actually load the texture into here
shader.bindUniformi(shader, i); // upload to texture unit 0

Then you need to use it in your shader.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
#version 400 core

in vec2 pass_texcoord;

uniform sampler2D u_texture0;

out vec4 out_Color;

void main(void) {
   
   out_Color = texture(u_texture0, pass_texcoord); // and here we are
   
}


If your texture is upside down, you have a texcoord/indices/vertex problem.



 9 
 on: 2016-05-27 11:47:55 
Started by DarkCart - Last post by princec
Exactly. And yet the internet is awash with programmers who seem to be entirely happy about this situation.

I'll suppose those programmers have never spent 20 years designing something, only for some giant corporation to come along and go "yoink! I'm 'avin' that" and subsequently make forty billion dollars out of it without giving them a bean.

Cas Smiley

 10 
 on: 2016-05-27 11:25:05 
Started by DarkCart - Last post by ags1
What irks me about this case is the Google position that no hard, creative labor goes into designing the API. According to Google that is no effort at all and only the implementation involves real work.

I'm sure I'm not the only one who thinks the implementation is relatively trivial in comparison to designing, validating and evolving a good API.

On the other hand, if this went in favor of Oracle, it would be like software patents all over again, but ten times worse.

Pages: [1] 2 3 ... 10
 
Hydroque (16 views)
2016-05-26 14:45:46

Mac70 (38 views)
2016-05-24 21:16:33

theagentd (42 views)
2016-05-14 18:38:35

theagentd (76 views)
2016-05-10 22:37:41

theagentd (82 views)
2016-05-10 22:33:46

IanParcs (110 views)
2016-04-18 14:18:53

KaiHH (106 views)
2016-04-18 08:35:41

KaiHH (130 views)
2016-04-15 12:43:58

theagentd (134 views)
2016-04-14 02:16:17

theagentd (157 views)
2016-04-14 02:15:43
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!