[ create a new paste ] login | about

Link: http://codepad.org/MPmZTOZe    [ raw code | output | fork ]

C++, pasted on Oct 17:
#include "Particles.h"

Particles::Particles() {
	// Initialize stuff here
	h = Hilfer();
	amount = 500;
	voidOffset = amount*16;
	h.seed(5);

	for(int i = 0; i < amount; i++) {
		data.push_back(h.randomPosition());
		data.push_back(h.randomPosition());
		data.push_back(h.randomPosition());
		data.push_back(1.0f);
	}

	for(int i = 0; i < amount; i++) {
		data.push_back(h.randomColor());
		data.push_back(h.randomColor());
		data.push_back(h.randomColor());
		data.push_back(1.0f);
	}
	float* vertexData = &data[0];
	std::cout << sizeof(vertexData) << std::endl;
	int SizeOfData = sizeof(float)*amount*8;

	shaderList.push_back(shader.LoadShader(GL_VERTEX_SHADER, "particles.vert"));
	shaderList.push_back(shader.LoadShader(GL_FRAGMENT_SHADER, "particles.frag"));

	theProgram = shader.CreateProgram(shaderList);

	//glGenVertexArrays(1, &vao);
	//glBindVertexArray(vao); 
	glGenBuffers(1, &vertexBufferObject);

	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
	glBufferData(GL_ARRAY_BUFFER, SizeOfData, vertexData, GL_STREAM_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	
	offsetLocation = glGetUniformLocation(theProgram, "offset");
	fXOffset = 0.0f, fYOffset = 0.2f;
	//glBindVertexArray(0);
	if(glewIsSupported("GL_ARB_point_sprite GL_ARB_point_parameters")) {
		std::cout << "Point sprites are supported." << std::endl;
	} else {
		std::cout << "Point sprites are NOT supported." << std::endl;
	}

}

Particles::~Particles() {
	// Kill stuff here

}

void Particles::Draw() {
	Refresh();
}

void Particles::Refresh() {

	glEnable(GL_BLEND);
	glBlendFunc(GL_ONE,GL_ONE);
	glEnable(GL_POINT_SPRITE);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_PROGRAM_POINT_SIZE);
	fXOffset+=0.01f;
	if(fXOffset>30.0f) {
		fXOffset-=30.0f;
	}
	glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
	glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);

	glUseProgram(theProgram);
	glUniform2f(offsetLocation, fXOffset, fYOffset);
	glPointSize(3.5f);

	
	//glBindVertexArray(vao);
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);

	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);
	
	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (void*)voidOffset);
	
	glDrawArrays(GL_POINTS, 0, amount);

	glDisableVertexAttribArray(0);
	glDisableVertexAttribArray(1);

	
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	//glBindVertexArray(0);
	glUseProgram(0);

	glDisable(GL_BLEND);
	glDisable(GL_PROGRAM_POINT_SIZE);
	glDisable(GL_POINT_SPRITE);
	glEnable(GL_DEPTH_TEST);
	h.checkGLError();
}


Output:
1
2
3
Line 22: error: Particles.h: No such file or directory
Line 3: error: 'Particles' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: