Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (498)
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 ... 25
1  Game Development / Newbie & Debugging Questions / LWJGL sending information to shaders via texture on: 2014-04-17 22:36:40
I'm trying to do something about my lighting calculations, because they really look poor. Sending all the light data as uniforms really seems stupid. I would much rather send it to shaders via texture. I'm kinda done, but the problem is that opengl caps float values to 1,1,1,1. For example, if I want to send value 10, I cannot, because it gets capped to 1.

Is there a way to fix it?

Here is the glteximage
1  
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 1, 1, 0, GL11.GL_RGBA, GL11.GL_FLOAT, makeLightData());
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Scene2D, utter tedious on: 2014-04-17 16:56:50
@teamworkbuy

Agreed.. I don't see how OP's code is messy. Yes it could use .addCallBack() so you don't have to add call back in the constructor, but other than that, the code seems rather clean.

Here is what you would start calling messy. Adding few buttons without functions is one thing. Its other thing to make everything work together. Here is a really small project I worked on for couple of days. It had like 5 buttons and 1 JList.

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  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
frame = new JFrame("Leauge Of Legends Simple Bot");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setResizable(false);

      JPanel leftPanel = new JPanel(new GridBagLayout());
      GridBagConstraints lc = new GridBagConstraints();
      lc.insets.top = 2;
      lc.insets.bottom = 2;
      lc.gridy = 0;
      frame.add(leftPanel, BorderLayout.WEST);

      JPanel rightPanel = new JPanel(new GridBagLayout());
      frame.add(rightPanel, BorderLayout.EAST);
      GridBagConstraints rc = new GridBagConstraints();
      rc.insets.top = 2;
      rc.insets.bottom = 2;
      rc.gridy = 0;

      buttonImport = new JButton("Import configuration");
      buttonImport.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
            int val = fileChooser.showOpenDialog(frame);

            if (val == JFileChooser.APPROVE_OPTION) {
               File file = fileChooser.getSelectedFile();

               if (file.exists()) {

                  String name = file.getName();
                  String[] names = name.split("\\.");

                  if (names.length == 2 && names[1].equals("botconfig")) {

                     try {
                        ParserDevice device = new ParserDevice(new FileReader(file));

                        try {
                           final BotConfigData data = new BotConfigData(file);
                           data.load(device);

                           dataList.add(data);

                           SwingUtilities.invokeLater(new Runnable() {
                              public void run() {
                                 jlistmodel.addElement(data);
                              }
                           });
                        } catch (NullPointerException e) {
                           showError("Cannot parse file. It may be corrupt.");
                        }
                     } catch (IOException e) {
                        e.printStackTrace();
                     }

                  } else {
                     showError("Wrong file format.\nExpected format is .botconfig");
                  }

               } else {
                  showError("File doesn't exist.");
               }
            }
         }
      });
      leftPanel.add(buttonImport, lc);

      jlistmodel = new DefaultListModel<BotConfigData>();
      jlist = new JList<BotConfigData>(jlistmodel);
      jlist.addListSelectionListener(new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent arg0) {
            if (jlist.getSelectedIndex() == -1) {
               currentConfigData = null;
               buttonStart.setEnabled(false);
               buttonRemove.setEnabled(false);
               return;
            }
            currentConfigData = dataList.get(jlist.getSelectedIndex());
            buttonStart.setEnabled(true);
            buttonRemove.setEnabled(true);
         }
      });

      JScrollPane scroller = new JScrollPane(jlist);
      scroller.setPreferredSize(new Dimension(250, 100));
      rightPanel.add(scroller, rc);

      lc.gridy++;
      buttonRemove = new JButton("Remove configuration");
      buttonRemove.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent arg0) {
         
            BotConfigData data = currentConfigData;
            int val = JOptionPane.showConfirmDialog(frame, "Are you sure you want to remove: "+data.toString()+" ?", "Confirm your selection", JOptionPane.YES_NO_OPTION);
           
            if(val==JOptionPane.OK_OPTION) {
               final int index = dataList.indexOf(currentConfigData);
               
               dataList.remove(index);
               
               SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                     jlistmodel.removeElementAt(index);
                  }
               });
               
               JOptionPane.showMessageDialog(frame, "Configuration "+data.toString()+" has been removed.");
            }
         }
      });
      buttonRemove.setEnabled(false);
      leftPanel.add(buttonRemove, lc);

      lc.gridy++;
      buttonStart = new JButton("Start bot");
      buttonStart.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           
            SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                  buttonImport.setEnabled(false);
                  buttonRemove.setEnabled(false);
                  jlist.setEnabled(false);
                  buttonStart.setEnabled(false);
                  buttonStop.setEnabled(true);
               }
            });
           
            new Thread() {
               public void run() {
                  Bot.instance.botLogic.start(dataList.get(jlist.getSelectedIndex()));
               }
            }.start();
         }
      });
      buttonStart.setEnabled(false);
      leftPanel.add(buttonStart, lc);

      lc.gridy++;
      buttonStop = new JButton("Stop bot");
      buttonStop.setEnabled(false);
      buttonStop.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            stop();
            Bot.instance.botLogic.stop();
         }
      });
      leftPanel.add(buttonStop, lc);

      frame.pack();
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);

      frame.addWindowListener(getClosingWindowListener());


And this is not all the code that has to do something with GUI..

This is what I call messy.

Some people probably find my code clean. It probably depends on your coding skill level.
3  Game Development / Newbie & Debugging Questions / Re: Problem with getting LWJGL to work outside of Eclipse on: 2014-04-17 13:19:05
You need lwjgl natives.

this
http://www.java-gaming.org/topics/compiling-and-running-a-lwjgl-project/31479/view.html

or download jarsplice and pack natives into jar manually.
4  Game Development / Newbie & Debugging Questions / Re: Problem with getting LWJGL to work outside of Eclipse on: 2014-04-17 11:41:21
Run the file in CMD. It will say the error just like in eclipse. Most likely you don't have the image near the jar your'e using.
If you want eclipse to export your jar with resources inside of them, create a res folder in your main project folder. I usually call it 'res' as most people do. Then in eclipse, goto project properties, build path, libraries, add class folder and select your newly create folder.

Now drop all images, sounds and everything you want exported with your jar into that folder. To access that folder in code, do OpenGL_Example.class.getResourceAsStream("/image.png");

5  Game Development / Newbie & Debugging Questions / Re: Export from Eclipse causes trouble on: 2014-04-17 10:35:10
Why isn't there a facepalm emote?

There is no "internal filesystem" in libGDX, Gdx.files.internal (and the other functions) is an API shortcut that basically stands in for getClass().getResourceAsAtream() or similar.

But for some reason you must refresh eclipse project for it to work. Try making changes to files that you load with .internal and you will see that they don't change, even though you saved them. How is that even possible if you don't have some kind of internal memory ?
6  Game Development / Performance Tuning / Re: LWJGL VBO vertices amount on: 2014-04-17 10:21:43
So how many floats fit into 4 mb? 1mil?
7  Game Development / Performance Tuning / LWJGL VBO vertices amount on: 2014-04-17 10:04:13
I have this map viewer, in which you can zoom out really far.
Basically the way it is setup at the moment is I put all the vertices data into 1 VBO and render it to the screen. I update the VBO when player moves/zooms the map.

I currently have my VBO with 20000 quads (80000 vertices) rendering, and it is far from enough. Is this normal? I mean, how much vertices should I limit myself to? Because I'm thinking I will need like close to 500000 vertices to view the map at max zoom.

I guess the question here is what is an optimal size for a VBO? Or rather, is there a downside to using this ONE huge interleaved VBO over few smaller ones?

EDIT-
I feel like I'm putting like 1.5 million vertices, 8 float / vertex into 1 single VBO. Is this OK to do? Cheesy
EDIT--
It seems I was really doing something wrong. I think I'm at 300k static vertices for terrain right now.
EDIT---
Now my question is should I try to optimize this and make multiple VBOs. Would that enhance the performance?
8  Games Center / WIP games, tools & toy projects / Re: Moon Pad v0.1 on: 2014-04-16 21:38:06
Now make it run the files you write and add multiple file support and we have a working IDE! Cheesy
9  Game Development / Newbie & Debugging Questions / Re: [LWJGL] Having trouble cropping from texture on: 2014-04-16 16:27:47
Animation is the last step.. Get the spritesheet rendering working first, then think about animation.

I hope this code 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  
public class SpriteSheet {
   public int width, height;

   // ................

   public void bind() {
      // .......
  }

   // ........

}

public class Sprite {

   public SpriteSheet sheet;
   public int x, y, width, height;
   public float x0, y0, x1, y1;

   public Sprite(SpriteSheet sheet, int x, int y, int width, int height) {
      this.sheet = sheet;
      this.x = x;
      this.y = y;
      this.width = width;
      this.height = height;

      x0 = (float) x / sheet.width;
      y0 = (float) y / sheet.height;

      x1 = (float) (x + width) / sheet.width;
      y1 = (float) (y + height) / sheet.height;
   }

   
   /*
    * Renders this sprite to specified location.
    */

   public void render(float x, float y, float width, float height) {
     
      sheet.bind();
     
      GL11.glBegin(GL11.GL_QUAD);

      GL11.glTexCoord2f(x0, y0);
      GL11.glVertex2f(x, y);

      GL11.glTexCoord2f(x1, y0);
      GL11.glVertex2f(x + width, y);

      GL11.glTexCoord2f(x1, y1);
      GL11.glVertex2f(x + width, y + height);

      GL11.glTexCoord2f(x0, y1);
      GL11.glVertex2f(x, y + height);

      GL11.glEnd();
   }

}
10  Game Development / Newbie & Debugging Questions / Re: [LWJGL] Having trouble cropping from texture on: 2014-04-16 16:10:18
What you want to achieve is called spritesheet or texture atlas or whatever you wanna call it.

I think I messed something up, because *1 doesn't do anything Cheesy

You said "I want to get the basics of animating"
Here is the path I would take: draw a quad, draw a colored quad, load a texture, draw quad with full texture, draw a quad with part of the texture, change the place of the texture you are rendering (animate)

As you can see animating is at the end of the line for me at least.
I can just dump some of my code if you really are lazy to figure it out on your own now.
11  Game Development / Newbie & Debugging Questions / Re: Export from Eclipse causes trouble on: 2014-04-16 15:25:27
If that's the issue, then fix it permanently with
Window > Preferences > General > Workspace > Refresh Using Native Hooks or Polling
and
Window > Preferences > General > Workspace > Refresh on Access

Check both of those.

(I highly doubt it was, as he said it worked in eclipse, but do this anyway)

This is what you do when you work with Libgdx, because libgdx uses some kind of internal file system. It needs to be refreshed. With LWJGL you probably are reading straight from the HDD so it doesn't matter if the files are present in IDE's memory or not.
12  Game Development / Newbie & Debugging Questions / Re: Export from Eclipse causes trouble on: 2014-04-16 14:42:55
Refresh your project. Eclipse might not be exporting some resources for you, because it doesn't know they exist on the hard drive.
13  Game Development / Newbie & Debugging Questions / Re: LibGDX and Getting Pixels From Sprite on: 2014-04-16 11:24:29
@grunt and gibbo

You don't seem to understand what he wants.

He doesn't want tinting. He wants to replace certain gray colors with custom colors in code.
14  Discussions / Miscellaneous Topics / f.lux on: 2014-04-16 08:58:12
Anybody here using flux?
I used to use it, but I deleted it for one reason. I wanted to confirm my findings yesterday so I installed it again.

Today I woke up, sat down for like 1 hour, and my left eye was so red from blood vessels it looked like something hit me in the eye.

So I deleted f.lux and now the redness is almost gone. Am I the only one with such experiences with f.lux?
15  Game Development / Newbie & Debugging Questions / Re: [LWJGL] Having trouble cropping from texture on: 2014-04-16 06:58:40
When sending tex coords, instead of sprite_x/texture.width, put this: 1f*(sprite_x/texture.width)
16  Game Development / Newbie & Debugging Questions / Re: LibGDX and Getting Pixels From Sprite on: 2014-04-16 06:55:03
Not really.

Not with libgdx.. At least performance wise. The way he did it is he took 4 gray colors (0, 85, 170, 255) and when rendering he would assign each of these colors a color he wanted with code.

Have you watched vanzeben's tutorials? I'm pretty sure he explains just that method.
https://www.youtube.com/watch?v=VE7ezYCTPe4
17  Game Development / Newbie & Debugging Questions / Re: Mouse Coords in a tiled world. on: 2014-04-16 06:49:49
You might need to be doing x-camera.x,y-camera.y instead of addition.
18  Discussions / Miscellaneous Topics / Re: What are Anti-Virus Developers Protecting us From? on: 2014-04-14 11:59:00
I don't have any anti virus installed either Cheesy

I remember having anti-virus virus program, that wouldn't allow you to do anything except open explorer and would say that if you run something it would damage your computer memory (info loss) and that you had to buy the full version which cost 50$ to remove that virus which didn't even exist.

That is one time I had a real virus. Maybe I'm currently typing and someone is seeing what I'm typing, but I doubt it.
19  Game Development / Newbie & Debugging Questions / Re: How to create a control panel next to a Canvas object in a JFrame? on: 2014-04-14 11:10:18
This is basic GUI question.. Add JPanel to the frame at center of the frame. Add any components you like to your jpanel. They will be ordered left-right by default.
20  Game Development / Newbie & Debugging Questions / Re: [SOLVED] Collision detection crash on: 2014-04-14 07:12:13
You need to give your variables better names to save yourself from any further confusion.

Its not the name problem. I constantly run into problems simple as this.
21  Java Game APIs & Engines / OpenGL Development / Re: Per-pixel lighting (NO SHADERS!) on: 2014-04-12 16:25:13
To people who say just use shaders, you're kinda wrong. The question he posed here is not whether or not to use shaders. If he used shaders, he would still be posting this question.

@OP
Use code tags [.code][./code](Without .) and that what longarmx said.

The way I did my lighting is divide distance by light strength, and then divide the number you get by some kind of constant ( i did 300)

1  
float light=distance/light.strength/300.0;
22  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-12 12:40:54
The key word is "easing". Armed with that I easily found these links:


Thanks so much! Smiley I have already implemented some of this Cheesy
23  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-12 12:20:23
try something like this perhaps. or multiply the speed by some value each loop.
1  
2  
3  
4  
5  
6  
7  
size = 0;
speed = 20;
while (size < maxSize){
    size += speed;
    speed -= 1;
    updateScreen();
}


I think I would much rather prefer mathematical equation if I find one, because right now all I have is time that the menu has been popping out. I don't have any speed values of anything and I would like it to keep it that way Cheesy
24  Game Development / Game Mechanics / Mathematical curves. on: 2014-04-12 11:43:07
I'm pretty sure there hasn't been a topic like this lately, so might as well post it for discussion, because some people might find this helpful.

What I want to achieve is menus popping in from the center of the screen. I can do it just find, but the problem is, it is very linear.

Would be awesome if people who have some experience could share some equations to make the popping out very fast at start, and slow down once the menu gets bigger.

Here is gif animation (Hope it works properly on first time)
25  Game Development / Newbie & Debugging Questions / Re: Reading/Writing JSON Constantly on: 2014-04-11 07:18:50
I don't really understand your problem, but from what I know, I would only use json for saving data to hard drive or sending json in networking. Using json inside the application so the application itself can access data as json seems silly to me..
26  Discussions / Miscellaneous Topics / Eclipse completions problem? on: 2014-04-10 07:12:30
I have been getting this problem since yesterday's evening, and it is really annoying. Basically completions and suggestions are working properly, almost.

When I'm writing interfaces for example, I don't have completions available for that specific interface. It doesn't happen for all interfaces, just for some..

Take this for example.
1  
2  
3  
4  
5  
6  
7  
8  
9  
jlist.addListSelectionListener(new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent e) {
           
            int index = jlist.getSelectedIndex();
            if (index != -1) currentSheet = sheets.get(index);
            else currentSheet = null;
            forceRender();
         }
      });


I have no completions available when trying to write valueChanged method and it is really annoying to me. Anybody knows why this might be happening?
27  Game Development / Newbie & Debugging Questions / Re: Swing JComboBox problem. on: 2014-04-09 12:50:50

Thanks I will look into it later.

28  Game Development / Newbie & Debugging Questions / Re: Swing JComboBox problem. on: 2014-04-09 12:36:59
Thanks.

I'm still not quite sure why there isn't something like I described (I will assume there isn't until someone proves otherwise Cheesy)

I would say this isn't a good fix, a hack rather.
29  Game Development / Newbie & Debugging Questions / Re: Swing JComboBox problem. on: 2014-04-09 11:57:27
I want to be able to display any string for any object in the JComboBox. I want to be able to put different objects and be able to name them however I want, not the object name.

I mean, atm this is what it does.
1  
renderString = object;


Which gives that objects package path, class name and object number or something.

I want it to do this:
1  
renderString=titleListener.getTitle(object);
30  Game Development / Newbie & Debugging Questions / Swing JComboBox problem. on: 2014-04-09 11:48:44
I'm currently making a certain program. I have a JComboBox setup. Here is the code.

1  
dropdown=new JComboBox<SpriteSheet>();


So I create a that box with spritesheet as its generic type or component or how the **** that's called.

This is how I put objects to it.
1  
dropdown.addItem(sheet);


The problem that causes me is this.


I think you understand what I want to do.

I would like to set like some kind of listener or something that would display the name of the object as I wish, not the actual object id or how is that called.

So it would look something like this:
1  
2  
3  
4  
5  
dropdown.setTitleListener(new TitleListener() {
   public String getTitle(SpriteSheet sheet) {
      return "title";
   }
});


This is just pseudo-code and it doesn't exist. I think you know what I want to achieve. I don't even know how to name it..
Pages: [1] 2 3 ... 25
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (27 views)
2014-04-15 18:08:23

BurntPizza (22 views)
2014-04-15 03:46:01

UprightPath (38 views)
2014-04-14 17:39:50

UprightPath (20 views)
2014-04-14 17:35:47

Porlus (36 views)
2014-04-14 15:48:38

tom_mai78101 (61 views)
2014-04-10 04:04:31

BurntPizza (119 views)
2014-04-08 23:06:04

tom_mai78101 (219 views)
2014-04-05 13:34:39

trollwarrior1 (186 views)
2014-04-04 12:06:45

CJLetsGame (193 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!