Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

redneon

Member Since 30 Apr 2004
Offline Last Active Jul 12 2012 04:17 PM
-----

Posts I've Made

In Topic: OpenGL ES 2 Texture Not Rendering

01 July 2012 - 08:47 AM

Bloody hell. I've fixed it and, as per usual with these things, it was user error. I was passing an incorrect value into glTexImage2D for the internal format. If you look at my texture load code below you can see I'm incorrectly passing bitDepth into glTexImage2D instead of textureFormat. Doh! I've no idea how this works correctly in normal OpenGL, though. I would expect it to fail like it does in GLES. Ah well, nevermind.
[source lang="cpp"]int32_t width, height, bitDepth = 0;//Load the image.uint8_t* pData = ::stbi_load_from_memory(rTextureFile.GetData(), rTextureFile.GetSize(), &width, &height, &bitDepth, 0);if (pData){ m_width = width; m_height = height; m_bitDepth = bitDepth; uint32_t textureFormat = bitDepth == 4 ? GL_RGBA : GL_RGB; glGenTextures(1, &m_handle); glBindTexture(GL_TEXTURE_2D, m_handle); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, bitDepth, width, height, 0, textureFormat, GL_UNSIGNED_BYTE, pData); //No longer need the image. stbi_image_free(pData); return true;}return false;[/source]
Thanks for your help, everyone.

In Topic: OpenGL ES 2 Texture Not Rendering

30 June 2012 - 12:15 PM

Just thinking, is there any chance that I could have set my window up incorrectly? Maybe something wrong in the EGL stuff? I don't think that this could cause this issue but I'm just clutching at straws really, as I can't see any difference between my code and the Simple_Texture2D code.

In Topic: OpenGL ES 2 Texture Not Rendering

30 June 2012 - 10:59 AM

I've fixed why the geometry wasn't being rendered when I don't use VBOs (I was being an idiot and hadn't unbound a buffer I was using elsewhere). So, I've got the geometry rending both with and without VBOs but in both instances I'm just getting black prims without the texture.

I'm now trying to match my code as closely as possible to the Simple_Texture2D sample. The first step was removing the VBOs, I've also tried using their texture code too but it hasn't made a difference. There must be something obviously different between my code and theirs though, for theirs to be working and mine not. I'm sure I'll get to the bottom of it if I keep chugging away :)

In Topic: OpenGL ES 2 Texture Not Rendering

30 June 2012 - 03:31 AM

I just quickly tried sacking off the VBOs and using glVertexAttribPointer to send the data to the GPU each render, as in the Simple_Texture2D sample like this:

[source lang="cpp"] glVertexAttribPointer(Effect::POSITION_ATTR, 2, GL_FLOAT, GL_FALSE, 0, ms_verts);glVertexAttribPointer(Effect::TEXCOORD0_ATTR, 2, GL_FLOAT, GL_FALSE, 0, ms_texCoords);glEnableVertexAttribArray(Effect::POSITION_ATTR);glEnableVertexAttribArray(Effect::TEXCOORD0_ATTR);glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glDisableVertexAttribArray(Effect::TEXCOORD0_ATTR);glDisableVertexAttribArray(Effect::POSITION_ATTR);[/source]

But now even the geometry isn't being rendered. I've probably done something stupid but I only had a quick five minutes before I go to work so I thought I'd give it a try. I'll have more of a look when I get back from work.

In Topic: OpenGL ES 2 Texture Not Rendering

30 June 2012 - 02:53 AM

I like #5, it's a clever way of seeing the texture coordinates are valid. Alas, mine were, black top-left, red top-right, green bottom-left, yellow bottom-right.

I am setting the colour value (though I know in my code I only showed me setting the texture uniform) but just to double check I removed colour from the gl_FragColor calculation and I'm still getting a black square.

I did think perhaps something isn't working in the GLES Windows SDK and that I should just port my code to Pi and fix the issue on there, if it's still an issue. That being said, if I run the Simple_Texture2D sample from the GLES book then the texture displays correctly. The only difference I can see between my code and theirs, however, is that they use glVertexAttribPointer to send the data to the GPU each render instead of storing the data off in a VBO. Should this make a difference?

PARTNERS