Hello Guest

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Lightweight Java Gaming Library / isCloseRequested
« Last post by Jehan on January 10, 2021, 19:54:38 »
hi everyone I have a simple question.

how to send a request to make Display.isCloseRequested() true ?

Code: [Select]
while (!Display.isCloseRequested())
{
Display.update();
nbFrame++;
}
Display.destroy();

thankyou !!
22
OpenGL / Multiple textures for multiple shaders
« Last post by Mihai_Ionut_Floares on January 09, 2021, 04:35:21 »
I have these 2 fragment shaders:
Simple.fragment:
Code: [Select]
#version 330 core

in vec2 UV;

out vec4 color;

uniform sampler2D myTextureSamplerr;
void main(){
//use the texture
}

Unlit.fragment:
Code: [Select]
#version 330 core

in vec2 UV;

out vec4 color;

uniform sampler2D myTextureSamplerr;
void main(){
//use the texture
}
And that's how I load them:
Code: [Select]
public static int loadTexture(String imagepath) {
Image image = new Image();
IntBuffer width = BufferUtils.createIntBuffer(1);
    IntBuffer height = BufferUtils.createIntBuffer(1);
    IntBuffer comp = BufferUtils.createIntBuffer(1);

ByteBuffer data = stbi_load(imagepath, width, height, comp, 4);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width.get(), height.get(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
id = glGenTextures();




stbi_image_free(data);

return id;


}

How to send a texture to first shader and another to the unlit one? Because even if I call the loadTexture method with 1 texture for a lit object and with the 2nd texture for the unlit one the both objects will use the 2nd texture(last called)
I think the problem is this line: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width.get(), height.get(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
It searched for uniform sampler2D and give the image to all of them.
23
OpenGL / Draw something in front of every thing else
« Last post by Mihai_Ionut_Floares on January 08, 2021, 21:20:40 »
How to draw an object even if it is behind another object?
24
OpenGL / Re: GLFW 3 Hide cursor
« Last post by Mihai_Ionut_Floares on January 08, 2021, 19:58:44 »
Sorry. I just found the solution:
Code: [Select]
glfwSetInputMode(WINDOW, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
25
OpenGL / GLFW 3 Hide cursor
« Last post by Mihai_Ionut_Floares on January 08, 2021, 19:53:54 »
I'm using this to set the cursor on the center of the screen to be able to pan the view around using mouse input like any other 3d game:
Code: [Select]
glfwSetCursorPos(WINDOW, Main.WIDTH/2, Main.HEIGHT/2);
It is working, but I want to add a crosshair. A simple GUI image centered. I want to keep the mouse functionality, but to hide it and keep only the crosshair.
26
OpenGL / Parent GLFW windows to java awt windows
« Last post by Mihai_Ionut_Floares on January 08, 2021, 02:09:12 »
I drew an schematic image of what I need:


I need to parent a java awt window to another java awt window and parent to that a glfw window.
The hierarchy of the windows would look like this:
Code: [Select]
JAVA AWT WINDOW #1
       JAVA AWT WINDOW #2
       GLFW WINDOW


So the JAVA AWT WINDOW #2 and the GLFW WINDOW are at the same level(childs of JAVA AWT WINDOW #1)

Is this possible?
27
OpenGL / Rotation matrix scales the object
« Last post by Mihai_Ionut_Floares on January 08, 2021, 01:39:19 »
Roation matrix code:
Code: [Select]
public static mat4 rotateMat(mat4 mat, float angle, vec3 axis) {
mat4 result = new mat4();
float radians = (float) Math.toRadians(angle);
float cos = (float) Math.cos(radians);
float sin = (float) Math.sin(radians);
float x2 = (float) Math.pow(axis.x, 2);
float y2 = (float) Math.pow(axis.y, 2);
float z2 = (float) Math.pow(axis.z, 2);
result.mat[0][0]+=cos+x2*(1-cos);
result.mat[0][1]+=axis.x*axis.y*(1-cos)-axis.z*sin;
result.mat[0][2]+=axis.x*axis.z*(1-cos)+axis.z*sin;

result.mat[1][0]+=axis.y*axis.x*(1-cos)+axis.z*sin;
result.mat[1][1]+=cos+z2*(1-cos);
result.mat[1][2]+=axis.y*axis.z*(1-cos)+axis.x*sin;

result.mat[2][0]+=axis.z*axis.x*(1-cos)-axis.y*sin;
result.mat[2][1]+=axis.z*axis.y*(1-cos)-axis.x*sin;
result.mat[2][2]+=cos+z2*(1-cos);





return result;
}
Source:


It rotates, but also scales the object, why?
And it seems logic, because the scaling is set by the diagonal of the matrix, but the rotation matrix overwrites that diagonal
28
OpenGL / Re: Orthographic projection matrix
« Last post by Mihai_Ionut_Floares on January 07, 2021, 15:00:09 »
Plus, when I face an object and approach it by pressing W and moving towards it, it stays at the same size(it doesn't look like I'm near it when I move side with A and D it moves relative to me and looks natural, but when I use the W and S it doesn't look bigger when I approach and it doesn't shrink when I walk backwards with S like normal. Is this a side effect of the orthographic projection or it something wrong). And I had to use the aspect ration for it to work(When on wikipedia photo it says right - left and top - bottom instead of Main.WIDTH for right - left I used 4f and instead of Main.HEIGHT for top - bottom I used 3f because my aspect ratio is 4:3)
29
OpenGL / Re: Orthographic projection matrix
« Last post by Mihai_Ionut_Floares on January 07, 2021, 14:42:51 »
With the wikipedia one it works, but I thought it wasn't because the skybox is black, Orthographic doesn't support object with the translation removed from view matrix like the cubemap?
30
OpenGL / Re: Orthographic projection matrix
« Last post by Mihai_Ionut_Floares on January 07, 2021, 14:26:48 »
I also found this image from wikipedia:


The calculations on column 3, row 0 and column 3 row 1 are useless.
Pages: 1 2 [3] 4 5 ... 10