Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a height map of 256x256, containing, foreach cell, not only height as a normal float value ( not 0-1 ) and also 2 gradient values ( for X and Y ), also as normal float values ( not 0-1 ). I have uploaded the texture via normal texture loading:

glEnable( GL_TEXTURE_2D );
glGenTextures( 1, &m_uglID );
DEBUG_OUTPUT("Err %x\n", glGetError());
glBindTexture( GL_TEXTURE_2D , m_uglID );
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F, unW + 1, unH + 1, 0, GL_RGB, GL_FLOAT, pvBytes );
DEBUG_OUTPUT("Err %x\n", glGetError());
DEBUG_OUTPUT("Err %x\n", glGetError());
DEBUG_OUTPUT("Err %x\n", glGetError());
DEBUG_OUTPUT("Err %x\n", glGetError());
DEBUG_OUTPUT("Err %x\n", glGetError());

as a parenthesis, the debug output is:

Err 500 Err 0 Err 0 Err 0 Err 500 Err 500 Err 0 Err 0

pvBytes is a 256x256 array of

typedef struct _tGradientHeightCell
    float v;
    float px;
    float py;
TGradientHeightCell, *LPTGradientHeightCell;


m_ugl_HeightMapTexture = glGetUniformLocation(m_uglProgram, "TexHeightMap");

I load it via:

glEnable(GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D , pTexture->GetID());
glUniform1i(m_ugl_HeightMapTexture, 0);

in shader, I just access it:

uniform sampler2D TexHeightMap;

vec4 GetVertCellParameters( uint i, uint j ) { return texture( TexHeightMap, vec2( i, j ) ); }

vec4 vH00 = GetVertCellParameters( i, j );

My problem is that, when passing negative values in one of the values in TGradientHeightCell ( v, px, py ), the texture is corrupted. I need the values to be passed exact as I have them in memory.

Any help appreciated.

share|improve this question

closed as off-topic by Josh Petrie Dec 18 '14 at 17:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.