Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (727)
Games in Android Showcase (217)
games submitted by our members
Games in WIP (796)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 7 8 [9] 10
 81 
 on: 2017-05-16 15:43:22 
Started by buddyBro - Last post by elect
forget glColor3fv, it's deprecated

this should be executed only once:

FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
verticesBuffer.put(vertices).flip();
int vboID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);


and then in the loop

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
glDrawArrays(GL_QUADS, 0, vertices.length);


If you need to change the vertices all together with the same transformation, you need to use matrices, otherwise bind again vboID and call glbufferSubData

 82 
 on: 2017-05-16 15:31:44 
Started by buddyBro - Last post by buddyBro
Intro, so I've spent a couple days trying to figure out the lwjgl 3 way of doing things with vbo's. This being the first time I'm hearing a lot of the terminology isn't making the resources/tutorials easy to understand. Nor do I want to begin at the very beginning, since I have a solid understanding of 3d rendering (though not of opengl or gpu's). Also, though I would like to take the time to learn opengl thoroughly eventually, at the moment, I just want to get my little experiment working.

Previously, I had been using Java graphics2D to draw polygons; e.g.,  brush.drawPolygon(xy[0], xy[1], xy[0].length);

However, I was not happy with the 15fps it was dipping too when polygon count would reach 15-20k. So I decided to try out lwjgl. Here's some code snippet I copied from a previous project before lwjgl 3 had come about, and was very happy with performance,
            glColor3fv(color);
            GL11.glBegin(GL11.GL_POLYGON);
            for (byte i = 0; i < vertices.length; i += 2)
               GL11.glVertex2d(vertices, vertices[i + 1]);
            GL11.glEnd();

But for learning's sake, I wanted to get a little familiar with the newer way of drawing in opengl. So I tried figuring out from tutorials and the online reference and eventually arrived at this working snippet (not included in the snippet is a glclear and glfwSwapBuffers that each happens once per frame):
            glColor3fv(color);
            FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
            verticesBuffer.put(vertices).flip();
            int vboID = glGenBuffers();
            glEnableVertexAttribArray(0);
            glBindBuffer(GL_ARRAY_BUFFER, vboID);
            glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_DYNAMIC_DRAW);
            glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);
            glDrawArrays(GL_QUADS, 0, vertices.length);

Unfortunately, this last snippet, was dropping painfully slow even at 1000 polygon count, which was disappointing, but also indicated that must not be the correct way of doing things.
I'm not sure if I can group up all my draw's into 1 giant array and only call glDrawArrays once, since I think only the last glColor would then be applied to all the quads. Nor do I want to include the color per vertex, since doing so seems to require writing a shader or something, and that seems like overkill for my requirement.
Additionally, if it matters, vertexes are in 2D coordinates. I do the 3d -> 2d transformation and lighting -> color calculations with java+math rather than opengl. Hence my reluctance to write shaders or anything too complicated.

Thanks,

 83 
 on: 2017-05-16 13:08:04 
Started by Chennorris - Last post by elect
Wow, feeling impressed by the speed at which you spotted the point Shocked

Got the same error of your somewhere in the past, it took me a while.. and I learnt that

 84 
 on: 2017-05-16 12:33:42 
Started by Chennorris - Last post by Chennorris
Wow, feeling impressed by the speed at which you spotted the point Shocked
I'm gonna think about putting your name in the thanks part of my project (if it's released one day Grin)

Now, I have a Missing attachment error, but it seems far better than this 1280 error code


_____________________
EDIT :

I just un-commented the part where I was creating a texture and attaching it to the framebuffer and now I get the GL_FRAMEBUFFER_COMPLETE.
Thanks a lot Wink

 85 
 on: 2017-05-16 12:19:09 
Started by Chennorris - Last post by elect
1280 is GL_INVALID_ENUM

from the doc:
Quote
For glCheckFramebufferStatus, the framebuffer checked is that bound to target, which must be GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_FRAMEBUFFER. GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER.

You are passing instead the fbo id/name and that's why the error

 86 
 on: 2017-05-16 12:00:06 
Started by Chennorris - Last post by Chennorris
Hello everyone,

I'm currently working on a new part of my JOGL project, following tutorials about Framebuffers (this one looks rather good to me). I'm stuck at the very beginning of this tutorial, with a strange status for my framebuffer (1280 does not seem to correspond to any status).

To understand a bit more my problem, here's how my code looks like :
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  
public static void renderAll(GLAutoDrawable drawable) throws NullPointerException {
    GL3 gl = drawable.getGL().getGL3();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
    gl.glClearColor(0.3f, 0.3f, 0.3f, 0);

    // Enabling alpha transparency
    gl.glEnable(GL3.GL_BLEND | GL3.GL_PROGRAM_POINT_SIZE);
    gl.glBlendFunc(GL3.GL_SRC_ALPHA, GL3.GL_ONE_MINUS_SRC_ALPHA);
    gl.glPolygonMode(GL3.GL_FRONT_AND_BACK, isInPlayMode() ? GL3.GL_FILL : GL3.GL_LINE);

    // Updating camera position, direction and zoom
    CameraManager.updateCamera();

    SceneManager.renderIntoFramebuffer(gl, mainWindow.getWidth(), mainWindow.getHeight());

    gl.glFlush();
}

...

SceneManager.renderIntoFramebuffer(GL3 gl, int viewportWidth, int viewportHeight) {
    // Creation of the framebuffer
    IntBuffer idFramebuffer = GLBuffers.newDirectIntBuffer(1);
    gl.glGenFramebuffers(1, idFramebuffer);
    gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, idFramebuffer.get(0));

    // Checking the framebuffer status
    int framebufferStatus = gl.glCheckFramebufferStatus(idFramebuffer.get(0));
    switch (framebufferStatus) {
        case GL3.GL_FRAMEBUFFER_COMPLETE:
            logger.info("Framebuffer is complete :)");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
            logger.error("Incomplete attachment");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
            logger.error("Incomplete dimensions");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
            logger.error("Incomplete draw buffer");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
            logger.error("Incomplete layer targets");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
            logger.error("Incomplete read buffer");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
            logger.error("Missing attachment");
            break;
        case GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
            logger.error("Incomplete multisample");
            break;
        case GL3.GL_FRAMEBUFFER_UNDEFINED:
            logger.error("Undefined");
            break;
        case GL3.GL_FRAMEBUFFER_UNSUPPORTED:
            logger.error("Not supported");
            break;
        default:
            logger.warn("Unknown framebuffer status (" + framebufferStatus + ")");
    }
    gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
    gl.glDeleteFramebuffers(1, idFramebuffer);
}


In my logs, the only result I obtain is "Unknown framebuffer status (1280)".
Do you see anything I could have forgotten / made wrong ?

Thanks in advance for your help Smiley

 87 
 on: 2017-05-16 09:38:12 
Started by 0AndrewShepherd0 - Last post by KaiHH
By "stretching the screen" you likely mean: Upon changing the aspect ratio of the viewport/window, you do not want the rendered objects to be stretched but keep their respective length ratios.
Or in short: No matter how you resize your window, a rendered unit square should always remain a unit square and not a stretched rectangle.

If so, then you can achieve this by changing the GL_PROJECTION matrix like so:
1  
2  
3  
4  
5  
GL11.glMatrixMode(GL_PROJECTION);
GL11.glLoadIdentity();
float aspect = (float)windowWidth/windowHeight;
GL11.glScalef(1/aspect, 1, -1);
/* Do any other coordiante system transformations... */


or if you want to specify the coordinate system bounds (left, right, bottom, top), you can use glOrtho which gives the same result:
1  
2  
3  
4  
GL11.glMatrixMode(GL_PROJECTION);
GL11.glLoadIdentity();
float aspect = (float)windowWidth/windowHeight;
GL11.glOrtho(-aspect, aspect, -1, 1, -1, 1);


Also interesting to note is that all of the above is also equivalent to this:
1  
2  
3  
4  
5  
GL11.glMatrixMode(GL_PROJECTION);
GL11.glLoadIdentity();
float aspect = (float)windowWidth/windowHeight;
GL11.glScalef(1/aspect, 1, 1);
GL11.glOrtho(-1, 1, -1, 1, -1, 1); // <- or any other bounds

However, now you can specify the visible bounds as if you had a square viewport and then still react to changing aspect ratios.

Now, if you do not want to use OpenGL's matrix stack and instead use shaders, there are other Java matrix libraries to build matrices for sending to a shader. But in essence, they all do the same as the above.

If by "stretching the screen" you mean that the viewport should always fill the window's client area, then do:
1  
GL11.glViewport(0, 0, windowWidth, windowHeight);

 88 
 on: 2017-05-16 07:31:38 
Started by Ecumene - Last post by EpicGuru
Great, thanks! That cleared some things up, I'll be glad to get some feedback to you. Best of luck!

 89 
 on: 2017-05-16 05:10:51 
Started by simulatoralive - Last post by 65K
My thoughts:

When finding a solution for versionising data, these are two different things:
The concept itself and the way to store data. Using text, binary, json or xml is not part of the design at first place.

One main part of a data version concept is about processing the data.

Your approach is actually not using zip files, but a file system (thats what you get with zip files). Nothing fundamentelly wrong with that of course.

Always favor simple solutions. Not clearly separating versioned data lets complexity explode.

 90 
 on: 2017-05-16 04:15:41 
Started by 0AndrewShepherd0 - Last post by 0AndrewShepherd0
I'm using LWJGL 3 for a 2d hacking simulator game. I want the screen to just be stretched upon resizing the window. How can this be done? I've looked at several posts on various forums and stackoverflow, but what everyone is saying seems to be outdated. I'm using version 3.1.2 Stable if that matters.

Pages: 1 ... 7 8 [9] 10
 
Archive (299 views)
2017-04-27 17:45:51

buddyBro (486 views)
2017-04-05 03:38:00

CopyableCougar4 (933 views)
2017-03-24 15:39:42

theagentd (955 views)
2017-03-24 15:32:08

Rule (955 views)
2017-03-19 12:43:22

Rule (924 views)
2017-03-19 12:42:17

Rule (925 views)
2017-03-19 12:36:21

theagentd (989 views)
2017-03-16 05:07:07

theagentd (903 views)
2017-03-15 22:37:06

theagentd (698 views)
2017-03-15 22:32:18
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!