mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Finished noiseTest example (in util.h) that uses Perlin noise to draw a bitmap in 2D.
This commit is contained in:
parent
be1b803656
commit
331d4116d9
2 changed files with 5 additions and 4 deletions
|
@ -115,16 +115,17 @@ void drawVector(glm::vec3 * vector) {
|
|||
|
||||
// Render a 2D set of squares using perlin/fractal noise
|
||||
void noiseTest(int w, int h) {
|
||||
const float CELLS = 100;
|
||||
const float CELLS = 500;
|
||||
const float NOISE_SCALE = 10.0;
|
||||
float xStep = (float) w / CELLS;
|
||||
float yStep = (float) h / CELLS;
|
||||
glBegin(GL_QUADS);
|
||||
for (float x = 0; x < (float)w; x += xStep) {
|
||||
for (float y = 0; y < (float)h; y += yStep) {
|
||||
// Generate a vector varying between 0-1 corresponding to the screen location
|
||||
glm::vec2 position(x / (float) w, y / (float) h);
|
||||
glm::vec2 position(NOISE_SCALE * x / (float) w, NOISE_SCALE * y / (float) h);
|
||||
// Set the cell color using the noise value at that location
|
||||
float color = glm::simplex(position);
|
||||
float color = glm::perlin(position);
|
||||
glColor4f(color, color, color, 1.0);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x + xStep, y);
|
||||
|
|
|
@ -893,7 +893,7 @@ void displayOverlay() {
|
|||
audioScope.render();
|
||||
#endif
|
||||
|
||||
// noiseTest(WIDTH, HEIGHT);
|
||||
//noiseTest(WIDTH, HEIGHT);
|
||||
|
||||
if (displayHeadMouse && !::lookingInMirror && statsOn) {
|
||||
// Display small target box at center or head mouse target that can also be used to measure LOD
|
||||
|
|
Loading…
Reference in a new issue