Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-07 18:14:11
That's great.
Thanks! Smiley
2  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-06 20:31:41
Yes, it's working.

Is there a site or something else where I can inform me about this (how the texture coordinates work)?
3  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-06 08:38:02
you're my hero!
Thank you very much! Smiley
4  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-05 17:26:30
I want to draw 100% of my texture (the whole texture).
The only thing is that the texture has an destination size of 40x40 (but 100% of the textures area in the destination squad, just scaled).
do the texture coords also has to be scaled down?
as said before:
Quote
The texture is stretched or shrunk to fit the vertex coordinates.

I'm not as advanced as I want to be in opengl.
But I'm working on it. Grin
5  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-05 12:07:04
Well...
I've 2 ways to initialize a image.

1. way: use the textures default width and height.
2. way: give 2 additional parameters (width and height).
so instead of adding texture.getWidth() to the vertex buffer I add the width.

so i initialize a image like: new Image("path", sizex, sizey)

that' how a image is "scaled".
6  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-04 18:04:06
Thank you for the answer!

40f/60 will just cut the image.
But I tried it: the image was cut and there was the problem again (wtf).

i have an 64x64 image that's scaled down to 40x40.
7  Games Center / WIP games, tools & toy projects / Re: Pseudo Voxel Expriements on: 2013-04-03 16:23:54
Very impressive!
I like the graphic and the idea. Cheesy
8  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-03 15:30:12
first of all thank you!
i changed it Grin

so, here's how i generate the coords:
An IntBuffer for the vertices:
1  
IntBuffer vertexBuffer = BufferUtils.createIntBuffer(8);

initializing:
1  
2  
3  
4  
5  
vertexBuffer.put(new int[] {0, 0,
                                      texture.getWidth(), 0,
                                      texture.getWidth(), texture.getHeight(),
                                      0, texture.getHeight()});
        vertexBuffer.flip();

texture is my texture (who knew that), which holds the height and width (64x64 in my case; when rendering it is about 40x40).

and the texture buffer:
1  
FloatBuffer textureBuffer = BufferUtils.createFloatBuffer(8);

initializing:
1  
2  
3  
4  
5  
textureBuffer.put(new float[] {0, 0,
                                      1, 0,
                                      1, 1,
                                      0, 1});
        textureBuffer.flip();


maybe it might help:
1  
2  
Image tile = availableTiles[tileLayer1[i][j]-1];
tile.draw((int)(i*tileSize + offsetX), (int)(j*tileSize + offsetY));

It's how a tile is drawn.
Image is a class which holds the texture + buffers and draws the image.
9  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-02 18:29:28
So...

Here's the TextureLoader:
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  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
public class TextureLoader {
    /* singleton */
    private static TextureLoader instance;
    /* Contains the path of the Texture and the Texture itself */
    private HashMap<String, Texture> textureMap;
    /* the color models for alpha and non-alpha images */
    private ColorModel glAlphaColorModel;
    private ColorModel glColorModel;

    // initialize fields
    private TextureLoader() {
        textureMap = new HashMap<String, Texture>();
        glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                new int[]{8, 8, 8, 8},
                true,
                false,
                ComponentColorModel.TRANSLUCENT,
                DataBuffer.TYPE_BYTE);

        glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                new int[]{8, 8, 8, 8},
                false,
                false,
                ComponentColorModel.OPAQUE,
                DataBuffer.TYPE_BYTE);
    }
   
    // return the singleton
    public static synchronized TextureLoader getInstance() {
        if (instance == null) {
            instance = new TextureLoader();
        }
        return instance;
    }

    public Texture load(String path) throws IOException {
        Texture texture = textureMap.get(path);

        if (texture == null) {
            texture = getTexture(path,
                    GL11.GL_TEXTURE_2D,
                    GL11.GL_RGBA,
                    GL11.GL_LINEAR,
                    GL11.GL_LINEAR);

            textureMap.put(path, texture);
        }

        return texture;
    }

    private Texture getTexture(String path, int target, int dstPixelFormat, int minFilter, int magFilter) throws IOException {
        int srcPixelFormat;
        int textureID = createTextureID();

        Texture texture = new Texture(target, textureID);

        GL11.glBindTexture(target, textureID);

        BufferedImage image = ImageLoader.load(path);
        texture.setWidth(image.getWidth());
        texture.setHeight(image.getHeight());

        boolean hasAlpha = image.getColorModel().hasAlpha();
        if (hasAlpha) {
            srcPixelFormat = GL11.GL_RGBA;
        } else {
            srcPixelFormat = GL11.GL_RGB;
        }

        ByteBuffer buffer = convertImageData(image, texture, hasAlpha);

        if (target == GL11.GL_TEXTURE_2D) {
            GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
            GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
        }

        GL11.glTexImage2D(target,
                0,
                dstPixelFormat,
                Number.getPowerOfTwo(2, image.getWidth()),
                Number.getPowerOfTwo(2, image.getHeight()),
                0,
                srcPixelFormat,
                GL11.GL_UNSIGNED_BYTE,
                buffer);

        return texture;

    }

    private int createTextureID() {
        return GL11.glGenTextures();
    }

    private ByteBuffer convertImageData(BufferedImage image, Texture texture, boolean hasAlpha) {
        ByteBuffer buffer;

        WritableRaster raster;
        BufferedImage textureImage;

        int textureWidth = Number.getPowerOfTwo(2, image.getWidth());
        int textureHeight = Number.getPowerOfTwo(2, image.getHeight());

        texture.setTextureWidth(textureWidth);
        texture.setTextureHeight(textureHeight);

        int bands = 3;
        ColorModel textureColorModel = glColorModel;

        if (hasAlpha) {
            bands = 4;
            textureColorModel = glAlphaColorModel;
        }

        raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
                textureWidth,
                textureHeight,
                bands,
                null);
        textureImage = new BufferedImage(textureColorModel, raster, false, new Hashtable());

        Graphics g = textureImage.createGraphics();
        g.setColor(new Color(0, 0, 0, 0));
        g.fillRect(0, 0, textureImage.getWidth(), textureImage.getHeight());
        g.drawImage(image, 0, 0, textureImage.getWidth(), textureImage.getHeight(), null);

        byte[] data = ((DataBufferByte) textureImage.getRaster().getDataBuffer()).getData();

        int dataLength = data.length;

        buffer = ByteBuffer.allocateDirect(dataLength);
        buffer.order(ByteOrder.nativeOrder());
        buffer.put(data, 0, dataLength);
        buffer.flip();


        return buffer;
    }
}


That's how I draw the texture.

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  
GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
       
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       
       
        if(rotation != 0) {
            GL11.glPushMatrix();
            GL11.glTranslatef(centerX, centerY, 0);
            GL11.glRotatef(rotation, 0, 0, 1);
            GL11.glTranslatef(-centerX, -centerY, 0);
        }
       
        GL11.glVertexPointer(2, 0, vertexBuffer);
        GL11.glTexCoordPointer(2, 0, textureBuffer);
       
        GL11.glDrawArrays(GL11.GL_QUADS, 0, 4);
       
        if(rotation != 0) {
            GL11.glPopMatrix();
        }
       
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glDisable(GL11.GL_TEXTURE_2D);


I want to solve the problem as soon as possible, cause its annoying to test with it.
I've really no idea what the problem is or how to solve it.

A image was posted before, hope this is enough illustrative material.
10  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-04-01 09:23:34
The problem seemed to be solved, but it isn't.  Angry
When I scale the tiles with glScalef(...) it does not render correct.
The background image is scaled over the whole window and the lowest row of pixels is also at the top too.
Is it a problem to scale images?
Cause I get the same problem with slick2d.

Hope someone can help.
11  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-03-27 19:54:12
The texture reader should not be the problem, 'cause the error occurred as well as I used Slick2D.
But thank deepthought for the hint. Well, actually it was the draw method.
I was drawing the image with floating coord values but as it seems there is no problem if i use integer values.

Think I can close the topic.

Thank you for the answers! Smiley
12  Java Game APIs & Engines / OpenGL Development / Re: Strange rendering fail on: 2013-03-27 15:00:28
It is doing it every time drawing a tile.
I have an array of integers which represents the index of an array of images.
e.g.:
int index = tilemap[xCoord][yCoord];
images[index].draw();
I also tried that code with Slick2D, same error.
13  Java Game APIs & Engines / OpenGL Development / Strange rendering fail on: 2013-03-26 21:28:40
Hi guys!

Currently I'm setting up the basic level rendering.
But a strange error occurred: the tile image bottom line shows at the top of the tile (source image size: 64x64).
the y-coords (i think): 64, 1, 2, 3, ...
I also searched on google, but the solution does not work, 'cause my images ARE pot-sizes.

Does someone know a solution?

Here's a image of the problem:
http://imageshack.us/photo/my-images/854/renderingfail.png/
14  Discussions / Business and Project Management Discussions / Re: Copyright for games on: 2013-03-26 20:00:28
Thank you for the answers!

Well, if I'm going to use a library or something else (lets say Slick2D, LWJGL, etc...), what should I do to be on the right side?
I don't want to get problems with them (needless to say). Grin
15  Discussions / Business and Project Management Discussions / Re: Copyright for games on: 2013-03-19 19:35:37
Thank you guys!
This was/is very important for me and (i think) also for other developers! Cheesy
16  Discussions / Business and Project Management Discussions / Copyright for games on: 2013-03-19 14:50:47
Hello everybody!

I'm new here and this is my first post.
The question is (as you might think) how to protect the game and its idea.

I read, that I'll get the copyright (more or less), as soon as I start developing my game.
Is that right and is that enough to protect my game?

How do I "present" the copyright?
Now it is at the top of every file in the project.


Lukas
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.

toopeicgaming1999 (64 views)
2014-11-26 15:22:04

toopeicgaming1999 (57 views)
2014-11-26 15:20:36

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (28 views)
2014-11-25 11:26:43

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

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

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

digdugdiggy (52 views)
2014-11-12 21:11:50
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!