Jump to content

  • Log In with Google      Sign In   
  • Create Account

redneon

Member Since 30 Apr 2004
Offline Last Active Jun 24 2014 10:07 AM

Posts I've Made

In Topic: Calculating aribtrary point position in rectangle

20 June 2014 - 09:58 AM

Yeah, that was part of the long story short. In this particular example, because of the way the pipeline works doing that would require some refactoring that I didn't want to do. You're right, though. That is the proper way to do it. I should just bite the bullet and do the refactoring instead of being lazy :)


In Topic: Calculating aribtrary point position in rectangle

20 June 2014 - 09:32 AM

Actually, I might be in luck. It looks like the camera will always be head on, which will make the shape always a rectangle. I imagine that makes things easier?


In Topic: Calculating aribtrary point position in rectangle

20 June 2014 - 09:21 AM

It's a 3D game but the problem is 2D. To cut a long story short, I'm having to pass four uniforms into a pixel shader for the 2D screen space positions of the four corners of a shape. This will end up being a rectangle if the camera is head on, otherwise it'll be a trapezoid. For each pixel in the shader I have the screen space position and I want to know 1) if the pixel is within those four coordinates and if so 2) calculate the amount across and up the shape for texture lookup.


In Topic: Calculating aribtrary point position in rectangle

20 June 2014 - 08:58 AM

Hmm. Actually, it could be a trapezoid based on the position of the camera.


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.

PARTNERS