valot menee heksakoodin mukaan
This commit is contained in:
95
src/main.cpp
95
src/main.cpp
@ -130,7 +130,7 @@ int __cdecl main(int argc, char* argv[])
|
||||
// main note effect
|
||||
boolean beenPlaying = false;
|
||||
const int SHAPES_SIZE = 15;
|
||||
float shapeIncrement = 0.02f;
|
||||
float shapeIncrement = 0.15f;
|
||||
|
||||
/**
|
||||
* Definition of shape with 3 parameters in a vec3
|
||||
@ -163,6 +163,14 @@ int __cdecl main(int argc, char* argv[])
|
||||
{ 0.0f, 0.0f, 0.0f }
|
||||
};*/
|
||||
|
||||
|
||||
struct Vec3 {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
#define GRID 32
|
||||
#define HEX_TEX_SIZE (GRID * GRID * 4) // RGBA: 4 floats per texel
|
||||
|
||||
do
|
||||
{
|
||||
direct_sound_buffer->GetCurrentPosition((DWORD*)&playCursor, NULL);
|
||||
@ -245,31 +253,32 @@ int __cdecl main(int argc, char* argv[])
|
||||
// if sound is playing, start a shape, if shape is already started - add length
|
||||
// if sound has stopped, end shape
|
||||
// if shape is finished, move shape forward
|
||||
|
||||
float captureSync = 0.0;
|
||||
|
||||
float captureSync = syncs[5];
|
||||
|
||||
if (captureSync >= 0.001f) {
|
||||
isPlaying = true;
|
||||
}
|
||||
|
||||
//if (isPlaying) {
|
||||
vec3ShapeArray[currentShape][1] = captureSync;
|
||||
vec3ShapeArray[currentShape][2] = vec3ShapeArray[currentShape][2] + shapeIncrement;
|
||||
if (isPlaying) {
|
||||
// vec3ShapeArray[currentShape][1] = captureSync;
|
||||
// vec3ShapeArray[currentShape][2] = vec3ShapeArray[currentShape][2] + shapeIncrement;
|
||||
|
||||
test[0] = test[0] + shapeIncrement; // x position
|
||||
test[1] = captureSync; // y position
|
||||
test[2] = 0.3f; // length
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// when note changes -- reset
|
||||
if (lastNote != captureSync) {
|
||||
test[0] = 0.0f;
|
||||
test[1] = 0.1f;
|
||||
test[2] = 0.0f;
|
||||
lastNote = captureSync;
|
||||
}
|
||||
|
||||
// shape mover, if the shape isnt the current one - move it
|
||||
|
||||
for (int i = 0; i < SHAPES_SIZE; ++i) {
|
||||
if (i != currentShape) {
|
||||
vec3ShapeArray[i][0] = vec3ShapeArray[i][0] + shapeIncrement;
|
||||
@ -287,7 +296,7 @@ int __cdecl main(int argc, char* argv[])
|
||||
currentShape = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float flatShapes[15] = {
|
||||
vec3ShapeArray[0][0], vec3ShapeArray[0][1], vec3ShapeArray[0][2],
|
||||
vec3ShapeArray[1][0], vec3ShapeArray[1][1], vec3ShapeArray[1][2],
|
||||
@ -297,17 +306,73 @@ int __cdecl main(int argc, char* argv[])
|
||||
};
|
||||
|
||||
PFNGLUNIFORM3FVPROC glUniform3fvProc = ((PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"));
|
||||
glUniform3fvProc(10, 3, flatShapes); // array of shapes
|
||||
glUniform3fvProc(40, 1, test); // test shape
|
||||
|
||||
glUniform3fvProc(600, 1, flatShapes); // array of shapes
|
||||
glUniform3fvProc(700, 1, test); // test shape
|
||||
|
||||
PFNGLUNIFORM1FVPROC glUniform1fvProc = ((PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"));
|
||||
glUniform1fvProc(0, SU_NUMSYNCS + 1, syncs);
|
||||
glUniform1fvProc(8, FFT_SIZE / 4, fft_uniform);
|
||||
glUniform1fvProc(20, FFT_SIZE / 4, fft_uniform);
|
||||
|
||||
glRects(-1, -1, 1, 1);
|
||||
|
||||
//syncs[0] = -syncs[0];
|
||||
//glUniform1fvProc(0, SU_NUMSYNCS + 1, syncs);
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture = ((PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture"));
|
||||
PFNGLUNIFORM1IPROC glUniform1i = ((PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"));
|
||||
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = ((PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"));
|
||||
|
||||
static float hexGridData[HEX_TEX_SIZE];
|
||||
|
||||
|
||||
float gap = 0.3f;
|
||||
|
||||
float cellW = 1.6f + 0.2f; // flat-to-flat width
|
||||
float cellH = (sqrtf(3.0f) / 2.0f) * cellW; // height based on regular hex geometry
|
||||
|
||||
float horizontalSpacing = 0.75f * cellW * (1.0f + gap); // 3/4 of width per column
|
||||
float verticalSpacing = cellH * (1.0f + gap); // full height per row
|
||||
|
||||
float rippleCenterX = 7.0f;
|
||||
float rippleCenterY = 7.0f;
|
||||
|
||||
Vec3 gridOffset = { horizontalSpacing * (GRID - 1) * 0.24f, -5.0f, verticalSpacing * (GRID - 1) * 0.24f };
|
||||
|
||||
for (int j = 0; j < GRID; ++j) {
|
||||
for (int i = 0; i < GRID; ++i) {
|
||||
// Offset every other column vertically
|
||||
float offsetZ = (i % 2 == 0) ? 0.0f : 0.5f * verticalSpacing;
|
||||
|
||||
float x = i * horizontalSpacing;
|
||||
float z = j * verticalSpacing + offsetZ;
|
||||
float y = 0.0f;
|
||||
|
||||
Vec3 hexPos = { x - gridOffset.x, y - gridOffset.y, z - gridOffset.z };
|
||||
|
||||
float dx = (float)i - rippleCenterX;
|
||||
float dy = (float)j - rippleCenterY;
|
||||
float hexDist = sqrtf(dx * dx + dy * dy);
|
||||
|
||||
int idx = (j * GRID + i) * 4;
|
||||
hexGridData[idx + 0] = hexPos.x;
|
||||
hexGridData[idx + 1] = hexPos.y;
|
||||
hexGridData[idx + 2] = hexPos.z;
|
||||
hexGridData[idx + 3] = hexDist;
|
||||
}
|
||||
}
|
||||
|
||||
GLuint hexGridTex;
|
||||
glGenTextures(1, &hexGridTex);
|
||||
glBindTexture(GL_TEXTURE_2D, hexGridTex);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, GRID, GRID, 0, GL_RGBA, GL_FLOAT, hexGridData);
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glUniform1i(glGetUniformLocation(pidMain, "u_hexGridTex"), 2);
|
||||
|
||||
|
||||
// render "post process" using the opengl backbuffer
|
||||
#if POST_PASS
|
||||
|
||||
Reference in New Issue
Block a user