Jump to content

  • Log In with Google      Sign In   
  • Create Account

povilaslt2

Member Since 14 Jul 2011
Offline Last Active Nov 22 2015 09:51 AM

Posts I've Made

In Topic: Help to review my first harder game

19 September 2015 - 01:02 PM

Thank you so much for your feedback. I read all and will apply in my code!


In Topic: Help to review my first harder game

19 September 2015 - 08:37 AM

Thanks for advice. I did that because when I minimise window and such then back to the game my always character falls off screen because delta time was + 1 :X. What do you advice to do with deltatime?


In Topic: VBO with shader not working

07 January 2015 - 05:31 AM

.


In Topic: VBO with shader not working

06 January 2015 - 02:24 PM

Modelview matrix:

glGetFloatv(GL_MODELVIEW_MATRIX, modelView);

Yep, I see right color that was set with glClearColor.

I don't see anything but blue screen.

When I change glClearColor nothing changes but background color.

I use glClearColor on main.cpp, main function just before glutMainLoop.


In Topic: VBO with shader not working

06 January 2015 - 01:15 PM

 

Changed glOrtho like you said, nothing changed. Second, how it could be wrong values if I get modelview and projection from system?


The reason for checking the values is just to make sure you are getting what is expected.
I'm sticking with the matrix data is wrong for whatever reason. I also agree with Irlan, you could be ordering your calls incorrectly or leaving something out. I see that, assuming this is full code for that method, you are missing a call to glLoadIdentity for your model matrix.

static void resize(int width, int height)
{
    //const float ar = (float) width / (float) height;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, width, 0.0, height, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity(); //Was missing in above code
}
If worst comes to worst, which this might actually be better in the long run.
You could just ditch the glOthro, glMatrixMode, and etc calls and just compute the ortho matrix yourself using a custom function. Storing the results in a float array, from there its just passing that along to the shader using the uniform calls you have

 

 

 


Thank you. I changed like you said, but it didn't change anything as I tought..

 

OpenGL it's a state machine basically. You need to check if  you're binding something where shouldn't be bound.

 

Try to change the orthographic matrix to the following:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, width, height, 0.0f, 0.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
(...)

and see if you get different results. Check if you're correctly computing your Model-View matrix.

 

Thank you both for answers but it didn't help.

float triangle[18] =
{
    // Left bottom triangle
    -1.0, 1.0, 0.0,
    -1.0, -1.0, 0.0,
    1.0, -1.0, 0.0,
    // Right top triangle
    1.0, -1.0, 0.0,
    1.0, 1.0, 0.0,
    -1.0, 1.0, 0.0
};

float texture[12] =
{
    // Right top triangle
    0.0, 1.0,
    0.0, 0.0,
    1.0, 0.0,
    // Left bottom triangle,
    1.0, 0.0,
    1.0, 1.0,
    0.0, 1.0
};

    glGenVertexArrays(1, &uiVAO);
    glBindVertexArray(uiVAO);

    glGenBuffers(1, &uiVBO);
    glBindBuffer(GL_ARRAY_BUFFER, uiVBO);
    glBufferData(GL_ARRAY_BUFFER, 18*sizeof(float), triangle, GL_STATIC_DRAW);
    glVertexAttribPointer(
        0,                  // The attribute we want to configure
        3,                  // size
        GL_FLOAT,           // type
        GL_FALSE,           // normalized?
        0,                  // stride
        0                   // array buffer offset
    );
    glGenBuffers(1, &uiVBO2);
    glBindBuffer(GL_ARRAY_BUFFER, uiVBO2);
    glBufferData(GL_ARRAY_BUFFER, 12*sizeof(float), texture, GL_STATIC_DRAW);
    glVertexAttribPointer(
        1,                  // The attribute we want to configure
        2,                  // size
        GL_FLOAT,           // type
        GL_FALSE,           // normalized?
        0,                  // stride
        0                   // array buffer offset
    );
    glBindVertexArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

Maybe it will helps somehow..


PARTNERS