Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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  Games Center / Contests / Re: Ludum Dare 29 (Beneath the Surface) on: 2014-04-29 15:27:06
Couldn't try Simn's, UprightPath's and atombrot's submissions because either they're using OpenGL 2.0 or the latest version of libGDX, and can't try HeroesGraveDev's because I'm on windows, sorry :/ . Some day I will have a computer that has at least OpenGL 2.0... some day...
I tried Wave Propagation's game though.
2  Games Center / Contests / Re: Ludum Dare 29 (Beneath the Surface) on: 2014-04-27 19:03:52
I've participated as well and am now done, anyone want to check it out? http://www.ludumdare.com/compo/ludum-dare-29/?action=preview&uid=36159
3  Game Development / Newbie & Debugging Questions / Re: Could someone test this? on: 2014-03-06 21:35:03
Oh, yeah. I think it's because I'm changing volume of a sound before the sound is loaded. I don't think that's a problem. Anything else?
4  Game Development / Newbie & Debugging Questions / Could someone test this? on: 2014-03-06 21:19:34
Not sure if this is the right section for this.
Could someone test if my engine gives any errors? Not sure why it would, but just in case. Also I programmed this on windows XP so it might cause errors on linux or mac.
I have registered to dropbox only a few minutes ago so not sure if this link will work Tongue
https://www.dropbox.com/s/kjwxwsctt3me90d/test.zip
Anyway, I'm going to go to sleep so I won't respond for a while.
5  Discussions / Miscellaneous Topics / Re: Welcome to 2014! on: 2014-01-02 11:08:47
What did I achieve in 2013?
Not too much:
- Joined JGO (only a few days ago Cheesy )
- Learned LWJGL (OGL <= 1.5)
- Learned a bit of C++
- Started making a 3D engine, realized it was too complicated for me, started making a 2D engine
- Learned how I can actually export my LWJGL games

What do I hope to achieve in 2014?
- Make a game...(Ludum Dare would count)
- Participate in at least 1 Ludum Dare competition
- Learn OGL 2.0 when and if I get a new computer
- Not give up on and "finish" my 2D engine
- Spend more time programming

- Possibly start working on a new 3D engine
- Possibly participate in 7DFPS (although I don't know much about that other than "You have to make an FPS game in 7 days")
6  Game Development / Newbie & Debugging Questions / Re: Texture problem in LWJGL on: 2013-12-30 17:50:01
That fixes it, thanks a lot Smiley
7  Game Development / Newbie & Debugging Questions / [SOLVED] Texture problem in LWJGL on: 2013-12-30 16:17:52
Hello everyone,
I have a problem in my LWJGL project - binding textures doesn't seem to work for me, I only see a white plane without the texture. I really have no idea why, the texture is 256x256, I have textures enabled and the loaded image has data.
Here's the code:
Engine class
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  
package main;

import static org.lwjgl.opengl.GL11.*;

import java.nio.ByteBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class Engine {
   
   final String TITLE = "IcyEngine2D";
   boolean vsync = false;
   final boolean ESC_ON = true;
   int W = 640;
   int H = 480;
   final int W_DEFAULT = 640;
   final int H_DEFAULT = 480;
   int fps = 60;
   Texture tex = new Texture();
   
   //initialize
  public void init(){
      glMatrixMode(GL_PROJECTION);
      glOrtho(0, W_DEFAULT, H_DEFAULT, 0, 1, -1);
      glMatrixMode(GL_MODELVIEW);
     
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glEnable(GL_TEXTURE_2D);
      tex.loadImage("res/textures/Image.png");
      tex.bind();
   }
   
   //game loop -------------------------------------------
  public void input(){
      if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && ESC_ON) exit(false);
   }
   
   public void logic(){
     
   }
   
   public void render(){
      glClear(GL_COLOR_BUFFER_BIT);
      glLoadIdentity();
      tex.bind();
      glTranslatef(200, 200, 0);
      glBegin(GL_QUADS);
      glTexCoord2f(1.0f, 0);
      glVertex2f(100, -100);
      glTexCoord2f(0, 0);
      glVertex2f(-100, -100);
      glTexCoord2f(0, 1.0f);
      glVertex2f(-100, 100);
      glTexCoord2f(1.0f, 1.0f);
      glVertex2f(100, 100);
      glEnd();
   }
   //-----------------------------------------------------
 
   //clean up and exit
  public void exit(boolean error){
      Display.destroy();
      System.exit(error ? 1 : 0);
   }
   
   public static void main(String[] args) {
      new Natives().load();
      new Engine();
   }
   
   public Engine(){
      initDisplay();
      init();
      while(!Display.isCloseRequested())
      loop();
      exit(false);
   }
   
   public void loop(){
      input();
      logic();
      render();
      Display.update();
      Display.sync(fps);
   }
   
   public void initDisplay(){
      try {
         Display.setDisplayMode(new DisplayMode(W, H));
         Display.setTitle(TITLE);
         loadIcon("res/textures/Icon.png");
         Display.create();
         Display.setVSyncEnabled(vsync);
      } catch (LWJGLException e) {
         e.printStackTrace();
         exit(true);
      }
   }
   
   public void throwError(){
      String e = checkError();
      if(e != "no errors")throw new Error(e);
   }
   
   public String checkError(){
      int e = glGetError();
      switch (e) {
      case GL_NO_ERROR: return "no errors";
      case GL_INVALID_ENUM: return "invalid enum";
      case GL_INVALID_VALUE: return "invalid value";
      case GL_INVALID_OPERATION: return "invalid operation";
      case GL_STACK_OVERFLOW: return "stack overflow";
      case GL_STACK_UNDERFLOW: return "stack underflow";
      case GL_OUT_OF_MEMORY: return "out of memory";
      default: return "unknown";
      }
   }
   
   public void loadIcon(String path){
      Texture tex = new Texture();
      tex.loadImage(path);
      ByteBuffer buffer = BufferUtils.createByteBuffer(tex.size * tex.size * 4);
      for(int y = 0; y < tex.size; y++){
         for(int x = 0; x < tex.size; x++){
               int pixel = tex.data[x][y];
                buffer.put((byte) ((pixel >> 16) & 0xFF));
                buffer.put((byte) ((pixel >> 8) & 0xFF));
                buffer.put((byte) (pixel & 0xFF));
                buffer.put((byte) ((pixel >> 24) & 0xFF));
         }
      }
      buffer.flip();
      ByteBuffer[] b = {buffer};
      Display.setIcon(b);
   }
   
}


Texture class
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  
package main;

import static org.lwjgl.opengl.GL11.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import javax.imageio.ImageIO;

import org.lwjgl.BufferUtils;

public class Texture {
   int size = 0;
   int[][] data = new int[size][size];
   int texID = -1;
   
   public void loadImage(String path){
      try {
         BufferedImage img = ImageIO.read(new File(path));
         size = Math.max(img.getWidth(), img.getHeight());
         data = new int[size][size];
         for (int y = 0; y < size; y++) {
            for (int x = 0; x < size; x++) {
               if(x < img.getWidth() && y < img.getHeight())
                  data[x][y] = img.getRGB(x, y);
               else data[x][y] = 0;
            }
         }
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
   
   public void bind(){
      if(texID == -1){
         ByteBuffer buffer = BufferUtils.createByteBuffer(size * size * 4);
         buffer.order(ByteOrder.nativeOrder());
         for(int y = 0; y < size; y++){
            for(int x = 0; x < size; x++){
                  int pixel = data[x][y];
                   buffer.put((byte) ((pixel >> 16) & 0xFF));
                   buffer.put((byte) ((pixel >> 8) & 0xFF));
                   buffer.put((byte) (pixel & 0xFF));
                   buffer.put((byte) ((pixel >> 24) & 0xFF));
            }
         }
         buffer.flip();
         texID = glGenTextures();
         glBindTexture(GL_TEXTURE_2D, texID);
         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
      }else{
         glBindTexture(GL_TEXTURE_2D, texID);
      }
   }
   
}
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.

CogWheelz (15 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!