Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: OpenGL OS/X, Linux problems on: 2013-08-28 08:52:18
The major minor version was caused because I used 1.7 but in the meantime I switched to 1.6.

At least it's good to know that it runs on some systems.
2  Game Development / Newbie & Debugging Questions / OpenGL OS/X, Linux problems on: 2013-08-27 22:04:18
Hey guys. I finished my first Ludum Dare entry on Sunday and got some problems with cross-platform support. Everything runs fine on Windows machines but it seems to crash on start-up on Mac and Linux. The first problem was that I worked with Java 1.7 but in the meantime I switched to 1.6. I'm using LWJGL and OpenGL 3.2.

Since I don't own a Mac or have a Linux system it's quite hard to find the problem. But through people posting about the crashes it seem to be this part of the code where the error occurs:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
int shaderHandle = GL20.glCreateShader(shaderType);

if (shaderHandle != 0) {
   GL20.glShaderSource(shaderHandle, shaderSource);
   GL20.glCompileShader(shaderHandle);
   int compileStatus = GL20.glGetShaderi(shaderHandle, GL20.GL_COMPILE_STATUS);
   
   if (compileStatus == 0) {
      System.out.println("Error compiling shader: GL20.glGetShaderInfoLog(shaderHandle)");
      GL20.glDeleteShader(shaderHandle);
      shaderHandle = 0;
   }
}

if (shaderHandle == 0) {        
   throw new RuntimeException("Error creating shader.");
}


"GL20.glCreateShader(shaderType)" seems to fail and returns 0.

This is how I'm initiating OpenGL on start-up:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);

try {
   Display.setDisplayMode(new DisplayMode(RESOLUTION.width,RESOLUTION.height));
   Display.setTitle(WINDOW_TITLE);
   Display.create(pixelFormat, contextAtrributes);
} catch (LWJGLException e) {
   e.printStackTrace();
   System.exit(-1);
}


Any ideas how to handle this and/or how to approach cross platform games?



All the posts about the errors are located here:
http://www.ludumdare.com/compo/ludum-dare-27/?action=preview&uid=26860
3  Games Center / Contests / Re: Ludum Dare 27 on: 2013-08-26 15:35:04
Here is my first entry "SuperSleepTime": http://www.ludumdare.com/compo/ludum-dare-27/?action=preview&uid=26860

You play as a superhero who overslept and only has 10 seconds to get ready to work. Depending what you get done you have different power-ups while fighting the enemies.

It requires OpenGL 3.2 and has some problems running on OS/X and Linux at the moment. But I will try to fix that and/or make a post later on asking for help. Wink
4  Java Game APIs & Engines / OpenGL Development / Re: Pixel / Scaling Error on: 2013-07-05 12:14:34
Awesome thanks! That makes sense I guess. My font is only 8 pixels high and it looks I'm save as long as I only use text sizes double that size etc.

I'll definitely check out your line rendering method, but for know I'll just keep using GL_LINE_LOOP since it's only for debugging and not that important.

Also I was able to clean up my interface by just rendering the textures in the right size. Seems pretty logical in retrospect...

Thanks again!
5  Java Game APIs & Engines / OpenGL Development / Pixel / Scaling Error on: 2013-07-04 13:44:49
I noticed a couple of strange pixel Errors in my Game and got no idea where they would come from. There's an image attached which shows three of them. They could be related too each other but I'm not sure. I also included some of my code. Any help would be appreciated! Smiley
If there's anything I should explain in more detail let me know. Thanks!


1. The first one is a problem with my text rendering. On the top right is the original text and beneath it is a magnification. As you can see it looks really messed up. There are some pixels missing etc. Beneath that you can see the original texture. The texture sheet itself is really small. But increasing the size didn't help.

2. The second one are the turquoise boxes which represent my collision objects. They render fine but when I move the camera there is a chance that some of the lines disappear. Also marked with red Arrows. I'm using GL_LINE_LOOP for those.

3. The third one isn't that big but still strange. On the ground floor of the building below the ceiling there is a small offset in the texture. Only by one pixel or so. If the camera is moved the error appears / disappears. On the bottom is a side by side comparison of the ingame texture and the orignal one.



Edit: The picture seems to be to wide, you can scroll to the right to see the rest of it..

Text drawing:
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  
      fontColor.bind();
      glEnable(GL_TEXTURE_2D);
      TextureHelper.hashtable.get("font1.png").bind();
     
      for(int i = 0; i < inputString.length(); i ++) {
         int asciiCode = (int)inputString.charAt(i);
         
         //ascii position minus first character in texture sheet (in this case " " / Space)
         asciiCode -= 32;
         //get tileX for char by ascii position modulo table width
         int tileX = asciiCode % 16;
         //get tileY for char by ascii position divided by table width
         int tileY = asciiCode / 16;
         
         float offset = size * i;
         
         glBegin(GL_QUADS);
            glTexCoord2f(0.0625f * tileX, 0.125f * tileY);
            glVertex3f(posX + offset, posY, depth);
            glTexCoord2f(0.0625f * (tileX + 1), 0.125f * tileY);
            glVertex3f(posX + size + offset, posY, depth);
            glTexCoord2f(0.0625f * (tileX + 1), 0.125f * (tileY + 1));
            glVertex3f(posX + size + offset, posY + size, depth);
            glTexCoord2f(0.0625f * tileX, 0.125f * (tileY + 1));
            glVertex3f(posX + offset, posY + size, depth);
         glEnd();
      }


Texture drawing and lineloop drawing:
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  
   public static void texQuad(Texture texture, float xPosition, float yPosition, float xSize, float ySize, float depth) {
      glEnable(GL_TEXTURE_2D);
      Color.white.bind();
      try {
         texture.bind();
      } catch (NullPointerException e) {
         e.printStackTrace();
         glDisable(GL_TEXTURE_2D);
         glColor4f(198.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f);
      }
      glBegin(GL_QUADS);
         glTexCoord2f(0,0);
         glVertex3f(xPosition, yPosition, depth);
         glTexCoord2f(1,0);
         glVertex3f(xPosition + xSize, yPosition, depth);
         glTexCoord2f(1,1);
         glVertex3f(xPosition + xSize, yPosition + ySize, depth);
         glTexCoord2f(0,1);
         glVertex3f(xPosition, yPosition + ySize, depth);
      glEnd();
   }
   
   public static void lineLoop(Color color, float xPosition, float yPosition, float xSize, float ySize, float depth) {
      glDisable(GL_TEXTURE_2D);
      color.bind();
      glBegin(GL_LINE_LOOP);
         glTexCoord2f(0,0);
         glVertex3f(xPosition,          yPosition,          depth);
         glVertex3f(xPosition + xSize,    yPosition,          depth);
         glVertex3f(xPosition + xSize,    yPosition + ySize,    depth);
         glVertex3f(xPosition,          yPosition + ySize,    depth);
      glEnd();
   }


Camera:
1  
2  
3  
4  
5  
      glOrtho(Player.xPosition - Game.resolution.width  / 2 * InGame.camScale, 
            Player.xPosition + Game.resolution.width  / 2 * InGame.camScale,
            Player.yPosition + Game.resolution.height / 2 * InGame.camScale,
            Player.yPosition - Game.resolution.height / 2 * InGame.camScale,
            20, -20);
6  Games Center / Showcase / Re: MARUTA Remake on: 2012-08-11 23:13:42
Awesome works perfectly! Smiley
7  Java Game APIs & Engines / OpenGL Development / GLSL Multitexturing and Texture Units (glActiveTexture ) on: 2012-08-05 17:43:13
My game world is rendered into a framebuffer and another texture gets multiplied on top by using a GLSL shader. That works perfectly fine.
Now I tried rendering another quad on top of that with a separate shader but had some difficulties getting that to work. In the end I noticed in debug mode that the first frame looks fine and after that the whole screen turns black (except the second quad).

After adding "glActiveTexture(GL_TEXTURE1);" to the last line suddenly both quads and both shaders showed up and are working fine. But I have no idea why? Any ideas why I have to change the active Texture Unit back to one?

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  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
//FrameBuffer renderpass:
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, worldColor.framebufferID);

glClearColor (1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(Player.xPosition-resolution.width/2*camScale, Player.xPosition+resolution.width/2*camScale, Player.yPosition+resolution.height/2*camScale, Player.yPosition-resolution.height/2*camScale, 1, -1);
cameraRender = (int)getTime();

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();  

glActiveTexture(GL_TEXTURE0);
sky.render();
skyRender = (int)getTime();
world.render();
worldRender = (int)getTime();
player.render();
playerRender = (int)getTime();
Inventory.render();
inventoryRender = (int)getTime();
Menu.render();
Cursor.render();
DebugScreen.render();

//Normal Renderpass:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

glClearColor (1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

GL11.glOrtho(0, resolution.width, 0, resolution.height, 1, -1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();  

Color.white.bind();

glUseProgram(light.shaderProgram);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, worldColor.colorTextureID);
glUniform1i(light.the_location0, 0);      

glActiveTexture(GL_TEXTURE1);
Tiles.vignette.bind();
glUniform1i(light.the_location1, 1);

glBegin(GL_QUADS);
   glTexCoord2f(0, 0);
   glVertex2f(0, 0);
   glTexCoord2f(1, 0);
   glVertex2f(resolution.width, 0);
   glTexCoord2f(1, 1);
   glVertex2f(resolution.width, resolution.height);
   glTexCoord2f(0, 1);
   glVertex2f(0, resolution.height);
glEnd();

glUseProgram(0);

glUseProgram(diffuse.shaderProgram);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Tiles.characters1.getTextureID());
glUniform1i(diffuse.the_location0, 0);

glBegin(GL_QUADS);
   glTexCoord2f(0, 0);
   glVertex2f(0, 0);
   glTexCoord2f(1, 0);
   glVertex2f(200, 0);
   glTexCoord2f(1, 1);
   glVertex2f(200, 200);
   glTexCoord2f(0, 1);
   glVertex2f(0, 200);
glEnd();

glUseProgram(0);

glActiveTexture(GL_TEXTURE1); // <-- why this?
8  Games Center / WIP games, tools & toy projects / Re: BOUNCE - 2D Platformer w/ destructable terrain on: 2012-08-04 15:21:01
I'm only getting this:
"Could not find main class: gametemplate.Main. Program will exit."
9  Games Center / Showcase / Re: Blasted Crates on: 2012-08-04 15:16:53
Great game! 

But level 8 stage 2 killed it for me. And will not try again.  Wink
It kinda seemed while jumping over the second crate that the one on top always exploded a few pixels before I would touch it, which was kinda annoying.
10  Game Development / Newbie & Debugging Questions / Re: How to determine game performance? on: 2012-07-27 05:36:50
Ok, I did a quick test with a 1024x1024 texture and it seems I will gain around 500 fps. So a bit better but still a lot of room for improvement. Also I haven't tried yet to offset the texture coordinates for each different tile.

I guess my next step is to write a better debug screen to check all the ms, I already have one but it's kinda crap. I'm not really sure if I want to use up all of the 16.67 ms, my system is fairly good and I would like it to be able to run on older machines too. But probably I should move on after implementing the texture atlas and start with the other stuff. Also sound logical that improving stuff will make more sense later on.

Another thing is, I tried using VBOs and Display Lists and didn't really get any performance increase. The performance got even worse. Will it cost more to use those for each tile than just drawing the 4 vertices and texture coordinates directly? If there should be an increase in performance not matter what I will go back and try to fix those.

Anyway thanks for all the great help so far!
11  Game Development / Newbie & Debugging Questions / Re: How to determine game performance? on: 2012-07-27 04:42:51
The number of tiles to render is a whole other story anyway, first I want to have a framework with a decent performance before I start working on anything else.

If each texture sheet for each material is 64x128 (giving me 128 different tiles for each material) and lets say I want 128 different materials. Making 16,384 individual tiles. That would be 1,048,576 pixels in a 1024x1024 texture. If I'm not mistaken that really doesn't seem so bad.

The last time I did this calculation I had a completely different result. Must have been late at night... Wink

So back to the texture atlas again!
(and I know the number of different tiles is high, but I would really like to have a system where this is possible)

Oh yes, I'm working with LWJGL.
12  Game Development / Newbie & Debugging Questions / Re: How to determine game performance? on: 2012-07-27 04:13:24
Yeah your rough guess is pretty close.  Cheesy Only I'm using 1280x720.
Another reason for me to improve performance is that I actually want to render even more at some point.

I tried different stuff with texture sheets and without, never changed much in performance. Each tile texture is only 8x8 but I have a lot of them. For example for grass: top, bottom, right, left, all the outer corners, inner corners, single double sided and so on. Plus variations. I was thinking to use an automated texture atlas to bind one big texture with all tiles before drawing the tiles but soon noticed that that would have to be a gigantic texture if I will have a lot of different tile IDs (rock, grass, stone, ...)

This code runs for every block:
(in this case without texture sheet and textures 8x8 pixels)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
glBindTexture(GL_TEXTURE_2D, textureID);
   glBegin(GL_QUADS);
      glTexCoord2f(0, 0);
      glVertex2f(x * Tiles.blockScale, y * Tiles.blockScale);
      glTexCoord2f(1, 0);
      glVertex2f(x * Tiles.blockScale + Tiles.blockScale, y * Tiles.blockScale);
      glTexCoord2f(1, 1);
      glVertex2f(x * Tiles.blockScale + Tiles.blockScale, y * Tiles.blockScale + Tiles.blockScale);
      glTexCoord2f(0, 1);
      glVertex2f(x * Tiles.blockScale, y * Tiles.blockScale + Tiles.blockScale);
   glEnd();


I was wondering if there is any better way to draw textures than this.
13  Game Development / Newbie & Debugging Questions / How to determine game performance? on: 2012-07-27 03:03:14
I'm fairly new to game programming and I was wondering how to know what a "good" game performance is.

My 2D Game consist out of a lot of tiles. With my current camera scale it would be 1400 textured tiles on screen, if the whole screen is covered in them. When that's the case my frames per second drop from 4300 (no tiles on screen) to 1500 (screen covered in tiles). And that's only the terrain. I'm planning to add lighting, more sprites for trees, enemies etc and all the game logic. And I'm wondering if I already lost too much performance on the terrain rendering.

I know it always depends on what kind of game, but can you say for example about 50% of the resources go to sprite rendering, 30% go to lighting and 10% each go to game logic and sound?

Any advice on performance testing / resource budgeting appreciated! Smiley
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Gibbo3771 (12 views)
2014-11-24 19:59:16

trollwarrior1 (35 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!