Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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] 2
1  Games Center / Showcase / Re: [LD29]Mission "Tank" on: 2014-05-06 12:41:52
Thanks you for playing it! Click counter is working whole game, not only in combat. I don't think i'll improve this game (I don't know why not, but i just don't want to do that).   
2  Games Center / Showcase / [LD29]Mission "Tank" on: 2014-04-29 04:44:16
Hello everyone! I want to show my game for LD29(Beneath the surface). My game is not polished or really done, but i am happy enough with result.
Good luck in game!







3  Game Development / Newbie & Debugging Questions / Re: Playing audio in game background on: 2014-04-23 11:54:55
Everything worked! I used slick2d. Thanks again!
4  Game Development / Newbie & Debugging Questions / Re: Playing audio in game background on: 2014-04-23 04:48:07
Thanks for help! I will try everything soon.
5  Game Development / Newbie & Debugging Questions / Re: Playing audio in game background on: 2014-04-22 21:33:41
I am using LWJGL. I have music in wav, mp3, ogg... I don't really care about format.
6  Game Development / Newbie & Debugging Questions / Playing audio in game background on: 2014-04-22 20:46:45
Hello everyone. I have small problem, i need to play audio in my game background while playing game and i cant do that. I used Google, but i cant find anything useful. I don't care about audio format. Please help me.
7  Discussions / Miscellaneous Topics / C++ models,textures loading on: 2014-04-15 16:40:18
Hello everyone. I just have started learning OpenGL, and i have a problem. I am reading OpenGL SuperBible, i have all sample code, models, textures and other stuff from that book. I just have reached topic about textures, models and everything is okay, but models in samples are in "SBM" format, and textures are in "KTX". All i want to load models in other format(obj,3ds), and load textures in png or other popular format. How i can do it? Please, give me some code or something. Thanks for help!
I have downloaded all samples from here: openglsuperbible.com and I am programming with C++.
8  Discussions / Miscellaneous Topics / Math problem on: 2014-03-05 15:27:05
I cant solve this:

37x + 8 = z
43y + 11 = z
z < 1000
x,y - natural numbers


I know answer is:
x = 21
y = 18
But, i need to prove it.
9  Game Development / Game Mechanics / Re: Infinite 2D world on: 2014-03-03 12:03:24
Its something like a terraria or starbound
10  Game Development / Game Mechanics / Re: Infinite 2D world on: 2014-03-02 21:13:29
I have chunks with 256 blocks (16x16), one block size is 8 pixels. And each block have tons of info about that block.
11  Game Development / Game Mechanics / Re: Infinite 2D world on: 2014-03-01 10:22:49
I will try it, if there is no way. Thanks!
12  Game Development / Game Mechanics / Infinite 2D world on: 2014-03-01 10:00:35
I want to know how to avoid "Java heap space" error in big 2D worlds. If i have more than 1000 chunks i get java heap space error. I tried to save chunks and delete them from game (keep data about them in computer hard drive). but when i need to load them my FPS drops to 1 for few seconds.
13  Game Development / Newbie & Debugging Questions / Re: "2D blocks game" water falling on: 2014-03-01 09:47:32
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public void updateVBOTextures(){
      for(int xb = 0;xb < 16;xb++){
         for(int yb = 0;yb < 16;yb++){
            changeTextureVBO((xb*16)+yb,blocks[xb][yb].textureX,blocks[xb][yb].textureY);
         }
      }
      glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
      glBufferData(GL_ARRAY_BUFFER, (FloatBuffer) BufferUtils.createFloatBuffer(data.length).put(data).flip() , GL_STATIC_DRAW);
     
   }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public void changeTextureVBO(int target,float textureX, float textureY){
      target = target * 32;
      data[target+2] = textureX;
      data[target+3] = textureY;
     
      data[target+2+8] = textureX + texSize;
      data[target+3+8] = textureY;
     
      data[target+10+8] = textureX + texSize;
      data[target+11+8] = textureY + texSize;
     
      data[target+18+8] = textureX ;
      data[target+19+8] = textureY + texSize;
     
      target = 0;
     
   }


I am using static draw. I am not using any shaders.
14  Game Development / Newbie & Debugging Questions / "2D blocks game" water falling on: 2014-02-28 17:33:40
I am making 2D blocks game, everything is ok, but i cant make water falling correct. Water falling is working, but it takes too much FPS.
My water blocks extends class Blocks. To render blocks i am using VBOs (one chunk - one VBO). Right now i am updating chunk VBO, when water block moves. I am doing it like that:

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  
for(int cx = 0;cx < sizex;cx++){
            for(int cy = 0;cy < sizey;cy++){
               for(int bx = 0;bx < 16;bx++){
                  for(int by = 0;by < 16;by++){
                     if(cy == sizex-1 && by == 15){
                     }else{
                     if(chunks[cx][cy].blocks[bx][by].isWater){
                                 if(by == 15){
                                    if(chunks[cx][cy+1].blocks[bx][0].id == IDS.airBlockID){
                                         chunks[cx][cy+1].blocks[bx][0] = new WaterBlock(...);
                                         chunks[cx][cy].blocks[bx][by] = new AirBlock(...);
                                          chunks[cx][cy].updateVBOTextures();
                                          chunks[cx][cy+1].updateVBOTextures();
                                    }
                                 }else{
                                    if(chunks[cx][cy].blocks[bx][by+1].id == IDS.airBlockID){
                                         chunks[cx][cy].blocks[bx][by+1] = new WaterBlock(...);
                                        chunks[cx][cy].blocks[bx][by] = new AirBlock(...);
                                         chunks[cx][cy].updateVBOTextures();
                                    }
                                 }
                              }
                           }
                  }
               }
            }
         }


My main FPS problem here is this line:
1  
  chunks[...][...].updateVBOTextures();

I am updating VBOs every tick, and it takes too much FPS. I want to ask, how i can avoid this VBOs updating every tick, and still get similar result (i want to see how water falling).
15  Game Development / Newbie & Debugging Questions / Re: VBO with colors on: 2014-02-28 12:52:28
Thank you!
16  Game Development / Newbie & Debugging Questions / VBO with colors on: 2014-02-27 18:22:33
I know basics of VBO's, right now i am rendering my game blocks with VBO, and i am using only vertex array and texture coord array. Right now i am trying to add colors array to VBO, but i am failing in here. Maybe somebody can edit this part of code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
...........           
            glEnableClientState(GL_VERTEX_ARRAY);
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glEnableClientState(GL11.GL_COLOR_ARRAY);
            glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
           
            glVertexPointer(2, GL_FLOAT, 7 << 2, 0);
            glTexCoordPointer(2, GL_FLOAT, 7 << 2, 2 << 2);
            GL11.glColorPointer(3, GL_FLOAT, 7 << 3,4 << 3);
           
            glBindTexture(GL_TEXTURE_2D, Main.texture.id);
            glDrawArrays(GL_QUADS, 0, 20*16*16);
...........


I want to use colors, please help me.
17  Game Development / Newbie & Debugging Questions / Re: VBO with vertex,texCoord and color data on: 2014-01-28 13:11:41
When i am starting this program, i get only my blocks with textures, but no colors (i get only texture colors).
18  Game Development / Newbie & Debugging Questions / VBO with vertex,texCoord and color data on: 2014-01-27 19:30:24
I am trying to add color for each block in my VBO,i already have vertex and texCoord data in my VBO, everything is working perfect. But for some reason i cant add colors.

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  
   
                 data[0] = x*16+xc;
               data[1] = y*16+yc;
               
               data[2] = texCooX;
               data[3] = texCooY;
               data[4] = color.x;
               data[5] = color.y;
               data[6] = color.z;
               
               
               data[7] = x*16+16+xc;
               data[8] = y*16+yc;
               
               data[9] = texCooX + texSize;
               data[10] = texCooY;
               data[11] = color.x;
               data[12] = color.y;
               data[13] = color.z;
               
               data[14] = x*16+16+xc;
               data[15] = y*16+16+yc;
               
               data[16] = texCooX+ texSize;
               data[17] = texCooY+ texSize;
               data[18] = color.x;
               data[19] = color.y;
               data[20] = color.z;
               
               data[21] = x*16+xc;
               data[22] = y*16+16+yc;
               
               data[23] =texCooX;
               data[24] = texCooY+ texSize;
               data[25] = color.x;
               data[26] = color.y;
               data[27] = color.z;


1  
2  
3  
4  
5  
GL11.glColorPointer(3, GL_FLOAT, 7 << 2, 4 << 3);
      glVertexPointer(2, GL_FLOAT, 7 << 2, 0);
      glTexCoordPointer(2, GL_FLOAT, 7 << 2,2 << 2);
      glBindTexture(GL_TEXTURE_2D, Main.textureMicroBlocks.id);
      glDrawArrays(GL_QUADS, 0, 20*16*16);



What i am doing wrong?
19  Game Development / Newbie & Debugging Questions / VBO with multiple textures on: 2013-12-29 14:34:33
It is possible to hold data about "what part of spritesheet i want to render" in floatbuffer? Right now i found only one way to change texture in one VBO:

1  
2  
3  
4  
5  
6  
7  
8  
glBindBuffer(GL_ARRAY_BUFFER, bufferId);
     
      glVertexPointer(3, GL_FLOAT, 5 << 2, 0);
      glTexCoordPointer(2, GL_FLOAT, 5 << 2, 3 << 2);
      glBindTexture(GL_TEXTURE_2D, texture.id);      
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
      glBindTexture(GL_TEXTURE_2D, texture2.id);
      glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);


With this, i can change texture in one VBO, but i think its wrong solution, because i lose so much fps and i must to do it for each quad. So how i can change texture in one VBO?
20  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 12:27:32
I found why that texture not worked! i just forgot to do this:
1  
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
21  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 11:31:29
still not working, but when i am using this tutorial code, textures working perfect.

And i want to ask, should i use two VBOs in one chunk (one for textures, one for vertices). I want each tile in chunk have different textures. And i think i must use spritesheet, or am i wrong?

22  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 09:50:30
I am using this texture load class:
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  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.ByteBuffer;

import javax.imageio.ImageIO;

import org.lwjgl.BufferUtils;
import static org.lwjgl.opengl.GL11.*;

/**
 * An OpenGL Texture.
 *
 * @author Sri Harsha Chilakapati
 */

public class Texture
{
   
    /**
     * Texture ID.
     */

    public int id;
   
    /**
     * Texture width.
     */

    public int width;
   
    /**
     * Texture height.
     */

    public int height;
   
    /**
     * Creates a texture.
     */

    private Texture(int id, int width, int height)
    {
        this.id = id;
        this.width = width;
        this.height = height;
    }
   
    /**
     * Loads a texture from a file.
     *
     * @param name The name of the file.
     */

    public static Texture loadTexture(String name)
    {
        // Load the image
        BufferedImage bimg = null;
        try
        {
            bimg = ImageIO.read(Texture.class.getClassLoader().getResourceAsStream(name));
        }
        catch (IOException e)
        {
            e.printStackTrace();
            System.out.println("Unable to load Texture: " + name);
            Game.end();
        }

        // Gather all the pixels
        int[] pixels = new int[bimg.getWidth() * bimg.getHeight()];
        bimg.getRGB(0, 0, bimg.getWidth(), bimg.getHeight(), pixels, 0, bimg.getWidth());

        // Create a ByteBuffer
        ByteBuffer buffer = BufferUtils.createByteBuffer(bimg.getWidth() * bimg.getHeight() * 4);

        // Iterate through all the pixels and add them to the ByteBuffer
        for(int y = 0; y < bimg.getHeight(); y++)
        {
            for(int x = 0; x < bimg.getWidth(); x++)
            {
                // Select the pixel
                int pixel = pixels[y * bimg.getWidth() + x];
                // Add the RED component
                buffer.put((byte) ((pixel >> 16) & 0xFF));
                // Add the GREEN component
                buffer.put((byte) ((pixel >> 8) & 0xFF));
                // Add the BLUE component
                buffer.put((byte) (pixel & 0xFF));
                // Add the ALPHA component
                buffer.put((byte) ((pixel >> 24) & 0xFF));
            }
        }

        // Reset the read location in the buffer so that GL can read from beginning.
        buffer.flip();

        // Generate a texture ID
        int textureID = glGenTextures();
        // Bind the ID to the context
        glBindTexture(GL_TEXTURE_2D, textureID);

        //Setup texture scaling filtering
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        //Send texture data to OpenGL
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, bimg.getWidth(), bimg.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

        // Return a new Texture.
        return new Texture(textureID, bimg.getWidth(), bimg.getHeight());
    }

}





1  
2  
3  
  glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


1  
  texture = Texture.loadTexture("simpletex.png");


1  
Texture texture;


23  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 09:27:05
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.id);
      GL11.glBegin(GL_QUADS);
            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2f(0, 0);
            GL11.glTexCoord2f(1, 0);
            GL11.glVertex2f(100, 0);
            GL11.glTexCoord2f(1, 1);
            GL11.glVertex2f(100, 100);
            GL11.glTexCoord2f(0, 1);
            GL11.glVertex2f(0, 100);
      GL11.glEnd();
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);


And it appears in top left corner
24  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 09:20:50
still nothing.

maybe you need other part of code?
25  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 09:05:54
1  
2  
3  
4  
5  
6  
7  
8  
9  
 float[] datatex = {
               100, 500, 0f,
               100, 100, 0f,
               500, 500, 0f,
               500, 100, 0f,
               0f, 0f,
               0f, 1f,
               1f, 0f,
               1f, 1f};



1  
2  
3  
4  
5  
6  
7  
glBindBuffer(GL_ARRAY_BUFFER, bufferId);
      glBindTexture(GL_TEXTURE_2D, texture.id);
      glVertexPointer(3, GL_FLOAT, 3 << 2, 0);
      glTexCoordPointer(2, GL_FLOAT, 2 << 2, 12 << 2); vector.
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
      glBindTexture(GL_TEXTURE_2D, 0);
      glBindBuffer(GL_ARRAY_BUFFER, 0);

I think this enough.


And thanks everyone for answers Smiley.

EDIT:
i tried it with immediate mode, everything worked perfect
26  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-29 08:57:17
For some reason i cant apply texture normal, whole quad just fills texture first pixel color.
27  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-28 14:13:53
I want to use something like this:
1  
 glTexCoordPointer(2, GL_FLOAT, 0, 0);
To add textures, and i have chunks with 16*16 tiles.
I want each tile with different texture
28  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-28 13:59:20
Quote
Have you ever played a platformer? Then yes, it's possible.

Have you ever used textures in OpenGL before? It's very easy to convert everything over to a buffer object. You'll need to have a spritesheet though.

I mean i want to change textures using VBO
29  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-28 13:30:10
Google is useless in my opinion, i cant find anything usefull.

I am trying to create platformer with tiles, and i want to store my tiles in chunks. And now i am thinking, it is possible to have chunk with 16*16 tiles and each tile with different texture?
30  Game Development / Newbie & Debugging Questions / Re: How to add vertices to VBO? on: 2013-12-28 11:59:43
I dont care it anymore, i just changed it to quads.

New question:
How to add textures?
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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!