Beispiel #1
0
void geGraphicsInit(){
	gePrintDebug(0x100, "geGraphicsInit 1\n");
	LibGE_VideoContext* ctx = (LibGE_VideoContext*)geMalloc(sizeof(LibGE_VideoContext));
	libge_context->vidcontext = (unsigned long)ctx;
	libge_context->gpumem += 2 * libge_context->width * libge_context->height * sizeof(u32);
	gePrintDebug(0x100, "geGraphicsInit 2\n");

	ctx->shader2d = geCreateShader();

	geShaderLoadVertexSource(ctx->shader2d, geFileFromBuffer(_ge_shader_gles2_generic_2d_vert, sizeof(_ge_shader_gles2_generic_2d_vert)+1));
	geShaderLoadFragmentSource(ctx->shader2d, geFileFromBuffer(_ge_shader_gles2_generic_2d_frag, sizeof(_ge_shader_gles2_generic_2d_frag)+1));

	ctx->loc_textured = geShaderUniformID(ctx->shader2d, "textured");
	gePrintDebug(0x100, "geGraphicsInit 4\n");
	glUseProgram(ctx->shader2d->programId);
	gePrintDebug(0x100, "geGraphicsInit 5\n");
	glActiveTexture(GL_TEXTURE0);
	glUniform1i(glGetUniformLocation(ctx->shader2d->programId, "ge_Texture"), 0);
	gePrintDebug(0x100, "geGraphicsInit 8\n");
	glUseProgram(0);
	
	glViewport(0, 0, libge_context->width, libge_context->height);
	gePrintDebug(0x100, "geGraphicsInit 9\n");
	
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CW);
	glCullFace(GL_FRONT);
	gePrintDebug(0x100, "geGraphicsInit 10\n");
	
	glScissor(0, 0, libge_context->width, libge_context->height);
	glEnable(GL_SCISSOR_TEST);
	gePrintDebug(0x100, "geGraphicsInit 11\n");
	
	//libge_context->fontbuf = geCreateSurface(libge_context->width, libge_context->height, 0x00000000);
}
Beispiel #2
0
ge_Particles* geCreateParticles(float x, float y, float z, float radius, float velocity, float life_time, int nParticles, ge_Image* texture){
	ge_Particles* particles = (ge_Particles*)geMalloc(sizeof(ge_Particles));
	particles->loop_mode = true;
	particles->origin.x = x;
	particles->origin.y = y;
	particles->origin.z = z;
	particles->radius = radius;
	particles->direction.x = 0.0;
	particles->direction.y = 1.0;
	particles->direction.z = 0.0;
	particles->velocity = velocity;
	particles->life_time = life_time / (velocity==0.0?1.0:velocity);
	particles->nParticles = nParticles;
	particles->size.x = 1.0;
	particles->size.y = 1.0;
	particles->texture = texture;
	particles->nParticles = nParticles;
	particles->particles = (ge_Particle*)geMalloc(sizeof(ge_Particle)*particles->nParticles);
	geParticlesLifeSeed(particles, 10.0);
	particles->shader = geCreateShader();
	geShaderLoadVertexSource(particles->shader, "default_shaders/particles.vert");
	geShaderLoadFragmentSource(particles->shader, "default_shaders/particles.frag");
	particles->render = geCreateRenderer(particles->shader);
	particles->render->blend_enabled = true;
	particles->render->depth_mask = false;
	ge_Object* obj = (ge_Object*)geMalloc(sizeof(ge_Object));
	particles->render->objs = (ge_Object**)geMalloc(sizeof(ge_Object*));
	particles->render->objs[0] = obj;
	particles->render->nObjs = 1;
	particles->render->nVerts = 6;
	obj->nVerts = 6;
	obj->verts = _ge_particles_vertices;
	particles->loc_size = geShaderUniformID(particles->render->shader, "size");
	particles->loc_pos = geShaderUniformID(particles->render->shader, "pos");
	particles->loc_rpos = geShaderUniformID(particles->render->shader, "rpos");
	particles->loc_life = geShaderUniformID(particles->render->shader, "life");
	particles->loc_textured = geShaderUniformID(particles->render->shader, "textured");
	particles->render->verts = _ge_particles_vertices;
	geRendererCreateContext(NULL, particles->render);

	particles->ut = ((float)geGetTick())/1000.0;
	particles->dt = ((float)geGetTick())/1000.0;
	return particles;
}
Beispiel #3
0
void geGraphicsInit(){
	LibGE_VideoContext* ctx = (LibGE_VideoContext*)libge_context->vidcontext;
	if(!ctx){
		ctx = (LibGE_VideoContext*)geMalloc(sizeof(LibGE_VideoContext));
		libge_context->vidcontext = (t_ptr)ctx;
		libge_context->gpumem += 2 * libge_context->width * libge_context->height * sizeof(u32);
	}

	if(!ctx->shader2d){
		gePrintDebug(0x100, "No 2D shader, loading it..\n");
		ctx->shader2d = geCreateShader();
		geShaderLoadVertexSource(ctx->shader2d, geFileFromBuffer(_ge_shader_ogl3_generic_2d_vert, sizeof(_ge_shader_ogl3_generic_2d_vert)+1));
		geShaderLoadFragmentSource(ctx->shader2d, geFileFromBuffer(_ge_shader_ogl3_generic_2d_frag, sizeof(_ge_shader_ogl3_generic_2d_frag)+1));
		ctx->loc_textured = geShaderUniformID(ctx->shader2d, "textured");
		geShaderUse(ctx->shader2d);
		glActiveTexture(GL_TEXTURE0);
		glEnable(GL_TEXTURE_2D);
		glUniform1i(glGetUniformLocation(ctx->shader2d->programId, "ge_Texture"), 0);
	}

	libge_context->blend_src = GE_DEFAULT;
	libge_context->blend_dst = GE_DEFAULT;

	glViewport(0, 0, libge_context->width, libge_context->height);
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CW);
	glCullFace(GL_FRONT);

	glScissor(0, 0, libge_context->width, libge_context->height);
	glEnable(GL_SCISSOR_TEST);
	
	if(libge_context->fontbuf){
		geFreeImage(libge_context->fontbuf);
		libge_context->fontbuf = NULL;
	}
	libge_context->fontbuf = geCreateSurface(libge_context->width, libge_context->height, 0x00000000);
}