LWJGL
May 24, 2013, 04:09:13 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: 1 2 [3] 4 5 ... 10
 21 
 on: May 20, 2013, 08:13:00 
Started by 8Bit_Jedi - Last post by 8Bit_Jedi
Figured out my camera problem:

Tutorial problem on page: http://lwjgl.org/wiki/index.php?title=The_Quad_with_Projection,_View_and_Model_matrices.

At the bottom of the page at code section Application after line: 107, there is a missing statement: projectionMatrix.m33 = 0;
If you use camera tutorials like Lloyd Goodall [http://www.lloydgoodall.com/tutorials/first-person-camera-control-with-lwjgl/], it doesn't work the camera just dollies around some point in front of it, making you scream why in angre Angry.

Took me a week to notice that missing statement, because I read the lwjgl tutorial and typed out the complete code given at the bottom of the page.

Who do we inform about the missing statement on the tutorial?

 22 
 on: May 20, 2013, 07:05:19 
Started by void256 - Last post by ajr_1
This sounds similar to my issue, see here:

http://lwjgl.org/forum/index.php/topic,4711.msg26339.html#msg26339

I've not been able to figure out how to fix it though. 

 23 
 on: May 20, 2013, 06:18:27 
Started by Yuri6037 - Last post by Fool Running
You need to specify what point of the texture corresponds to each vertex (where 0 represents the left or top and 1 represents the right or bottom).
Try something like:
Code:
    glBegin(GL_QUADS);
    {
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2f(x, y);
        GL11.glTexCoord2f(1, 0);
        GL11.glVertex2f(width + x, y);
        GL11.glTexCoord2f(1, 1);
        GL11.glVertex2f(width + x, height + y);
        GL11.glTexCoord2f(0, 1);
        GL11.glVertex2f(x, height + y);
    }
You might have to flip the Y-values because of the way OpenGL's coordinates work (i.e. (0,0) is normally bottom-left instead of top-left).

 24 
 on: May 20, 2013, 06:10:30 
Started by GenomeGame - Last post by Fool Running
I'm not sure how this is an "Urgent Bug!" Tongue

I would normally just say "Google is your friend", but I'm feeling unusually helpful today:
GL11.glDisable(GL11.GL_TEXTURE_2D);
and
GL11.glEnable(GL11.GL_TEXTURE_2D);


EDIT: Realized you double-posted and someone already answered somewhere else. Undecided

 25 
 on: May 20, 2013, 05:19:25 
Started by Yuri6037 - Last post by Yuri6037
I'm trying to draw a textured quad with LWJGL, but I don't know why my quad renders with only one pixel of color.

This is the first time that i use LWJGL to create a 2D Fullscreen game.

Here's the code used to draw the quad:

    public void drawRect(int x, int y, int width, int height){
    glBegin(GL_QUADS);
    {
        GL11.glVertex2f(x, y);
        GL11.glVertex2f(width + x, y);
        GL11.glVertex2f(width + x, height + y);
        GL11.glVertex2f(x, height + y);
    }
    glEnd();
}
Here's the code for load texture image:

public int getTexture(File f)
{
    Integer integer = textureMap.get(f);

    if (integer != null)
    {
        return integer.intValue();
    }

    try
    {
        singleIntBuffer.clear();
        GLAllocation.generateTextureNames(singleIntBuffer);
        int i = singleIntBuffer.get(0);
        InputStream inputstream = new FileInputStream(f);
        setupTexture(readTextureImage(inputstream), i);
        textureMap.put(f, Integer.valueOf(i));
        return i;
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }

    GLAllocation.generateTextureNames(singleIntBuffer);
    int j = singleIntBuffer.get(0);
    setupTexture(missingTexture, j);
    textureMap.put(f, Integer.valueOf(j));
    return j;
}
    public void setupTexture(BufferedImage par1BufferedImage, int par2)
{
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, par2);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    int i = par1BufferedImage.getWidth();
    int j = par1BufferedImage.getHeight();
    int ai[] = new int[i * j];
    byte abyte0[] = new byte[i * j * 4];
    par1BufferedImage.getRGB(0, 0, i, j, ai, 0, i);

    for (int k = 0; k < ai.length; k++)
    {
        int i1 = ai[k] >> 24 & 0xff;
        int k1 = ai[k] >> 16 & 0xff;
        int i2 = ai[k] >> 8 & 0xff;
        int k2 = ai[k] & 0xff;

        /**
        if (options != null && options.anaglyph)
        {
            int i3 = (k1 * 30 + i2 * 59 + k2 * 11) / 100;
            int k3 = (k1 * 30 + i2 * 70) / 100;
            int i4 = (k1 * 30 + k2 * 70) / 100;
            k1 = i3;
            i2 = k3;
            k2 = i4;
        }
        */

        abyte0[k * 4 + 0] = (byte)k1;
        abyte0[k * 4 + 1] = (byte)i2;
        abyte0[k * 4 + 2] = (byte)k2;
        abyte0[k * 4 + 3] = (byte)i1;
    }

    imageData.clear();
    imageData.put(abyte0);
    imageData.position(0).limit(abyte0.length);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, i, j, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageData);
}
private BufferedImage readTextureImage(InputStream par1InputStream) throws IOException
{
    BufferedImage bufferedimage = ImageIO.read(par1InputStream);
    par1InputStream.close();
    return bufferedimage;
}
Here's the code for binding textures:

    public void bindTexture(int par1)
{
    if (par1 < 0)
    {
        return;
    }
    else
    {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1);
        return;
    }
}
Here's init game code:

    public BrickBroken() {
    renderEngine = new RenderEngine();
    try {
        Display.setDisplayMode(Display.getDesktopDisplayMode());
        Display.setTitle("Brick Broken");
        Display.sync(300);
        Display.setFullscreen(true);
        Display.create();
        initOpenGL();
        loop();
    }catch (LWJGLException e){
        e.printStackTrace();
        System.exit(0);
    }

    //startGame();
}


   private void loop(){
    while(!Display.isCloseRequested()){
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        runTick();
        Display.update();
    }
    Display.destroy();
    closeGame();
}

private void runTick(){
    File background = new File(BrickBroken.getGameDir() + File.separator + "ressources" + File.separator + "imgs" + File.separator + "brickStone_state0.png");
    int i = renderEngine.getTexture(background);
    renderEngine.bindTexture(i);
    renderEngine.drawRect(20, 20, 100, 50);
}

private void initOpenGL(){
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, getScreenWidth(), getScreenHeight(), 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
I have tried many things for rendering textured quads for this game. This is a "break the brick" game who can play with DataInputStream used for multiplayer.

In the paste I have created this game using JAVA2D and javax.swing, but due to lags and compatibility problems on Windows Non Areo Systems (XP, ...) and with some Linux and Mac I've decided to reconstruct the rendering code with LWJGL.

Can you help me?

 26 
 on: May 20, 2013, 02:07:42 
Started by badlogic - Last post by kappa
Hmm, slightly cross at the response the OP got on #lwjgl though. Is there a transcript and can the transgressors be hung by the toenails until sorry?

Cas Smiley
Transcript at 21:43, no surprise at who the perpetrator was.

If I was to guess I'd say its a nvidia driver bug, anyway tried here but can't reproduce it on my nvidia card (although using latest stable nvidia driver as opposed to experimental). Anyway there was a change in the way xrandr 1.4 parses display settings recently, so maybe OP might have some luck with the latest nightly build of LWJGL.

 27 
 on: May 20, 2013, 01:55:51 
Started by fiendfan1 - Last post by quew8
The only way to do shininess with the fixed functionality is to render one face at a time, switching the shininess between (it makes no sense to do it per vertex, that's why it's a uniform). If you are using your own shaders however, you could make a custom attribute variable  and add the data to your vbo, or potentially even better - use the alpha channel of your colour as a shininess. This also works if you are using textures provided that you aren't using the alpha channel.

As for the individual texture for each face, I think you might be confused because it really makes no difference whether you are in immediate mode or are using vbos.

 28 
 on: May 20, 2013, 01:06:27 
Started by badlogic - Last post by princec
Hmm, slightly cross at the response the OP got on #lwjgl though. Is there a transcript and can the transgressors be hung by the toenails until sorry?

Cas Smiley

 29 
 on: May 19, 2013, 20:59:41 
Started by RiverC - Last post by RiverC
The clamping needs a little work, sometimes you're seeing angles on the composites that make for awkward visuals. Particularly, it seems that at the 45 degree pitch and 45 degree yaw position you see the top or bottom part. This is probably because the clamping for each dimension doesn't depend on the value of the other dimension (giving the space you see the 'top' a square shape rather than a round one like it should have.) i.e
Code:
float fudge_factor = .4;
int direction = 0;

if(n.x < -fudge_factor) {
   direction | back_bit;
} else if (n.x > fudge_factor) {
   direction | front_bit;
}

if(n.y < -fudge_factor) {
  direction | right_bit;
} else if (n.y > fudge_factor) {
  direction | left_bit;
}

if(n.z < -fudge_factor) {
  direction | bottom_bit;
} else if (n.z > fudge_factor) {
  direction | top_bit;
}

return direction;
This gives you any of 26 possible directions; Seems the eye expects the top images to show up later at 45-degree angles than this simple clamping gives me. Another possibility is I need another layer of angled images closer to the top view, which isn't my favored solution but might be the way to getting the sprites to have a production quality appearance from all directions.

Additionally, I've noticed when the sprites are at the edges of a perspective view, some skew needs to be applied to the quads or the parts look disjointed. I'll have to look into how to get the right amount of skew...

 30 
 on: May 19, 2013, 18:59:13 
Started by fiendfan1 - Last post by fiendfan1
I Just found the function glColorPointer() , so I can do colors.

Still have no idea on shininess.

Pages: 1 2 [3] 4 5 ... 10
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!