# 3DTextures + Conversion + C++

Hey All,

I need some tips on how to convert float to integer.

The other part of the code in my project is a water landscape and when I add the code below and compile it supposed to show sort of a zigzag image laying on top of the water (for example a rough bush).

sample of the code:

float height = 0.0f;

for(int i = 1; i < m_Landscape.getWidth(); ++i)
{
glBegin(GL_TRIANGLE_STRIP);
for(int j = 0; j < m_Landscape.getDepth(); ++j)
{
height = m_Landscape.getHeight(i - 1, j);
glVertex3f(i - 1, height, j);
height = m_Landscape.getHeight(i, j);
glVertex3f(i, height, j);
}
glEnd();
}

The compiler keeps giving me a warning. It displays a flat/plain landscape and not the zigzag one i was hoping for.
So, I have tried to use a cast but with no luck. Maybe I’m using it incorrectly?

the compiler complains on these lines and not the whole code*

glVertex3f(i - 1, height, j);

glVertex3f(i, height, j);

Thanks

Im writing totally as i dont know much of the OpenGL im still learning it. But the think you ask from float to int this is unsafe casting you will lose original data.
Basically anyway if you want to change some variable type
you just write let say that we have
int a = 5;
float b = 5.1;
and at some point you want
cout << int(b); // it would be 5 if not warning for unsafe cast
cout << (int)b; // the same as above
cout << float(a); // legal cast probably 5.0 i didnt compile it //im talking theoritical
cout << (float)a; // the same as above
but if you are sure that you want to convert from float to int you could possibly try to round the result like this
int(b + 0.5);
and if you are using negative values be sure to check if you would add or subtract 0.5.
sry i cant help with the opengl part hope the casting helps

managed to fix it so no worries.