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  Game Development / Newbie & Debugging Questions / Re: how to apply graphic filters to rendered image in OpenGL? on: 2013-09-05 08:28:13
Sorry, I have not watched it yet, so any reference must be unintentional Cheesy
2  Game Development / Newbie & Debugging Questions / Re: how to apply graphic filters to rendered image in OpenGL? on: 2013-09-04 18:51:47
Thank you!
3  Game Development / Newbie & Debugging Questions / how to apply graphic filters to rendered image in OpenGL? on: 2013-09-04 16:22:42
Hi all,

I am wondering, what is the best (most performative and good results) way to apply some basic graphic manipulations like Brightness, Contrast, Noise etc. to a rendered image in OpenGL?

Thanks!
4  Game Development / Newbie & Debugging Questions / animated custom mouse cursor in LWJGL on: 2013-08-04 10:54:25
Hi all,

I have been trying some hours now and searching the forums, but I can't get my own custom Mouse Cursor Animation working in LWJGL.
Please take a look.

Here is my Code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
private static Cursor getCursor() throws IOException, LWJGLException{
     int cursorWidth  = 32;
     int cursorHeight = 32;
     int numImages= 16;
     // note that image needs to be flipped, because OpenGL and image formats disagree about the coordinate system
     BufferedImage img = ImageIO.read(new File("data/img/input/mouseCursor.png"));
     int[] rgbs = new int[cursorWidth*cursorHeight];
     IntBuffer imageBuffer = IntBuffer.allocate(img.getWidth()*img.getHeight()/16*numImages);
     IntBuffer delays        = IntBuffer.allocate(cursorAmount);
     for( int y = 0; y < img.getHeight()/cursorHeight; y++){
        for (int x = 0; x < img.getWidth()/cursorWidth; x++){
           if( y*(img.getWidth()/cursorWidth)+x < numImages){
              imageBuffer.put(img.getRGB(x*cursorWidth, y*cursorHeight, cursorWidth, cursorHeight, rgbs, 0, cursorWidth));
              delays.put(100);
           }
        }
     }
     imageBuffer.rewind();
     delays.rewind();
     System.out.println(cursorWidth*cursorHeight*numImages+" "+imageBuffer.remaining());
     return new Cursor(cursorWidth,cursorHeight,0,cursorWidth-1,numImages,imageBuffer,delays);//,delays);
  }


When I run it, it gives me the following Error:
java.lang.IllegalArgumentException: width*height*numImages > images.remaining()

It is an error, that is thrown by the Cursor Constructor:
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 Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
      synchronized (OpenGLPackageAccess.global_lock) {
         if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
         images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
         if (delays != null)
            delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
         if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
         if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
         if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
         if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

         Sys.initialize();

         // Hmm
         yHotspot = height - 1 - yHotspot;

         // create cursor (or cursors if multiple images supplied)
         cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
      }
   }


But note, that my console output says for width*height*numImages 16384 and for images.remaining() it says also 16384, so why does it trigger the error?

When I use only one Cursor and set delays to null, it is working by the way. The problem only occurs with more then 1 cursor images....

Thank you!
5  Java Game APIs & Engines / OpenGL Development / Re: cant get a 2D Camera in LWJGL working (beginner) on: 2013-07-19 10:10:20
The code example you gave me works great! Also the sites you linked me seem to be amazing. It will take quite some time, to go through these, but at least I know, that this is the "real deal" (not some deprecatet concepts).
Also, I was told over at the LWJGL Forum, that you made the lwjgl-basics library including the spriteBatcher. I went through quite some of your tutorials before and they are really excellent. They helped me out a lot to set foot on this ground. So thank you very much for those, too Cheesy
6  Java Game APIs & Engines / OpenGL Development / Re: cant get a 2D Camera in LWJGL working (beginner) on: 2013-07-18 17:52:42
Thank you very much davedes, that is some very useful information.
I will try to get my head around the matrix stuff and take LibGDX as an emergency exit, if it proves to be too hard Smiley
7  Java Game APIs & Engines / OpenGL Development / cant get a 2D Camera in LWJGL working (beginner) on: 2013-07-18 13:29:54
Hi all,

I am working on a 2D Game and I try to set up a simple camera for it (just moving and zooming).
Unfortunatly, I don't get it working at all.
Since I am new to LWJGL and OpenGL in general I have no idea, if I am missing out on something very basic
or if the problem is more complex.

With my googling I found out that there are 3 approaches:
1.) Use glScalef and glTranslatef (this seems to be very easy... in theoriy...)
2.) Use gluLookAt and gluPerspective (this seems to be more sophisticated, but maybe too much for a 2D Game?)
3.) Hardcode the "camera" position and zoom level into each draw call (now that seems to be a terrible way to go, even though I am sure I could do that...)

The most effort so far I put into the glScalef and glTranslatef approach.
My code is compiling, but neither the scaling nor the translating has any
effect on the screen.

Maybe somebody can take a look at my code and help me out

So here is my code:
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  
// called once at start
protected void create() {
      // Enable blending
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   // enable textures since we're going to use these for our sprites
      glEnable(GL_TEXTURE_2D);
       
      // disable the OpenGL depth test since we're rendering 2D graphics
      glDisable(GL_DEPTH_TEST);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
       
      glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glViewport(0, 0, WIDTH, HEIGHT);
      // Set clear to transparent black
      glClearColor(0f, 0f, 0f, 0f);
}

// called every frame
protected void render(){
    // Clear the screen
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    float centerX = WIDTH * 0.5f;
    float centerY = HEIGHT * 0.5f;
    //Move to center of scene
    glTranslatef(centerX,centerY,0);  
    //Scale at center
    glScalef(2,2,1);          
    //Move back to origin
    glTranslatef(-centerX,-centerY,0);
    glPushMatrix();
      // ... render our game here ...
      spriteBatch.begin();
                         // next line is Pseudo-Code, but this is the way i draw all my graphics.
                         // I pass the spriteBatch to all my Entities, and they are drawn in the fashion shown below
               spriteBatch.draw( textureRegion, x, y, width, height );
      spriteBatch.end();
     glPopMatrix();
}


The SpriteBatch I use is not by me.
I use this one here: https://github.com/mattdesl/lwjgl-basics/blob/master/src/mdesl/graphics/SpriteBatch.java
Might it be the source of my problem? I tried to wrap my head around what actually is happening in that SpriteBatch,
but it is way beyond me Sad

8  Game Development / Newbie & Debugging Questions / Re: Best approach to do OpenGL 3D Animation on: 2013-07-10 09:35:04
ok, thank you! I'll check out the engines and start from there
9  Game Development / Newbie & Debugging Questions / Re: Best approach to do OpenGL 3D Animation on: 2013-07-09 22:39:13
Ok, I see. You got any tip for me on where to start? I can do some basic modeling, but have no idea on the data type I have to export from my 3d software. And also I don't know how to import it with Java and OpenGL Sad
10  Game Development / Newbie & Debugging Questions / Re: Best approach to do OpenGL 3D Animation on: 2013-07-09 21:01:17
Its 3D, but I read that bone or skeleton animation is only recommended for fancy animations, with real physics and so on. A standard walk cycle should be faster and easier with keyframe animation (thats what i read)
11  Game Development / Newbie & Debugging Questions / Best approach to do OpenGL 3D Animation on: 2013-07-09 15:50:26
Hey all,

I am new to OpenGL. So far, I went through some basic stuff and I can create simple geometries and textures now. Next up, I want to create some simple animations (e.g. walk-cycle). I did some hours of google search and what I found so far is, that you can do either a keyframe or a skeleton animation. Since keyframe animation seems to be easier and totally sufficient for my needs, I tend to go with that. What I know so far is, that you store vertices, normals and texture-coordinates of at least 2 different states and interpolate between them.
Now here are my questions:
1. Is it better to hardcode each keyframe or to use some 3D modelling software (e.g.Blender) exports? What is the RIGHT way to do it? I know it probably depends on what you want to do, but if you were to make a character walk cycle animation, which approach would you choose?
2. In both cases, can anyone supply me with some resources on how to do it exactly?

Thank you very much in advance
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 (54 views)
2014-11-26 15:22:04

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

toopeicgaming1999 (8 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 (26 views)
2014-11-25 11:26:43

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

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

xFryIx (75 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!