void init(void) { dumpInfo(); // GL inits glClearColor(1,1,1,0);; glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); printError("GL inits"); // Airplane Dynamics_Init(&forward, &up, &right, &position, &velocity); Airplane_Init(&thrust, &yawRate, &pitchRate, &rollRate, &firstPersonView, &resetFlag); // Camera Camera_Init(firstPersonView, &forward, &up, &position, velocity, &camera_position, &camera_look, camMatrix); // Terrain and skybox World_Init(&camera_position, &camera_look); // Init game Game_Init(); // Projection matrix frustum(-0.1, 0.1, -0.1, 0.1, 0.2, 200.0, projMatrix); printError("init arrays"); }
int main(void) { // unsigned long x, a, b, c, d; // char cool[5]; //int i = 0; SysTick_Init(); ADC_Init(1); PORTG_Init(1); PORTD_Init(); PORTA_Init(); PORTF_Init(); PORTB_Init(); PORTE_Init(1); PORTH_Init(); LCD_Init(); Touch_Init(); Camera_Init(); /* while(1) { x = ADC_In(); a = x/1000; x -= a * 1000; b = x/100; x -= b * 100; c = x/10; x -= c * 10; d = x; cool[0] = (char)(a + 48); cool[1] = (char)(b + 48); cool[2] = (char)(c + 48); cool[3] = (char)(d + 48); cool[4] = 0; TFT_Fill(purple); TFT_Text(&cool[0], 50, 50, 16, black, purple); } */ while(1) { GPIO_PORTG_DATA_R ^= 0x04; if(ADC_In() != 1023) { TFT_Fill(yellow); } else { TFT_Fill(purple); } } //TFT_H_Line(50,150,50,black); // return 1; }
void Game_Init() { InputHandler_Init(); Shaders_Init(MAX_SHADERS); Model_Init(MAX_MODELS); Transform_Init(MAX_TRANSFORMS); Camera_Init(MAX_CAMERAS); game_object_list = (struct GameObject *)malloc(MAX_GAME_OBJECTS * sizeof(struct GameObject)); camera_object_list = (struct CameraObject *)malloc(MAX_CAMERAS * sizeof(struct CameraObject)); num_objects = 0; num_cams = 0; struct ShaderPair simple_shader_pair[2] = { [0].shader_source = "Shaders/vertex_shader.glsl", [0].shader_type = GL_VERTEX_SHADER, [1].shader_source = "Shaders/fragment_shader.glsl", [1].shader_type = GL_FRAGMENT_SHADER };
Game *Game_Init(const char *title, const int width, const int height, int flags) { Game *game = (Game *)malloc(sizeof(Game)); assert(game != NULL); game->quit_flag = 1; game->window_context = WindowContext_Init(title, width, height, flags); game->input_handler = InputHandler_Init(game->window_context); game->shader = Shader_CreateProg("shaders/simple_vert.glslv", "shaders/simple_frag.glslf"); game->camera = Camera_Init(); game->directional_light = DirectionalLight_Init(); game->moving_object[0] = GameObject_Init(SPHERE, "textures/blue.png", game->shader); vec3 up = { 0.0f, 1.0f, 0.0f }; Transform_MoveDirection(game->moving_object[0]->transform, up, 0.5f); int i; for (i = 1; i < 5; ++i) game->moving_object[i] = GameObject_Init(CUBE, "textures/yellow.png", game->shader); vec3 forward = { 0.0f, 0.0f, -1.0f }; vec3 back = { 0.0f, 0.0f, 1.0f }; vec3 left = { -1.0f, 0.0f, 0.0f }; vec3 right = { 1.0f, 0.0f, 0.0f }; float disp = 5.0f; Transform_MoveDirection(game->moving_object[1]->transform, forward, disp); Transform_MoveDirection(game->moving_object[2]->transform, back, disp); Transform_MoveDirection(game->moving_object[3]->transform, left, disp); Transform_MoveDirection(game->moving_object[4]->transform, right, disp); Transform_MoveDirection(game->moving_object[0]->transform, left, disp); game->still_object = GameObject_Init(CUBE, "textures/grey.png", game->shader); vec3 scale = { 20.0f, 0.01f, 20.0f }; Transform_Scale(game->still_object->transform, scale); GameObject_RenderUpdate(game->still_object); return game; }