Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (651)
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 ... 8
1  Game Development / Newbie & Debugging Questions / Rendering quad with quad class: Nothing appears on: 2015-05-02 19:02:23
I'm trying to use opengl 3 to make a reusable rectangle class for rendering multiple objects. I just get a blue window based off of code from the lwjgl wiki. Here's the code (note i have x, y width height params not doing anything because nothing happened. instead i use the float values given by the tutorial):

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  
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.*;

import java.nio.FloatBuffer;


public class gl30 {

    public static void main(String[] args) {
        // Setup an OpenGL context with API version 3.2
        try {
            PixelFormat pixelFormat = new PixelFormat();
            ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
                    .withForwardCompatible(true)
                    .withProfileCore(true);

            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setTitle("GL30 Demo");
            Display.create(pixelFormat, contextAtrributes);

            GL11.glViewport(0, 0, 640, 480);
        } catch (LWJGLException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        // Setup an XNA like background color
        GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);

        // Map the internal OpenGL coordinate system to the entire screen
        GL11.glViewport(0, 0, 640, 480);

        gl30_quad q = new gl30_quad(200, 100, 50, 50);


        while (!Display.isCloseRequested()) {
            q.render();
           
            Display.update();
            Display.sync(60);
        }
        q.dispose();


        Display.destroy();
        System.exit(0);
    }
}

class gl30_quad {

    private float x, y;
    private int width, height;
    private float r = 1f, g = 0f, b = 1f;

    int vaoId;
    int vboId;
    int vertexCount;


    public gl30_quad(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        init();
    }

    public gl30_quad(int x, int y, int width, int height, float r, float g, float b) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        init();
    }

    private void init() {
        // OpenGL expects vertices to be defined counter clockwise by default
        float[] vertices = {
                // Left bottom triangle
                -0.5f, 0.5f, 0f,
                -0.5f, -0.5f, 0f,
                0.5f, -0.5f, 0f,
                // Right top triangle
                0.5f, -0.5f, 0f,
                0.5f, 0.5f, 0f,
                -0.5f, 0.5f, 0f
        };
        // Sending data to OpenGL requires the usage of (flipped) byte buffers
        FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
        verticesBuffer.put(vertices);
        verticesBuffer.flip();

        vertexCount = 6;

        // Create a new Vertex Array Object in memory and select it (bind)
        // A VAO can have up to 16 attributes (VBO's) assigned to it by default
        vaoId = GL30.glGenVertexArrays();
        GL30.glBindVertexArray(vaoId);

        // Create a new Vertex Buffer Object in memory and select it (bind)
        // A VBO is a collection of Vectors which in this case resemble the location of each vertex.
        vboId = GL15.glGenBuffers();
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
        GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW);
        // Put the VBO in the attributes list at index 0
        GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
        // Deselect (bind to 0) the VBO
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

        // Deselect (bind to 0) the VAO
        GL30.glBindVertexArray(0);
    }

    public void render() {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        // Bind to the VAO that has all the information about the quad vertices
        GL30.glBindVertexArray(vaoId);
        GL20.glEnableVertexAttribArray(0);

        // Draw the vertices
        GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount);

        // Put everything back to default (deselect)
        GL20.glDisableVertexAttribArray(0);
        GL30.glBindVertexArray(0);
    }

    public void dispose() {
        // Disable the VBO index from the VAO attributes list
        GL20.glDisableVertexAttribArray(0);

        // Delete the VBO
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
        GL15.glDeleteBuffers(vboId);

        // Delete the VAO
        GL30.glBindVertexArray(0);
        GL30.glDeleteVertexArrays(vaoId);

        Display.destroy();
    }

}
2  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-31 23:57:27
Maybe I will have something ready for next year's jam.

This is annual now?
3  Games Center / WIP games, tools & toy projects / Re: ScorpionHunter - A SilenceEngine Demo game on: 2014-12-31 18:57:16
Nice demo. It was pretty smooth but felt a slow. The rotation was a bit too slow for my taste and I thought the scorpions should spawn a little more progressively. Also, when you shoot, I notice a small red line behind the gun.

PS: what is that on the player's head?
4  Discussions / General Discussions / Re: 2015 Game Development Goals on: 2014-12-31 18:54:37
As the year ended I realized my full potential (because of tafsj). I wish to show my ability and polish a different kind of game. Every time I started a project and got into it, someone on JGO had already created it and better.
5  Game Development / Game Mechanics / Re: Turn mechanics in an RPG on: 2014-12-28 22:20:07
How about the arena is an enneagon with a player on each point. Each player chooses their attack and when their all ready they attack whichever player they choose in order of the speed stat. If you want teams, I suggest coloring one part of the enneagon red (for the red team) , another part blue (for the blue team) , and the last part green (the green team). I drew a small diagram for it:
6  Discussions / General Discussions / Re: why doesn't anyone use PlayN? on: 2014-12-28 17:51:19
Because there can only be one. But if you find any reason why you choose one over the other, go ahead. Whatever get's the job done.
7  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-12-28 05:06:41
<snip>

Nice work! Are you programming it with c++, Java, or..?
8  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-27 09:14:27
Coming along.
Click to Play
9  Game Development / Newbie & Debugging Questions / Re: IOException: Operation not permitted on: 2014-12-27 04:07:52
[ offtopic ]
I know it is highly frowned upon, but he told me had development knowledge with Bukkit, so I figured he would know all the do's and dont's of testing plugins (I think he still does, although I quickly found out he doesn't have much development knowledge)
[ /offtopic]
Wasn't development on Bukkit canceled after the 1.8.0 update?
10  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-27 00:01:34
Maybe after January 1st or on the same day, one thing I ask is to give 10 days time for each JAM, we can get more quality games done in my opinion.
I personally think the 7 days are okay because it spices up your Monday a bit, but some people may be busy with some other things during the week so 8 - 10 days seems reasonable. That also changes the due date each week.
11  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-26 18:03:17
I'm dropping out. Not because I don't want to finish, but because I would rather be with friends and family than sit by my computer all day programming.

I may even go outside, if I can remember the way out.
I sold all my friends in family for a new intel processor months ago. It actually increases my productivity.
Kidding
12  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-12-26 05:32:04
For Christmas, I got my first mechanical keyboard (A DAS Model S Professional). Very clicky, and very fun Cheesy.
I also got a Galaxy S5, switching from a long line of Iphones. I rooted it as soon as I got it, and I am absolutely loving it!

Any suggestions for what I should do with it (geek-wise)?

If you like playing old games, you can download emulators on to it and download ROMs/ISOs from coolrom (doesn't require root).
13  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-26 04:44:52
When do we submit it?

On new Years.
14  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-12-25 06:01:01
Finished the hellish core tile classes that load tile maps from small image files and converts each pixel into a tile. Time to sleep, it's Christmas (well, if 12:00 am counts)!
Click to Play
15  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-24 21:03:35
Finishing up core classes.
Click to Play
16  Game Development / Newbie & Debugging Questions / Re: Libgdx Rotate a sprite 90 degress on: 2014-12-24 18:37:15
Ah, I suppose you're talking about the delta
17  Game Development / Newbie & Debugging Questions / Re: Libgdx Rotate a sprite 90 degress on: 2014-12-24 18:33:01
In the render method
1  
2  
3  
float rot = 0;
if(rot<90) {rot++;}
sprite.setRotation(Math.toDegrees(rot));
18  Game Development / Newbie & Debugging Questions / Re: [LibGdx] Sprite rotation with mouse on: 2014-12-24 07:25:46
I wasn't drawing the sprite correctly. I was using batch.draw() instead of sprite.draw(batch).
19  Game Development / Newbie & Debugging Questions / [SOLVED] Sprite rotation with mouse on: 2014-12-24 06:59:08
I think I have the code for it after using:
1  
2  
3  
4  
5  
6  
7  
void mouseMove() {
      float angle = (float) Math.atan2(562 - Gdx.input.getY() - p.getY(), Gdx.input.getX() - p.getX());
       
       angle = (float) Math.toDegrees(angle);
         
       player.setRotation(angle);
   }

In this code the player is the sprite. I noticed, without using mouse based rotation, regular rotation doesn't work. Why wont my sprite rotate?
20  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 20:53:52
If only I could finish my current project by the end of December. Cheesy

... Maybe December.. 2015
A little side project wouldn't hurt.  Grin Don't you need some breaks from RPC?
21  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 20:11:49
Made a little character. Now I have to convert him to top down  Emo
22  Discussions / General Discussions / Re: Bring back 1HGJ? on: 2014-12-23 18:43:36
We have Ludum Dare and we literally just started a little game jam yesterday. What more do you want? *goes on knees and cries
23  Discussions / Miscellaneous Topics / Re: My Pixel Theme Song! on: 2014-12-23 18:38:08
Not enough bass
24  Discussions / Miscellaneous Topics / Re: Looking for nice RPGs to check out (online/offline) on: 2014-12-23 18:12:49
Are you looking for a game to play or learn from? If you're trying to learn, I recommend GitHub. It has available source code in any language you please.  Cool
25  Discussions / General Discussions / Re: Hi guys on: 2014-12-23 00:08:09
@matanui159 I'm sure he worked hard to get where he is. Unless he's a.. wizard...
26  Discussions / General Discussions / Re: Hi guys on: 2014-12-23 00:05:34

But good luck
27  Game Development / Newbie & Debugging Questions / Re: [LibGdx] Problem with tile collision on: 2014-12-22 22:52:02
I guess the player was too big for the tile. It works.
28  Game Development / Newbie & Debugging Questions / [LibGdx] Problem with tile collision on: 2014-12-22 21:50:25
Here's the code:
1  
2  
3  
4  
5  
6  
7  
8  
try{
            TiledMapTileLayer layer=(TiledMapTileLayer) map.getLayers().get(0);
            if (layer.getCell((int)p.getX(), (int)p.getY()).getTile().getProperties().containsKey("a"))
            {
               System.out.println("COLLISION!");
            }
            } catch(Exception e) {System.out.println("error coliding"); e.printStackTrace();}
           

When the player touches a tile with the property "a" nothing happens most of the time. If you go to a certain position near the tile it may print "COLLISION!". When I clear out all the tiles and cover the whole map with a grass tile that has no property, it does the weirdest thing. if your x is < than 0 or > 99 it points the exception to the if statement. same for the y axis. I have no kind of method that should stop the player from going past 100 x and y. What do I do to convert the player's position to a tile coordinate?
29  Games Center / Archived Projects / Re: Red Game 2D Engine (the redo!) on: 2014-12-22 01:43:34
Well... because this one was done from scratch and the last one already had alot of talk about how horrible it was I thought it would've been better to create a new topic...

Don't get bothered by any criticism that may seem harsh. Your tech demo looks great based off of what I've seen.
30  Game Development / Networking & Multiplayer / Re: Books on Multiplayer Games? on: 2014-12-22 01:40:46
You should take a look at Kyronet. As far as books; you can get pretty much any by searching it's PDF, 4Shared, and pretty much any good Java book. Looks like The Pirate Bay is gone.
Pages: [1] 2 3 ... 8
 
SHC (11 views)
2015-08-01 03:58:20

Jesse (17 views)
2015-07-29 04:35:27

Riven (38 views)
2015-07-27 16:38:00

Riven (19 views)
2015-07-27 15:35:20

Riven (22 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (32 views)
2015-07-25 00:14:37

BurntPizza (43 views)
2015-07-24 22:06:39

BurntPizza (25 views)
2015-07-24 06:06:53

NoxInc (31 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!