Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
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 [3] 4 5 ... 7
61  Java Game APIs & Engines / OpenGL Development / Re: Generating Textures on: 2005-11-30 03:17:29
 Grin Big pixels would actually be perfect for what we're trying to do!!  I'll have to wait until tomorrow to try out the rest of it!  Thank you!!!!
62  Java Game APIs & Engines / OpenGL Development / Re: Generating Textures on: 2005-11-29 20:43:50
Ok, I have it working ... sort of.  I am still pretty clueless when it comes to textures and I have never used mipmaps before, so please bear with me!  The texture that I created is a simulated weather pattern that I want to be able to zoom in on, but it takes a really long time (~5 sec.) to create the mipmap and when I zoom in it gets really fuzzy.  So I have three questions, 1) is there a better way to create a mipmap?  2) Is there a setting to allow it to look better at higher zoom levels?  3) There isn't any transparency, how do I create that?

Here's the code I have so far and some screenshots:
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  
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1.0);

GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LEQUAL);

GL11.glEnable(GL11.GL_LINE_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(45f, (float)mode.getWidth()/(float)mode.getHeight(), 0.1f, 100f);

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());

...

byte[] data = ((DataBufferByte) weatherImage.getRaster().getDataBuffer()).getData();
imageBuffer = ByteBuffer.allocateDirect(data.length);
imageBuffer.order(ByteOrder.nativeOrder());
imageBuffer.put(data, 0, data.length);
imageBuffer.flip();

GL11.glGenTextures(weatherTexture);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, weatherTexture.get(0));
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

// when texture area is small, bilinear filter the closest mipmap
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
// when texture area is large, bilinear filter the original
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
// the texture wraps over at the edges (repeat)
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

// build our texture mipmaps
GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, width, height, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageBuffer);




63  Java Game APIs & Engines / OpenGL Development / Generating Textures on: 2005-11-29 17:04:50
I have a ByteBuffer that I pulled from a BufferedImage that I need to convert into a texture.  I have seen the code to do that somewhere, but for the life of me I can't seem to find it now!  Does anyone know where I can look for this?
64  Game Development / Newbie & Debugging Questions / Re: preloading stuff with lwjgl/ogl on: 2005-11-18 16:08:53
You need to have a shared gl context.  I did some messing around with pre loading a while back.  Here is what I found out.
65  Java Game APIs & Engines / OpenGL Development / Re: Trouble with gluUnproject on: 2005-11-16 15:37:07
Ahhh, I was just using get()!   Thank you!
66  Java Game APIs & Engines / OpenGL Development / Re: Trouble with gluUnproject on: 2005-11-16 14:17:00
Just to be sure that I understand, I should use GL_FLOAT and then pass it a ByteBuffer?  Because according to the lwjgl javadoc, my only options are a ByteBuffer, and IntBuffer and a ShortBuffer.

-=EDIT=-
It can't be ByteBuffer, it complied fine, but it always returns 0.
67  Java Game APIs & Engines / OpenGL Development / Re: Trouble with gluUnproject on: 2005-11-15 18:58:07
Ok, I have found out that I am an idiot!  I just read in the Red Book that the winZ value must be between 0 and 1, I was using the actual dpeth that I was drawing!  So now I am trying to read the depth from the DepthBuffer using  glReadPixels(), but I am not understanding it either!  Here is what I am doing:
1  
2  
3  
4  
5  
6  
7  
private IntBuffer winZ = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
...
winZ.rewind();
GL11.glReadPixels(mouseX, mouseY, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_INT, winZ);
GLU.gluUnProject((float)mouseX, (float)mouseY, winZ.get(), modelArray, projectionArray, viewportArray, oldResult);
 winZ.rewind();
System.out.println("Z="+winZ.get()+"\t("+oldResult[0]+","+oldResult[1]+")");

and it is returning 2147483647, which is most definately not between 0 and 1!   Huh
68  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-15 16:31:06
 Sad Ok, so I guess it's back to trying to figure out how to convert that equation into a matrix!
69  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-15 15:59:36
Unfortuantely I can't guarantee anything about the hardware so it looks like I am off to asm land!  I have a lot of reading to do! Smiley
70  Java Game APIs & Engines / OpenGL Development / Re: Trouble with gluUnproject on: 2005-11-15 15:07:42
Here is the code in my initGL() method:
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  
private void initGL()
 {
     try
     {
          setVSyncEnabled(true);
     }
     catch (LWJGLException e1)
     {
          System.err.println("Unable to enable VSync: " + e1);
     }
     GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
     GL11.glClearDepth(1.0); // Depth Buffer Setup

     GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
     GL11.glDepthFunc(GL11.GL_LEQUAL); // The Type Of Depth Testing To Do

     GL11.glEnable(GL11.GL_CULL_FACE);

     // Really Nice Perspective Calculations
     GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_FASTEST);
     GL11.glEnable(GL11.GL_LINE_SMOOTH);
     GL11.glLineWidth(1.0f);

     GL11.glEnable(GL11.GL_BLEND);
     GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

     viewportInit();
}

And here is where I initialize the viewport, there is a bit of weirdness due to te fact that I have multiple viewports to create a Picture-in-a-Picture effect.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
private void viewportInit()
{
     GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
     GL11.glLoadIdentity(); // Reset The Projection Matrix
     // Calculate The Aspect Ratio Of The Window
     width = getWidth();
     height = getHeight();

     viewMaxX = (int)(width*0.75f);
     viewMinX = (int)(width*0.05f);
     viewMaxY = (int)(height*0.75f);
     viewMinY = (int)(height*0.05f);

     for(int i = 0; i < 7; i++)
     {
          if(viewWidth[i] == 0) viewWidth[i] = width/5;
          if(viewHeight[i] == 0) viewHeight[i] = height/5;
     }

     GLU.gluPerspective(45.0f, (float)width/(float)height, 0.1f, 2000.0f);
     GL11.glViewport(0, 0, width, height);
     GL11.glMatrixMode(GL11.GL_MODELVIEW); // Select The Modelview Matrix
     GL11.glLoadIdentity();
}
71  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-15 15:01:27
I read that vertex programs bypass the standard transform and lighting instructions.  What exactly does that mean?  For example if I wrote a vertex program to perform the projection calculations that I need would I still be able to move the projected drawing around using glTranslate()?
72  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-15 13:05:17
That's cool, I actually miss asm! Wink Thank you for the tip!  I am very excited to see how it goes!
73  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-15 02:27:34
Do all cards support that?  We are already making a Java2D version and an OpenGL version incase the client machine is too out-dated.  Other than that concern it sounds like an awesome idea!  I am very keen to know how well vertex shaders are supported!
74  Java Game APIs & Engines / JOGL Development / Re: Vector Graphics Support on: 2005-11-14 22:41:38
Do you mean the SVG format, or vector graphics in general?  If you mean in general then absolulely!  In fact everything that you draw in OpenGL that is not a texture and doesn't use the drawPixel() method is a vector graphic!  If you mean the SVG format then you'll need to write a loader fot that, but it should be pretty straight forward!
75  Game Development / Shared Code / Re: Color Picker source code on: 2005-11-14 20:43:58
That's a very cool tool!  Thank you!  Grin
76  Java Game APIs & Engines / OpenGL Development / Re: Trouble with gluUnproject on: 2005-11-14 17:12:56
I have tried using a z of zero, -300, +300 and always I get the same values!!!  Does anyone have an example of this actually working that they could post?
77  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-14 16:12:06
Just the fact that you tried is awesome!  Thank you!  Grin
78  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-13 20:19:27
If you could post what you have I would LOVE to see it.  Even calculating k' twice per change is better than what we do now!  We have to go through and calculate k', x and y 80,000 times!
79  Games Center / Archived Projects / Re: 3D Engine and Demo with some nice effects on: 2005-11-11 16:27:49
VERY NICE!  Even on my crappy work PC with an onboard graphics card it managed a smooth 35 fps!   Shocked  And it looked beautiful!  The flashlight was super-sweet!  Great Work!
80  Game Development / Artificial Intelligence / Re: Projection Matrix on: 2005-11-11 16:10:20
I think that's correct too!  The problem is that the equation is not that simple!  It's meant to translate the current point of a map as a Latitude/Longitude pair into an (x, y) screen location based on a center point, also in Lat/Long.  Different center points are the same as spinning a globe to look at different points on the Earth.  Now we do the whole thing in software, so that any time someone wants to spin the world we have to go through the entire list of points (currently around 80,000) and apply the new projection.  The way it works currently is ok but I thought that if we could convert this equation into matrix form we could put it in the Projection Matrix and do it all in hardware.  That way when the user wanted to spin the globe all we would need to do would be to re-calculate that matrix and the rest would happen auto-magically.

Here are a couple of screenshots to show what I am talking about:
Here the center point is in the middle of the US


Here the center point is in Europe


And here is the equation that we use
81  Game Development / Artificial Intelligence / Projection Matrix on: 2005-11-10 21:11:34
This is most likely the wrong place for this, but I couldn't think of a better one.  Does anyone know of any place that I can look for help in translating an equation into a matrix?  See, I have a set of equations for calculating a projection and I want to translate that into matrix form so I can lod it into the projection matrix, but my linear algebra is pretty week!
82  Game Development / Newbie & Debugging Questions / Re: TextArea 12 - Me - 0 on: 2005-11-10 20:58:57
Yeah, if you like you can do a
1  
JFrame textFrame = new JFrame();

then set the attributes and add the JTextArea and set it to visible when you want someone to talk and then not visible when they are done.
83  Game Development / Newbie & Debugging Questions / Re: TextArea 12 - Me - 0 on: 2005-11-10 20:47:08
You should be able to add the relevant stuff from the constructor to your init() method
1  
2  
3  
4  
currMessage = new JTextArea(5, 35);
currMessage.setLineWrap(true);
currMessage.setWrapStyleWord(true);
currMessage.setCaretColor(Color.WHITE);

and then add the stuff in the run() method to to your render() method.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
if(time == 0 || System.currentTimeMillis() >= time)
 {
        if(currLetter <= message.length())
        {
                currMessage.setText(message.substring(0, currLetter));
                currLetter++;
                time = System.currentTimeMillis() + 75;
        }
        else
        {
                break;
        }
}

You'll also have to decare the variables, but that should work!   I just did it that way to have a fully functional (well mostly functional  Embarrassed ) example.
84  Game Development / Newbie & Debugging Questions / Re: TextArea 12 - Me - 0 on: 2005-11-10 20:05:05
Weird, it ran fine for me!  As far as a JFrame vs. a JApplet, the repaint speed shouldn't be any different.  Did it run ok (other than the exception) as a JFrame?
85  Game Development / Shared Code / Re: Some code.. on: 2005-11-10 19:53:55
That's AWESOME!  Grin  Thank you so much for your generosity!  Those files represent a lot of work and an immense knowledgebase and will provie for and excellent resource for me as well as many others I am sure!
86  Java Game APIs & Engines / OpenGL Development / Trouble with gluUnproject on: 2005-11-10 18:00:07
I am drawing a flat image in an XY plane.  In the example that I posted z[0] is the z value of that plane.  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  
projectionBuff.rewind();
modelBuff.rewind();
viewportBuff.rewind();

GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionBuff);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelBuff);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewportBuff);

modelBuff.get(modelArray[0]);
modelBuff.get(modelArray[1]);
modelBuff.get(modelArray[2]);
modelBuff.get(modelArray[3]);

projectionBuff.get(projectionArray[0]);
projectionBuff.get(projectionArray[1]);
projectionBuff.get(projectionArray[2]);
projectionBuff.get(projectionArray[3]);

viewportBuff.get(viewportArray);
GLU.gluUnProject((float)mouseX, (float)mouseY, z[0], modelArray, projectionArray, viewportArray, oldResult);
System.out.println("("+oldResult[0]+","+oldResult[1]+")");

The trouble is that I am always getting really small results usually between 1.001E-6 and 7.5E-5.  What am I doing wrong?
87  Java Game APIs & Engines / OpenGL Development / Zoom on mouse on: 2005-11-09 20:44:57
Ok, here's what I am trying to accomplish.  Have you seen those applications that zoom around the mouse?  AutoCAD is a really good example.  The page doesn't center on the mouse but the pointer is the focal point for the zooming action.  I have a program that displays map data on and AWTGLCanvas and I need to implement that same kind of thing.  Here is my idea (feel free to shoot this idea down (In fact please do there has got to be a better way)):

1. Get the mouse location from the MouseEvent
2. Translate that to world coords
3. Zoom
4. Get the new screen coords of where the mouse had been pointing
5. Adjust to reconcile the difference vetween the two sets of screen coords

Now in pseudo-code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
Do you think that'll work?
oldX = mouseEvent.getX();
oldY = mouseEvent.getY();
gluUnProject((float)oldX, (float)oldY, zoomLevel, modelArray, projectionArray, viewportArray, result);
worldX = result[0];
worldY = result[1];
zoom();
gluProject(worldX, worldY, zoomLevel,  modelArray, projectionArray, viewportArray, result);
newX = result[0];
newY = result[1];
pan(newX - oldX, newY - oldY);
88  Game Development / Newbie & Debugging Questions / Re: TextArea 12 - Me - 0 on: 2005-11-08 23:29:48
If you are using a TextArea you won't need to override the paint().  That's only if you want to draw with a Graphics object or otherwise alter the default repaint behavior.
89  Game Development / Newbie & Debugging Questions / Re: TextArea 12 - Me - 0 on: 2005-11-08 19:21:49
Here is an altered version of the other example I posted.  Hope this helps!
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  
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JTextArea;

public class TypeWriter extends JFrame implements Runnable
{
   private final String message = "This is your mission, should you choose to accept it:\nFind the Princess and bring her back to the castle where she will be safe from the evil Oompa-Loompas.  Then kill as many of those little bastards as you can!";
   private JTextArea currMessage;
   private int currLetter = 0;
   private Thread thread;
   private long time = 0;
   
   public static void main(String[] args)
   {
      new TypeWriter();
   }

   public TypeWriter()
   {
      addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent we)
         {
            stop();
            System.exit(0);
         }
      });
      setLayout(new FlowLayout());
      currMessage = new JTextArea(5, 35);
      currMessage.setLineWrap(true);
      currMessage.setWrapStyleWord(true);
      currMessage.setCaretColor(Color.WHITE);
      add(currMessage);
      setSize(400, 120);
      setTitle("Evil Oompa-Loompas!");
      setVisible(true);
      start();
   }
   
   public void run()
    {
        Thread me = Thread.currentThread();
        while (thread == me)
        {
           if(time == 0 || System.currentTimeMillis() >= time)
           {
              if(currLetter <= message.length())
              {
                 currMessage.setText(message.substring(0, currLetter));
                 currLetter++;
                 repaint();
                 time = System.currentTimeMillis() + 75;
              }
              else
              {
                 break;
              }
           }
           else
           {
              try
              {
                 Thread.sleep(50);
              }
              catch(InterruptedException ie)
              {}
           }
        }
        thread = null;
    }
   
   public void start()
    {
       thread = new Thread(this);
       thread.setPriority(Thread.MIN_PRIORITY);
       thread.start();      
    }

    public void stop()
    {
       thread = null;
    }
}
90  Game Development / Newbie & Debugging Questions / Re: Stack overflow and my dang thread on: 2005-11-08 19:05:31
 Grin Sweet!  Glad I could help!
Pages: 1 2 [3] 4 5 ... 7
 
EgonOlsen (1572 views)
2018-06-10 19:43:48

EgonOlsen (1632 views)
2018-06-10 19:43:44

EgonOlsen (1143 views)
2018-06-10 19:43:20

DesertCoockie (1569 views)
2018-05-13 18:23:11

nelsongames (1173 views)
2018-04-24 18:15:36

nelsongames (1638 views)
2018-04-24 18:14:32

ivj94 (2395 views)
2018-03-24 14:47:39

ivj94 (1605 views)
2018-03-24 14:46:31

ivj94 (2691 views)
2018-03-24 14:43:53

Solater (882 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!