Example #1
0
Window::Window(Window::DisplayMode mode, ContextSettings contextSettings) {
	VBE_ASSERT(instance == nullptr, "Only one Window can exist at a time");

	instance = this;
	WindowImpl::create(mode, contextSettings);

	Keyboard::init();
	Mouse::init();
	Gamepad::init();
}
Example #2
0
void ParticleEmitter::update(float deltaTime) {
	VBE_ASSERT(period > 0, "Invalid particle emitter period. Period must be bigger than 0.");
	currWorldPos = vec3f(fullTransform*vec4f(0, 0, 0, 1));
	while(state < deltaTime) {
		state += period;
		spawnParticle(state, deltaTime);
	}
	state -= deltaTime;
	oldWorldPos = currWorldPos;

}
Example #3
0
void ParticleSystem::draw() const {
	if(particles.size() == 0)
		return;
	VBE_ASSERT(textureSheet != NULL, "Cannot draw textureless particles, give particleSystem a textureSheet before emitting particles");
	glDepthMask(GL_FALSE);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	model.program->uniform("modelViewMatrix")->set(viewMatrix*fullTransform);
	model.program->uniform("projectionMatrix")->set(projectionMatrix);
	model.program->uniform("texSize")->set(1.0f/float(textureCount));
	model.program->uniform("textureSheet")->set(textureSheet);
	model.draw();
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDepthMask(GL_TRUE);
}
Example #4
0
Window::~Window() {
	VBE_ASSERT(instance == this, "wtf");

	instance = nullptr;
	WindowImpl::destroy();
}
Example #5
0
void Simulation::setFrame(int frame) {
	VBE_ASSERT(frame >= 0 && frame < NUM_FRAMES,"Non-existent frame " << frame);
	tex->loadFromRaw((const void*) &data[WIDTH*HEIGHT*4*frame], WIDTH, HEIGHT, Texture::RGBA, Texture::UNSIGNED_BYTE, Texture::RGBA8);
	tex->setFilter(GL_NEAREST, GL_NEAREST);
	currentFrame = frame;
}
Example #6
0
//static
bool Gamepad::isConnected(int id) {
	VBE_ASSERT(id <= 0 && id < COUNT, "Invalid gamepad ID, must be in range [0, Gamepad::COUNT)");
	return InputImpl::isGamepadConnected(id);
}
Example #7
0
//static
bool Gamepad::justReleased(int id, Gamepad::Button b) {
	VBE_ASSERT(id <= 0 && id < COUNT, "Invalid gamepad ID, must be in range [0, Gamepad::COUNT)");
	return !InputImpl::getGamepadButtonPressed(id, b) && buttonsOld[id][b];
}
Example #8
0
//static
bool Gamepad::pressed(int id, Gamepad::Button b) {
	VBE_ASSERT(id <= 0 && id < COUNT, "Invalid gamepad ID, must be in range [0, Gamepad::COUNT)");
	return InputImpl::getGamepadButtonPressed(id, b);
}
Example #9
0
//static
float Gamepad::axis(int id, Gamepad::Axis a) {
	VBE_ASSERT(id <= 0 && id < COUNT, "Invalid gamepad ID, must be in range [0, Gamepad::COUNT)");
	return InputImpl::getGamepadAxis(id, a);
}
Example #10
0
 void erase(const std::string& resID) {
     VBE_ASSERT(resources.find(resID) != resources.end(), "Failed to delete resource. resource " << resID << " doesn't exist");
     VBE_LOG("* Deleting resource with ID " << resID );
     resources.erase(resID);
 }
Example #11
0
 T&   get  (const std::string& resID) const {
     VBE_ASSERT(resources.find(resID) != resources.end(), "Failed to get resource. resource " << resID << " doesn't exist");
     return resources.at(resID);
 }
Example #12
0
 void add  (const std::string& resID, T resource) {
     VBE_ASSERT(resources.find(resID) == resources.end(), "Failed to add resource. resource " << resID << " already exists");
     VBE_LOG("* Adding resource with ID " << resID);
     resources.insert(std::pair<std::string, T>(resID, std::move(resource)));
 }