示例#1
0
GLuint* OpenGL::RayCaster::CreateRenderBuffer(const int WINDOW_SIZE_X,
                                             const int WINDOW_SIZE_Y)
{

    INFO("Creating the rendering buffer");

    GLuint* renderBuffer_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    // Generate the render buffer ID
    glGenRenderbuffersEXT(1, renderBuffer_ID);

    // Bnd the render buffer
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, *renderBuffer_ID);

    // Setup the parameters of the render buffer
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
                             WINDOW_SIZE_X, WINDOW_SIZE_Y);

    // Attche the render buffer to the frame buffer
    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
                                 GL_RENDERBUFFER_EXT, *renderBuffer_ID);

    // Unbind the render buffer
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

    INFO("1")
    return renderBuffer_ID;
}
示例#2
0
GLuint* OpenGL::RayCaster::CreateImageBuffer(const int WINDOW_SIZE_X,
                                             const int WINDOW_SIZE_Y)
{
    INFO("Creating buffer for rendering the final image");

    GLuint* imgTex_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    // Generate the texture ID
    glGenTextures(1, imgTex_ID);

    // Bind the texture
    glBindTexture(GL_TEXTURE_2D, *imgTex_ID);

    // Adjust texture parameters
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

     // Allocate the texture required for the rendering the final image
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA16F_ARB, WINDOW_SIZE_X, WINDOW_SIZE_Y, 0, GL_RGBA, GL_FLOAT, NULL);

    return imgTex_ID;
}
示例#3
0
GLuint* OpenGL::RayCaster::CreateBackFaceBuffer(const int WINDOW_SIZE_X,
                                                const int WINDOW_SIZE_Y)
{
    INFO("Creating buffer for rendering the back face of the cube");

    GLuint* backfaceTex_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    // Generate the texture ID
    glGenTextures(1, backfaceTex_ID);

    // Bind the backface texture
    glBindTexture(GL_TEXTURE_2D, *backfaceTex_ID);

    // Adjust texture parameters
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

    // Allocate the texture required for the back face
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB,
                 WINDOW_SIZE_X, WINDOW_SIZE_Y,
                 0, GL_RGBA, GL_FLOAT, NULL);

    // Attachig the texture to the buffer for filling it with buffer data
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                              GL_TEXTURE_2D, *backfaceTex_ID, 0);
    return backfaceTex_ID;
}
示例#4
0
durationStruct* Timers::BoostTimers::getDuration(time_boost startTime, time_boost endTime)
{
	duration_boost durationCalc = endTime - startTime;

	durationStruct* duration = MEM_ALLOC_1D_GENERIC(durationStruct, 1);

	duration->unit_NanoSec = (double) durationCalc.total_nanoseconds();
	duration->unit_MicroSec = (double) durationCalc.total_microseconds();
	duration->unit_MilliSec = (double) durationCalc.total_microseconds() / 1000;
	duration->unit_Sec = (double) durationCalc.total_microseconds()/ (1000 * 1000);

	return duration;
}
示例#5
0
GLuint* OpenGL::RayCaster::CreateFBO()
{
    INFO("Creating FBO for rendering the back face of the cube");

    GLuint* FBO_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    // Generate FBO ID
    glGenFramebuffersEXT(1, FBO_ID);

    // Bind the FBO
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, *FBO_ID);

    return FBO_ID;
}
示例#6
0
GLuint* OpenGL::RayCaster::UploadVolumeRGBA(volumeImage* ptrVolImage)
{
    INFO("Uploading the volume to the GPU");

    // Pixel data storage format
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);

    INFO("1");

    // Generate texture ID
    GLuint* volumeTex_ID = MEM_ALLOC_1D_GENERIC(GLuint, 1);

    INFO("2");
    // Generate texture ID
    glGenTextures(1, volumeTex_ID);

    INFO("3");
    // Bind texture
    glBindTexture(GL_TEXTURE_3D, *volumeTex_ID);
INFO("4");
    // Replacement mode
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    INFO("5");

    // Adjust 3D texture paramters
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);

    INFO("6");
    // Upload the texture to the GPU
    glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA,
                 ptrVolImage->volSize.NX,
                 ptrVolImage->volSize.NY,
                 ptrVolImage->volSize.NZ,
                 0,
                 GL_RGBA,
                 GL_UNSIGNED_BYTE,
                 ptrVolImage->volPtr);
    INFO("7");

    INFO("Uploading volume to 3D texture DONE");

    return volumeTex_ID;
}
示例#7
0
void ex_FFTShift::FFTShift_2D_CPU(int size_X, int size_Y)
{
	LOG();

	INFO("2D FFT Shift - CPU");

	// Allocation
	arr_2D_float = MEM_ALLOC_2D_FLOAT(size_X, size_Y);

	// Filling array
	Array::fillArray_2D_float(arr_2D_float, size_X, size_Y, 1);

	// Printing input
	int ctr = 0;
	for (int i = 0; i < size_X; i++)
		for (int j = 0; j < size_Y; j++)
		{
			if (ctr == 0 || ctr == size_X * size_Y - 1 )
				printf("Input \t %f \n", arr_2D_float[i][j]);
			ctr++;
		}

	duration = MEM_ALLOC_1D_GENERIC(durationStruct, 1);

	// FFT shift operation
	//arr_2D_float = FFT::FFT_Shift_2D_float(arr_2D_float, size_X, size_Y, duration);

	// Printing output
	ctr = 0;
	for (int i = 0; i < size_X; i++)
			for (int j = 0; j < size_Y; j++)
			{
				if (ctr == 0 || ctr == size_X * size_Y - 1 )
					printf("Output \t %f \n", arr_2D_float[i][j]);

				ctr++;
			}
	// Freeing memor
	FREE_MEM_1D(duration);
}