Can't get a quad with a texture or in the right position to render properly

Started by asyx, September 13, 2015, 17:52:30

Previous topic - Next topic

asyx

Hello!

So, I had a problem in another project and just thought to figure out what's wrong, I just strip it down so that I only deal with the texturing and it still doesn't work.

I'm using LWJGL 3.0.0b from the maven repository. I tried to do it with 3.0.0a but also had the same results.

http://pastebin.com/dx4jML4d That's the code. It's the only class in the project.
http://imgur.com/a/AjccL Here is the texture and what I'm seeing. Note the colour of the result. It's from the texture.
https://owncloud.asyxx.eu/index.php/s/qKQuYxGLXC8oAiZ That's the code in a maven project. mvn package gives you the jar with everything you need. You can just double click it. Classpath is set
https://owncloud.asyxx.eu/index.php/s/SnapCTgqTC7Uu38 And here is the compiled version in case you can't be bothered to do that or don't have maven.

I host the last two links myself so if you have any problems with those, I can fix that.

I've never been so stuck with OpenGL in my life...

Also, CodeXL doesn't see the texture at all which is weird but in my other project, it sees the textures but they are just garbage. It's like they're all random numbers in ByteBuffer. The thing is, I've checked the ByteBuffer with a 4x4 whtie texture (which doesn't work in CodeXL either) and literally every byte is 0xFF which it should be.

Also, CodeXL in the other project tells me that I didn't set the texture parameters like the MIN filter and MAG filter and WRAP S and WRAP T. Some are set, some are set differently, some aren't set at all.

I think that's it...

Thanks.

quew8

I'm kind of surprised it works as well as it does. Your problem is where you setup your vertex attribute pointers.

glVertexAttribPointer(posAttrib, 2, GL_FLOAT, false, 4, 0);
...
glVertexAttribPointer(uvAttrib, 2, GL_FLOAT, false, 4, 2);


But the last two parameters, the stride and the offset, are specified in BYTES. You've specified them in floats. The code should be:

glVertexAttribPointer(posAttrib, 2, GL_FLOAT, false, 16, 0);
...
glVertexAttribPointer(uvAttrib, 2, GL_FLOAT, false, 16, 8);


Everyone always slips up on the vertex attribute pointers. I still do probably one in three times I start a new OpenGL project. Sometimes it's that they're in bytes, sometimes you just calculate them wrong, sometimes you tell OpenGL to normalize them by mistake. Always check the VA pointers when something like this goes wrong.

asyx

Oh my f*cking god... I am such a moron. I wasted so much time on that. I know CodeXL better than chest hair at this point because I tried to find the error and then it's THAT!

If I drank, I'd need a drink right now...

Thanks.

quew8

We've all done it. We learn and move on.

I would say that that knowledge of CodeXL will help you later on but it's a bit odd that it wasn't working. Personally I use apitrace and I've never had issues with that as far as textures go. It might be good to figure out why CodeXL wasn't working or just use something else in future.

asyx

apitrace seems like much more of a hassle. At least I didn't find an easy way to set break points on OpenGL errors, for example.

quew8

It is a bit of a hassle. Especially from a Java application. Even more so from an IDE. And yes I don't think you can breakpoints - it's more of a post-runtime analysis tool. But you can combine it with a debug context or something like that.

Anyway I never really looked into the options too much when I chose a program.