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); }
void ge_Splashscreen(){ #ifndef LIBGE_MINI if(!_ge_splashscreen_enabled)return; u32 ticks = geGetTick(); u32 time = 0; ge_Image* splash = geLoadImage(geFileFromBuffer(ge_splash_screen, sizeof(ge_splash_screen))); int h = (splash->height > libge_context->height) ? libge_context->height : splash->height; int w = h * splash->width / splash->height; geDrawingMode(GE_DRAWING_MODE_2D); while(time < 3000){ time = geGetTick() - ticks; if(time < 800){ splash->color = RGBA(255, 255, 255, (u8)(time * 255 / 800)); }else if(time < 2200){ splash->color = RGBA(255, 255, 255, 255); }else if(time < 3000){ splash->color = RGBA(255, 255, 255, (u8)((1000-(time-3000)) * 255 / 1000)); } geClearScreen(); geBlitImageStretched(libge_context->width/2, libge_context->height/2, splash, 0, 0, splash->width, splash->height, w, h, GE_BLIT_CENTERED); geSwapBuffers(); } geFreeImage(splash); #endif }
char* _ge_shader_load_header(const char* file, void* buf, long buflen, int* _size){ char* ret = 0; bool crit = geDebugCritical(false); ret = _ge_shader_load_source(file, _size); geDebugCritical(crit); if(!ret){ ret = _ge_shader_load_source(geFileFromBuffer(buf, buflen), _size); } return ret; }
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); }