Show Posts
|
|
Pages: [1]
|
|
2
|
Java Game APIs & Engines / JOGL Development / shadows with textures
|
on: 2011-04-17 19:46:10
|
Hi, its me again! I tried to setup a simple shadow. I used the code from this tutorial: http://fabiensanglard.net/shadowmapping/index.phpWell, its working good (not the best shadow creation but its ok for me) but I am not able to use textures. I tried it with multitexturing, since the shadow map is a TEXTURE_2D but it doesnt work. All I got is this:  (yes, there also should be a skybox) Does anyone know how to solve this? Or, also a better/other shadow tutorial would also be useful, especially if i can use textures with it  greets
|
|
|
|
|
5
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-15 00:36:24
|
Mhm, i checked your code, and also tried your tips, but nothing helped. Then I tried to call this lines: 1 2
| System.out.println(glCapabilities.getPbufferRenderToTexture()); System.out.println(glCapabilities.getPbufferRenderToTextureRectangle()); |
And I got two times false. Could it be that my drivers dont support framebuffers / render to texture? or is this something other?
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-14 21:20:03
|
Very much THANKS! Now it works correctly! Sorry for my noobishness! Well, if its ok for you i have one last question, i tried to make a Framebuffer object, but always when i check the framebuffer with glCheckFramebufferStatus i get an error code, so that i cant use the frambuffer  I set it up like this: 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| void generateShadowFBO(GL2 gl) { int shadowMapWidth = RENDER_WIDTH * SHADOW_MAP_RATIO; int shadowMapHeight = RENDER_HEIGHT * SHADOW_MAP_RATIO; int FBOstatus; gl.glGenTextures(1, depthTextureId); gl.glBindTexture(GL2.GL_TEXTURE_2D, depthTextureId); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP ); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_R_TO_TEXTURE); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_COMPARE_FUNC, GL2.GL_LEQUAL); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_DEPTH_TEXTURE_MODE, GL2.GL_INTENSITY); gl.glTexImage2D( GL2.GL_TEXTURE_2D, 0, GL2.GL_DEPTH_COMPONENT, shadowMapWidth, shadowMapHeight, 0, GL2.GL_DEPTH_COMPONENT, GL2.GL_UNSIGNED_BYTE, 0); gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); gl.glGenFramebuffers(1, fboId); gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboId); gl.glDrawBuffer(GL2.GL_NONE); gl.glReadBuffer(GL2.GL_NONE); gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT,GL2.GL_TEXTURE_2D, depthTextureId, 0); FBOstatus = gl.glCheckFramebufferStatusEXT(GL2.GL_FRAMEBUFFER); if(FBOstatus != GL2.GL_FRAMEBUFFER_COMPLETE) System.out.println("GL_FRAMEBUFFER_COMPLETE_EXT failed, CANNOT use FBO\n"); gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0); } |
I need it for a simple shadow. Would it also be possible to render the screen simply to a texture? Thank you! and it would be ok if you dont want to help me anymore 
|
|
|
|
|
7
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-14 19:07:45
|
yes you are right..anyways thats for you help! Well, I tried a complete new project and simply put this in: 1 2 3 4 5 6 7 8 9 10 11 12
| public void init(GLAutoDrawable arg0) { GL2 gl = arg0.getGL().getGL2(); GLU glu = new GLU(); gl.glViewport(0, 0, arg0.getWidth(), arg0.getHeight()); glu.gluPerspective(45.0f, (float)arg0.getWidth()/(float)arg0.getHeight(), 1.0f, 2000.0f);
} |
1 2 3 4 5 6 7 8 9 10 11 12
| public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int width, int height) { GL2 gl = arg0.getGL().getGL2(); GLU glu = new GLU(); gl.glViewport(0, 0, width, height); glu.gluPerspective(90.0f,(float)width/(float)height), 1.0f, 2000.0f); } |
and put a sphere in the render routine. If i set the screen size for example to 600x600, everything looks normal. But if I set it on 1280x720 for example, everything is streched horizontally. I tried everything on the viewports and it seems that gluPerspective does NOTHING. No matter what i type in as parameters the view is always the same. I guess this is not normal and maybe the problem?? thank you in advance!
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-13 22:10:06
|
thanks for your help i checked all your advices and changed the hardcoded w and h with the GLAutoDrawable getHeight and getWidth. But nothing changed. It is still distorted  I also activated the lighting but now I just get this:  it seems that just the skybox is lightened up. But also not really correct. I dont know whats going on x_x
|
|
|
|
|
9
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-08 00:57:24
|
Mh, the adding of matrix.put(15,1f) didnt anything.... but here is my projection setup: 1 2 3 4 5 6 7 8
| if (height <= 0) { height = 1; } final float h=(float)width/(float)height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 10000.0); gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); |
or if its still too few, here is my complete source: http://www.xup.in/dl,80364351/src.zip/I hope its not too complicated  //Edit: It seems I also have some other problems. I'm also not able to render to texture. I use this function to render to texture: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| private void renderToTexture(GL gl, GLU glu) { gl.glViewport(0, 0, 128, 128); renderScene(); gl.glBindTexture(GL.GL_TEXTURE_2D, renderTexture);
gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_LUMINANCE, 0, 0, 128, 128, 0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } |
And my lighting also seems to be wrong. If i enable a simple light, everything is same bright. There are no darker and brighter sides (for example at my box). I dont get it...i also tried to light via Shader, but its the same effect. Everything at the same brightness..
|
|
|
|
|
10
|
Java Game APIs & Engines / JOGL Development / Re: JOGL Y axis too large
|
on: 2011-04-07 23:20:33
|
mhm, I cant find it. To get a FPS like movement, I set a FloatBuffer like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public void set(){ matrix.put(0, cosc*cosb-sinc*sina*sinb); matrix.put(1, sinc*cosb+cosc*sina*sinb); matrix.put(2, -cosa*sinb); matrix.put(4, -sinc*cosa); matrix.put(5, cosc*cosa); matrix.put(6, sina); matrix.put(8, cosc*sinb+sinc*sina*cosb); matrix.put(9, sinc*sinb-cosc*sina*cosb); matrix.put(10, cosa*cosb); matrix.put(12, matrix.get(0)*x+matrix.get(4)*y+matrix.get(8)*z); matrix.put(13, matrix.get(1)*x+matrix.get(5)*y+matrix.get(9)*z); matrix.put(14, matrix.get(2)*x+matrix.get(6)*y+matrix.get(10)*z); } |
and while rendering i load the matrix with this commands: 1 2
| matrix.rewind(); gl.glLoadMatrixf(matrix); |
These are the movement functions: 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 28 29 30 31 32 33 34
| public void setHeading(float amount){ heading+=amount; cosb=(float)Math.toRadians(Math.cos(heading)); sinb=(float)Math.toRadians(Math.sin(heading)); cosz=(float)Math.toRadians(Math.cos(heading+_90)); sinz=(float)Math.toRadians(Math.sin(heading+_90)); } public void setPitch(float amount){ pitch-=amount; if(pitch>_maxPitch)pitch=_maxPitch; if(pitch<-_maxPitch)pitch=-_maxPitch; cosa=(float)Math.cos(pitch); sina=(float)Math.sin(pitch); } public void setFord(float amount){ x+=cosz*amount; z+=sinz*amount; } public void setBack(float amount){ x-=cosz*amount; z-=sinz*amount; } public void setStrafel(float amount){ x+=cosb*amount; z+=sinb*amount; } public void setStrafer(float amount){ x-=cosb*amount; z-=sinb*amount; } public void setHeight(float amount){ y=amount; } |
Maybe here is something wrong with the matrix calculation? Because my viewPort etc are initialized like you said... Please help me, I dont geht the error 
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / JOGL Y axis too large
|
on: 2011-04-07 18:31:44
|
Hi! first off, I'm german, so sorry for bad language  I have a problem with my JOGL code. The Y axis is much bigger than the other ones. If I try to create a circle with gluSphere it is distorted vertically. Also if I build a "box" with vertexes, i have to hold the y values very small. I tried everything (gluPerspective, glViewport, etc etc) but nothing seemes to be the correct solution. I hope you understand my problem.. :/ greetings
|
|
|
|
|