Show Posts
|
|
Pages: [1]
|
|
5
|
Game Development / Newbie & Debugging Questions / LWJGL Keyboard, what's going on?
|
on: 2013-01-28 17:22:36
|
Hello! Quick question! I have player input setup like this: 1 2 3 4 5
| boolean keyUp = Keyboard.isKeyDown(Keyboard.KEY_UP) ... if(keyUp){ } |
And a bit later: 1 2 3 4 5
| while(Mouse.next()){ if(Mouse.isButtonDown(0)){ } } |
So what happens is, if player holds UP key to run and presses mouse button to fire, movement stops. In order to run again, player must press up key again, running while shooting is impossible. Why do keys get reset that way?
|
|
|
|
|
6
|
Games Center / Cube World Projects / Re: Merging triangle faces!
|
on: 2013-01-06 23:24:26
|
I don't see why you need to optimise it that much. And that will just slow down the CPU when just one block is missing from the surface.
Well it seems like a good way to increase performance, I'll stick to only face and frustrum culling for now. 
|
|
|
|
|
7
|
Games Center / Cube World Projects / Merging triangle faces!
|
on: 2013-01-06 22:56:13
|
Hello!  I need some help! So basically, having an integer array of cube ids with the size of 16^3 and static method, which returns triangle vertices based on location given by array iterator. Feeding vbo with that data I get this mess:  Nothing fancy but here's a problem I'm struggling with.. That chunk of cubes could also be rendered like this, providing that ids are the same:  Getting rid of cubes that are completely surrounded would be easy, but I still have a lot of verticies left that don't have to be stored in memory. I need someone's help on algorithm that would "merge" verticies that share the same properties and kept triangle topology. (after trying it just got far too complex)
|
|
|
|
|
8
|
Java Game APIs & Engines / OpenGL Development / Finding 2D point on screen from 3D perspective
|
on: 2012-07-27 20:30:02
|
Well, the title explains what I need to know  So if I have a basic lwjgl/opengl 3D world with some entities which can be some NPC's or other game stuff. And lets say I want to make floating names, test if object is seen by camera etc. I need to know exact 2D point coordinates when I have 3D point location data. This is how I did 3D picking (needs to be "reversed"): Please tell me if there's a better way. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public static Vector3f getMousePosition(int mouseX, int mouseY) { viewport = BufferUtils.createIntBuffer(16); modelview = BufferUtils.createFloatBuffer(16); projection = BufferUtils.createFloatBuffer(16); winZ = BufferUtils.createFloatBuffer(1); position = BufferUtils.createFloatBuffer(3); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection); GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); GL11.glReadPixels(mouseX, mouseY, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZ);
if (winZ.get(0) == 1) { return null; } GLU.gluUnProject(mouseX, mouseY, winZ.get(), modelview, projection, viewport, position); return new Vector3f(position.get(0), position.get(1), position.get(2)); } |
So I was thinking... By using this (found on stackoverflow): 1
| screen_coordinates = projection_matrix * modelview_matrix * world_coordinates |
Could I somehow get position this way? I need help 
|
|
|
|
|
12
|
Game Development / Newbie & Debugging Questions / Re: lwjgl Display remove title bar?
|
on: 2012-02-19 02:22:46
|
Take a java.awt.Window, put a java.awt.Canvas in it and use Display.setParent(...) to bind your surface to the canvas.
I've returned to this project, and made it work. But now I want to know how does resizing of the window work (Display.getWidth or JFrame.getWidth())? If I render something on screen with opengl (I use Display.getWidth/2 to render 2D in center) and then resize this screen everything moves out of place (aspect ratio messes up, before I used Display.wasResized() to renew ratio on gluPerspective). I tryed to use Frame.getWidth() and getHeight() but I get same result. I want to know how are display and jframe connected exactly. sry for my typing, i need to get some sleep. parent code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Canvas = new Canvas(); Frame = new JFrame("sup");
Frame.setSize(1280, 720); Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Frame.setBackground(Color.BLACK); Canvas.setBackground(Color.BLACK); Frame.getContentPane().add(Canvas); Frame.setLocationRelativeTo(null); Frame.setVisible(true); try { Display.setVSyncEnabled(true); Display.setParent(Canvas); Display.create(); } catch (Exception e) { e.printStackTrace(); Display.destroy(); System.exit(0); } |
|
|
|
|
|
16
|
Game Development / Newbie & Debugging Questions / Re: lwjgl FBO texture rendering problem
|
on: 2012-02-16 14:54:22
|
Ok I tried making fixed display size of 1280x720, then use same size for fbo and final screen display method. I also played around with pixelformat of display and I did some optimizing for my game render methods (commented out some stuff). Result is still the same  . If fbo code is ok then i must have done something wrong with vbo's, because there is nothing else that could go wrong (maybe).
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: lwjgl FBO texture rendering problem
|
on: 2012-02-15 15:28:32
|
No, I have glViewport before rendering to the fbo. this is before rendering to fbo: 1 2 3 4 5 6 7 8 9
| glViewport (0, 0, Display.getWidth(), Display.getHeight()); glBindTexture(GL_TEXTURE_2D, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, openGL.framebufferID); glClearColor (0.0f, 0.0f, 0.0f, 1.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); glTranslatef (0.0f, 0.0f, intoTheScreen);
|
and later to display fbo texture: 1 2 3 4 5 6 7 8 9
| glEnable(GL_TEXTURE_2D); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glClearColor (0.0f, 0.0f, 0.0f, 1.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); glTranslatef (0.0f, 0.0f, intoTheScreen); glColor3f(1, 1, 1); renderScreen(); |
renderScreen method: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public void renderScreen() { GL11.glPushMatrix(); glMatrixMode(GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(),0, Display.getHeight(), -1, 1); glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, openGL.colorTextureID); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); glTexCoord2f(1.0f, 0.0f); glVertex2i(Display.getWidth(), 0); glTexCoord2f(1.0f, 1.0f); glVertex2i(Display.getWidth(), Display.getHeight()); glTexCoord2f(0.0f, 1.0f); glVertex2i(0, Display.getHeight()); glEnd(); glPopMatrix(); } |
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / lwjgl FBO texture rendering problem
|
on: 2012-02-14 22:56:13
|
Good day I have a problem while rendering to texture using FBO. I followed tutorial on lwjgl.org and got it to work with my project, but as you can see on the bottom picture it doesn't work as it should. You can see this funny lines on all of my textures which should not be there (top-right to bottom-left, also edges are strangely distorted). I had this problem before when i started with lwjgl and made basic textures and stuff, but i don't remember how i fixed it. I'm rendering cubes with VBO's and i have blend, cull_face and gl_texture_mag_filter gl_nearest enabled, but anyway problem occurs on basic openGL texture calls too. Help me to solve this mystery?  example: 
|
|
|
|
|
20
|
Game Development / Newbie & Debugging Questions / Re: lwjgl, jarsplice, distributing problem
|
on: 2012-01-24 00:52:42
|
Well I load this single image as bufferedImage, and catch exception which i can see later when running: 1 2 3 4 5 6 7 8 9
| public static void load(){ imageMain = null; try { imageMain = ImageIO.read(new File("res/fonts/font.png")); } catch (IOException e) { System.out.println("cant load fonts Image!"); System.exit(0); } } |
I use this one later to get subimages... And then I load a bunch more textures using InputStream for "regular use": 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
| public static Texture basic; public static Texture orange; public static Texture blue; public static Texture menuBG; public static Texture stars; public static Texture moon; public static Texture redPlanet; public static void initTexs(){ try { basic = TextureLoader.getTexture("PNG",new FileInputStream(new File("res/tex/basic.png"))); orange = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/tex/orange.png"))); blue = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/tex/blue.png"))); stars = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/tex/stars.png"))); menuBG = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/menu/background.png"))); moon = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/tex/moon.png"))); redPlanet = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/tex/redplanet.png"))); System.out.println("Textures are loaded!"); } catch (IOException e) { e.printStackTrace(); System.out.println("Error while loading textures!"); Display.destroy(); System.exit(0); } } |
|
|
|
|
|
21
|
Game Development / Newbie & Debugging Questions / lwjgl, jarsplice, distributing problem
|
on: 2012-01-24 00:27:55
|
|
Im sure this has been answered before, but I will ask it anyway. I exported my lwjgl game and used jarsplice to create fat jar, simple. But when runnng my game I get image not loaded exception. Basically textures failed to load. Do I have to make some sort of workaround for this to work? I use slick Textureloader and imageIO for a couple of images which works perfectly when debugging from eclipse. It seems I get exception under imageIO.
How can I get it to work?
|
|
|
|
|
22
|
Game Development / Newbie & Debugging Questions / lwjgl Display remove title bar?
|
on: 2012-01-22 01:02:12
|
Hey! I have a simple question. Is it possible to remove title bar and decoration around lwjgl openGL display when using windowed mode? similar to JFrame maybe: 1 2 3 4 5
| JFrame frame = new JFrame("something"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(width,height); frame.setUndecorated(true)); frame.setVisible(true); |
|
|
|
|
|
25
|
Game Development / Newbie & Debugging Questions / Re: BufferedImage to lwjgl texture
|
on: 2012-01-15 01:09:56
|
|
I can't get it to work. I get alot of errors like invalid enum or null pointer location using various methods in opengl. At the end i tryed displaying this buffer with drawPixels() method which kinda worked but image was completly messed up. Can you please show me how to bind this buffer, to gl_quads for example, correctly? I don't know exactly what im doing couse i started learning java about a month ago. Thanks for your help!
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / BufferedImage to lwjgl texture
|
on: 2012-01-14 16:56:59
|
|
Hi guys! I have a simple question about converting a bufferedimage from java.awt library to lwjgl Texture. Basically i want to bind this texture to opengl ("texture.bind()") after i do some cropping from the main image (using "image.getSubImage(x,y,width,height)" or cropImageFilter()"). It's supposed to make a few textures from a bigger image just like minecraft does for it's fonts and so on. So can anyone give me a snippet how could i do this?
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|