int32_t obj_parser_init(obj_parser_t *p, const char *filename) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Parsing: %s\n", filename); FILE *f = fopen(filename, "rb"); // If file doesn't exist if(f == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to open file: %s\n", filename); return 1; } // Determine the size of the file fseek(f, 0, SEEK_END); size_t fsize = (size_t)ftell(f); fseek(f, 0, SEEK_SET); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Size of \'%s\' file: %lu bytes\n", filename, fsize); // Read the whole file into memory char *fstring = (char*)malloc(fsize+1); fread(fstring, fsize, 1, f); fclose(f); // Null terminate the string fstring[fsize] = 0; // Initialize the parser object *p = (obj_parser_t){fstring, fsize, 0, {array_create(2, sizeof(char)), OBJ_UNKNOWN}}; return 0; }
/* Loads the image at the file name. Takes in a pointer to a Texture structure that it puts all the generated data into. Returns >= 0 on success, < 0 on failure. */ int gfxUtil_LoadTexture( const char* fileName, Texture* outTexture ) { LoadedImage image = { 0 }; int returnCode = 0; if( outTexture == NULL ) { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Null outTexture passed for file %s!", fileName ); goto clean_up; } // load and convert file to pixel data image.reqComp = 4; image.data = stbi_load( fileName, &( image.width ), &( image.height ), &( image.comp ), image.reqComp ); if( image.data == NULL ) { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Unable to load image %s! STB Error: %s", fileName, stbi_failure_reason( ) ); returnCode = -1; goto clean_up; } if( createTextureFromLoadedImage( GL_RGBA, &image, outTexture ) < 0 ) { returnCode = -1; goto clean_up; } clean_up: //SDL_FreeSurface( loadSurface ); stbi_image_free( image.data ); return returnCode; }
// This is still somewhat game-specific. (Because it assumes that your // leaderboards are tied to events.) TODO: clean this up further later. void GPGManager::ShowLeaderboards(const GPGIds *ids, size_t id_len) { #ifdef NO_GPG return; #endif if (!LoggedIn()) return; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: launching leaderboard UI"); // First, get all current event counts from GPG in one callback, // which allows us to conveniently update and show the leaderboards without // having to deal with multiple callbacks. game_services_->Events().FetchAll([id_len, ids, this]( const gpg::EventManager::FetchAllResponse &far) { for (auto it = far.data.begin(); it != far.data.end(); ++it) { // Look up leaderboard id from corresponding event id. const char *leaderboard_id = nullptr; for (size_t i = 0; i < id_len; i++) { if (ids[i].event == it->first) { leaderboard_id = ids[i].leaderboard; } } assert(leaderboard_id); if (leaderboard_id) { game_services_->Leaderboards().SubmitScore(leaderboard_id, it->second.Count()); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: submitted score %llu for id %s", it->second.Count(), leaderboard_id); } } game_services_->Leaderboards().ShowAllUI([](const gpg::UIStatus &status) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Leaderboards UI FAILED, UIStatus is: %d", status); }); }); }
void GPGManager::ShowAchievements() { #ifdef NO_GPG return; #endif if (!LoggedIn()) return; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: launching achievement UI"); game_services_->Achievements().ShowAllUI([](const gpg::UIStatus &status) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Achievement UI FAILED, UIStatus is: %d", status); }); }
void listDebugShow(list_t* list, uint_fast8_t all ) { listItem* it; //Check that list will iterate to the end it = &list->begin; int c=0; while( (it=it->next) != &list->end ) { if(c++ > list->count) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " == ERROR == More forward iterations than list elements; List is corrupt.\n"); return; } } //Check that list will iterate to the beginning it = &list->end; c=0; while( (it=it->prev) != &list->begin ) { if(c++ > list->count) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " == ERROR == More backward iterations than list elements; List is corrupt.\n"); return; } } if( all & LIST_DEBUG_SHOW_FORWARD ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " Forward iteration:\n"); it = &list->begin; while( (it=it->next) != &list->end ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " listItem( %p )->data = %p ( prev = %p - next = %p )\n", it, it->data, it->prev, it->next); } } if( all & LIST_DEBUG_SHOW_BACKWARD ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " Reverse iteration:\n"); it = &list->end; c=0; while( (it=it->prev) != &list->begin ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " listItem( %p )->data = %p ( prev = %p - next = %p )\n", it, it->data, it->prev, it->next); } } }
ScriptComponent* scriptpool_add(Pool* pool, lua_State* L, const char* path) { ScriptComponent* item = pool_pop_available(pool); if(item == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ScriptPool stack overflow.\n"); return NULL; } item->component = NULL; strcpy(item->path, path); int status = luaL_loadfile(L, item->path); status |= lua_pcall(L, 0, 0, 0); if(status) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load file %s: %s\n", item->path, lua_tostring(L, -1)); } lua_getglobal(L, "instance"); item->instance = lua_tostring(L, -1); lua_pop(L, 1); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Script `%s` loaded.\n", item->path); return item; }
void GPGMultiplayer::AcceptConnectionRequest( const std::string& client_instance_id) { if (message_listener_ == nullptr) { message_listener_.reset(new MessageListener( [this](const std::string& instance_id, std::vector<uint8_t> const& payload, bool is_reliable) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: OnMessageReceived(%s) callback", instance_id.c_str()); this->MessageReceivedCallback(instance_id, payload, is_reliable); }, [this](const std::string& instance_id) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: OnDisconnect(%s) callback", instance_id.c_str()); this->DisconnectedCallback(instance_id); })); } SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: Accepting connection from %s", client_instance_id.c_str()); nearby_connections_->AcceptConnectionRequest( client_instance_id, std::vector<uint8_t>{}, message_listener_.get()); pthread_mutex_lock(&instance_mutex_); AddNewConnectedInstance(client_instance_id); UpdateConnectedInstances(); auto i = std::find(pending_instances_.begin(), pending_instances_.end(), client_instance_id); if (i != pending_instances_.end()) { pending_instances_.erase(i); } pthread_mutex_unlock(&instance_mutex_); }
void GPGMultiplayer::SendConnectionRequest( const std::string& host_instance_id) { if (message_listener_ == nullptr) { message_listener_.reset(new MessageListener( [this](const std::string& instance_id, std::vector<uint8_t> const& payload, bool is_reliable) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: OnMessageReceived(%s) callback", instance_id.c_str()); this->MessageReceivedCallback(instance_id, payload, is_reliable); }, [this](const std::string& instance_id) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: OnDisconnect(%s) callback", instance_id.c_str()); this->DisconnectedCallback(instance_id); })); } SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: Sending connection request to %s", host_instance_id.c_str()); // Immediately stop discovery once we start connecting. nearby_connections_->SendConnectionRequest( my_instance_name_, host_instance_id, std::vector<uint8_t>{}, [this](int64_t client_id, gpg::ConnectionResponse const& response) { SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: OnConnectionResponse() callback"); this->ConnectionResponseCallback(response); }, message_listener_.get()); }
/* Turns a single channel bitmap into a texture. Takes in a pointer to a Texture structure that it puts all the generated data into. Returns >= 0 on success, < 0 on failure. */ int gfxUtil_CreateTextureFromAlphaBitmap( uint8_t* data, int width, int height, Texture* outTexture ) { assert( data != NULL ); assert( width > 0 ); assert( height > 0 ); int returnCode = 0; LoadedImage image = { 0 }; image.data = data; image.width = width; image.height = height; image.reqComp = image.comp = 1; if( outTexture == NULL ) { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Null outTexture passed for bitmap!" ); goto clean_up; } if( createTextureFromLoadedImage( GL_ALPHA, &image, outTexture ) < 0 ) { returnCode = -1; goto clean_up; } clean_up: return returnCode; }
jint JNI_OnLoad(JavaVM *vm, void *reserved) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "main: JNI_OnLoad called"); gpg::AndroidInitialization::JNI_OnLoad(vm); return JNI_VERSION_1_4; }
SDL_GLContext* glcontext_create(SDL_Window* window) { glcontext_init(); SDL_GLContext* gl = SDL_GL_CreateContext(window); SDL_GL_SetSwapInterval(0); check_gl_errors("GL Context creation"); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_CULL_FACE); glClearColor(1, 1, 1, 1); SDL_LogInfo( SDL_LOG_CATEGORY_RENDER, "GL version: %s - GLSL version: %s\n", glGetString(GL_VERSION), glGetString(GL_SHADING_LANGUAGE_VERSION)); return gl; }
/* Converts the LoadedImage into a texture, putting everything in outTexture. All LoadedImages are assumed to be in RGBA format. Returns >= 0 if everything went fine, < 0 if something went wrong. */ int createTextureFromLoadedImage( GLenum texFormat, LoadedImage* image, Texture* outTexture ) { //GLenum texFormat = GL_RGBA; GL( glGenTextures( 1, &( outTexture->textureID ) ) ); if( outTexture->textureID == 0 ) { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Unable to create texture object." ); return -1; } GL( glBindTexture( GL_TEXTURE_2D, outTexture->textureID ) ); // assuming these will look good for now, we shouldn't be too much resizing, but if we do we can go over these again GL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ) ); GL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ) ); GL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ) ); GL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ) ); GL( glTexImage2D( GL_TEXTURE_2D, 0, texFormat, image->width, image->height, 0, texFormat, GL_UNSIGNED_BYTE, image->data ) ); outTexture->width = image->width; outTexture->height = image->height; outTexture->flags = 0; // check to see if there are any translucent pixels in the image for( int i = 3; ( i < ( image->width * image->height ) ) && !( outTexture->flags & TF_IS_TRANSPARENT ); i += 4 ) { if( ( image->data[i] > 0x00 ) && ( image->data[i] < 0xFF ) ) { outTexture->flags |= TF_IS_TRANSPARENT; } } return 0; }
extern "C" JNIEXPORT void JNICALL Java_com_google_fpl_pie_1noon_FPLActivity_nativeOnActivityResult( JNIEnv *env, jobject thiz, jobject activity, jint request_code, jint result_code, jobject data) { gpg::AndroidSupport::OnActivityResult(env, activity, request_code, result_code, data); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: nativeOnActivityResult"); }
void US_Startup(void) { Sint16 n; // BBi int sdl_result; // BBi if (US_Started) return; // BBi SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL: %s", "Initializing timer..."); sdl_result = SDL_InitSubSystem(SDL_INIT_TIMER); if (sdl_result != 0) Quit("%s", SDL_GetError()); sys_timer_id = SDL_AddTimer(1000 / 70, sys_timer_callback, NULL); if (sys_timer_id == 0) Quit("%s", SDL_GetError()); // BBi US_InitRndT(true); // Initialize the random number generator switch (::g_args.check_argument(US_ParmStrings2)) { case 0: compatability = true; break; case 1: compatability = false; break; } // Check for TED launching here n = static_cast<int16_t>(g_args.check_argument(US_ParmStrings)); switch(n) { case 0: #if 0 tedlevelnum = atoi(g_argv[i + 1]); // if (tedlevelnum >= 0) tedlevel = true; #endif break; // case 1: // NoWait = true; // break; } US_Started = true; }
void GPGManager::ToggleSignIn() { #ifdef NO_GPG return; #endif delayed_login_ = false; if (state_ == kAuthed) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Attempting to log out..."); game_services_->SignOut(); } else if (state_ == kStart || state_ == kAuthUIFailed) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Attempting to log in..."); state_ = kManualSignBackIn; do_ui_login_ = true; } else { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: Ignoring log in/out in state %d", state_); delayed_login_ = true; } }
int Sq_Export() { // take the level path and take off the filename strcpy(ExportPath, LevelFilenameFull); char *Temp = strrchr(ExportPath, '/'); if(!Temp) Temp = strrchr(ExportPath, '\\'); if(!Temp) strcpy(ExportPath, "./"); if(Temp) Temp[1] = 0; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Exporting to \"%s\"", ExportPath); const char *ExportFormat = GetLevelStr("", "Meta/ExportFormat"); if(!ExportFormat || !*ExportFormat) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "No export format specified in the file"); return 0; // no format } SquirrelHook *Hook = AllExportFormats; for(; Hook; Hook=Hook->Next) { if(!strcasecmp(Hook->Name, ExportFormat)) break; } if(!Hook) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "No exporter registered for \"%s\"", ExportFormat); return 0; // format not found } IsExporting = 1; SQInteger top = sq_gettop(Hook->Script); sq_pushroottable(Hook->Script); sq_pushobject(Hook->Script, Hook->Function); sq_pushroottable(Hook->Script); // push "this" sq_call(Hook->Script, 1, SQTrue, SQTrue); IsExporting = 0; // if we return a true, then it was successful SQBool BoolResult = SQFalse; if(OT_BOOL == sq_gettype(Hook->Script,-1)) sq_getbool(Hook->Script, -1, &BoolResult); sq_settop(Hook->Script,top); return (BoolResult==SQTrue)?1:0; }
// Called every frame from the game, to see if there's anything to be done // with the async progress from gpg void GPGManager::Update() { #ifdef NO_GPG return; #endif assert(game_services_); switch (state_) { case kStart: case kAutoAuthStarted: // Nothing to do, waiting. break; case kAutoAuthFailed: case kManualSignBackIn: // Need to explicitly ask for user login. if (do_ui_login_) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: StartAuthorizationUI"); game_services_->StartAuthorizationUI(); state_ = kAuthUILaunched; do_ui_login_ = false; } else { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: skipping StartAuthorizationUI"); state_ = kAuthUIFailed; } break; case kAuthUILaunched: case kAuthUIStarted: // Nothing to do, waiting. break; case kAuthUIFailed: // Both auto and UI based auth failed, I guess at this point we give up. if (delayed_login_) { // Unless the user expressed desire to try log in again while waiting // for this state. delayed_login_ = false; state_ = kManualSignBackIn; do_ui_login_ = true; } break; case kAuthed: // We're good. TODO: Now start actually using gpg functionality... break; } }
void scriptcomponent_serialize(ScriptComponent* component, lua_State* L, cmp_ctx_t* context) { cmp_write_map(context, 2); cmp_write_str(context, "path", 4); cmp_write_str(context, component->path, strlen(component->path)); cmp_write_str(context, "instance", 8); script_serialize(L, component->instance, context); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Script `%s` serialized.\n", component->path); }
/* Turns an SDL_Surface into a texture. Takes in a pointer to a Texture structure that it puts all the generated data into. Returns >= 0 on success, < 0 on failure. */ int gfxUtil_CreateTextureFromSurface( SDL_Surface* surface, Texture* outTexture ) { // convert the pixels into a texture GLenum texFormat; if( surface->format->BytesPerPixel == 4 ) { texFormat = GL_RGBA; } else if( surface->format->BytesPerPixel == 3 ) { texFormat = GL_RGB; } else { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Unable to handle format!" ); return -1; } // TODO: Get this working with createTextureFromLoadedImage( ), just need to make an SDL_Surface into a LoadedImage glGenTextures( 1, &( outTexture->textureID ) ); if( outTexture->textureID == 0 ) { SDL_LogInfo( SDL_LOG_CATEGORY_VIDEO, "Unable to create texture object." ); return -1; } glBindTexture( GL_TEXTURE_2D, outTexture->textureID ); // assuming these will look good for now, we shouldn't be too much resizing, but if we do we can go over these again glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexImage2D( GL_TEXTURE_2D, 0, texFormat, surface->w, surface->h, 0, texFormat, GL_UNSIGNED_BYTE, surface->pixels ); outTexture->width = surface->w; outTexture->height = surface->h; outTexture->flags = 0; // the reason this isn't using the createTextureFromLoadedImage is this primarily if( gfxUtil_SurfaceIsTranslucent( surface ) ) { outTexture->flags |= TF_IS_TRANSPARENT; } return 0; }
void set_opengl_version(lite3d_video_settings *settings) { SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "Setting OpenGL Version: %d.%d", settings->glVersionMajor, settings->glVersionMinor); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, settings->glVersionMajor); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, settings->glVersionMinor); }
//Select packNum (or default if out of range void packSet(int packNum) { if(packNum < ps.numPacks) ps.selected=packNum; else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "packSet(); Error: packNum '%i' out of range (%i)\n",packNum, ps.numPacks); ps.selected=0; } SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "packSet(); Selecting pack %i...\n", ps.selected); ps.cp = (packInfoType*)listGetItemAt(ps.packs, ps.selected)->data; //Set finishedImg 0 when we select a pack, to make sure the correct image is loaded. ps.finishedImg=0; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,"packSet(); Selected pack '%s' Loading stats..\n", ps.cp->path); //Load stats for this pack statsLoad(); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,"packSet(); Stats loaded.\n"); }
SQInteger Sq_ExportOpen(HSQUIRRELVM v) { if(!IsExporting) goto Error; const SQChar *What; sq_getstring(v, 2, &What); char Temp[260]; // disallow too long file paths if((strlen(What)+strlen(ExportPath)+1) > sizeof(Temp)) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "ExportOpen filename too long"); goto Error; } // disallow writing files outside of the directory the file is in if(!PathIsSafe(What)) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "ExportOpen filename attempting to write outside the file's directory"); goto Error; } // try to open a file if there's space for one for(int i=0; i < NUM_EXPORT_FILES; i++) if(!ExportFiles[i]) { sprintf(Temp, "%s%s", ExportPath, What); FILE *File = fopen(Temp, "wb"); if(!File) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "ExportOpen can't open %s", Temp); goto Error; } ExportFiles[i] = File; sq_pushinteger(v, i); return 1; } Error: sq_pushinteger(v, -1); return 1; }
int isFile(const char* fileName) { struct stat st; if(stat(fileName, &st)==0) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "stat() return 0 for file %s",fileName); if( (st.st_mode&S_IFREG) == S_IFREG ) { return(1); } } SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "stat() return -1 for file %s",fileName); return(0); }
void scene_save(Scene* scene, const char* path) { FILE *file = NULL; cmp_ctx_t context; file = fopen(path, "w+b"); if(file == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to open %s. ERROR: %d\n", path, errno); } cmp_init(&context, file, file_reader, file_writer); scene_serialize(scene, &context); fclose(file); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Scene `%s` serialized.\n", scene->path); }
void GPGMultiplayer::RejectConnectionRequest( const std::string& client_instance_id) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: Rejecting connection from %s", client_instance_id.c_str()); nearby_connections_->RejectConnectionRequest(client_instance_id); pthread_mutex_lock(&instance_mutex_); auto i = std::find(pending_instances_.begin(), pending_instances_.end(), client_instance_id); if (i != pending_instances_.end()) { pending_instances_.erase(i); } pthread_mutex_unlock(&instance_mutex_); }
Naglfar::Renderer::Renderer(Naglfar::Window *window) { renderer = window->GetRenderer(); glewInit(); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); /* Enable smooth shading */ glShadeModel( GL_SMOOTH ); /* Set the background black */ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); /* Depth buffer setup */ glClearDepth( 1.0f ); /* Enables Depth Testing */ glEnable( GL_DEPTH_TEST ); /* The Type Of Depth Test To Do */ glDepthFunc( GL_LEQUAL ); /* Really Nice Perspective Calculations */ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glContext = SDL_GL_CreateContext(window->GetWindow()); /* Setup our viewport. */ glViewport( 0, 0, ( GLsizei )800, ( GLsizei )600 ); /* change to the projection matrix and set our viewing volume. */ glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); /* Set our perspective */ gluPerspective( 45.0f, (800/600), 0.1f, 100.0f ); /* Make sure we're chaning the model view and not the projection */ glMatrixMode( GL_MODELVIEW ); /* Reset The View */ glLoadIdentity( ); if(GLEW_VERSION_3_0) { SDL_LogInfo(0, "Support for OpenGL 3.0 found!"); } }
void SayCommand::execute( vector<string> args ) { Network& network = Game::getInstance()->getNetwork(); NetEventPtr chatMsg; string msg; msg += "[SERVER] "; for( auto& arg : args ) msg += arg + " "; chatMsg = make_shared<NEChatMsg>( msg ); network.broadcastEvent( chatMsg ); SDL_LogInfo( SLC_CHAT, msg.c_str() ); }
static int sdl_init(void) { uint32_t subSystems = SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER; SDL_version compiledVers, linkedVers; if (SDL_WasInit(subSystems) != subSystems) { if (SDL_Init(subSystems) != 0) { SDL_LogCritical( SDL_LOG_CATEGORY_APPLICATION, "%s: SDL startup error..", LITE3D_CURRENT_FUNCTION); return LITE3D_FALSE; } } SDL_VERSION(&compiledVers); SDL_GetVersion(&linkedVers); if (compiledVers.major != linkedVers.major) { SDL_LogCritical( SDL_LOG_CATEGORY_APPLICATION, "SDL version mismatch.."); SDL_Quit(); return LITE3D_FALSE; } SDL_LogInfo( SDL_LOG_CATEGORY_APPLICATION, "SDL Version %d.%d.%d", (int) linkedVers.major, (int) linkedVers.minor, (int) linkedVers.patch); return LITE3D_TRUE; }
void GPGMultiplayer::DisconnectAll() { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPGMultiplayer: Disconnect all players"); // In case there are any connection requests outstanding, reject them. RejectAllConnectionRequests(); // Disconnect anyone we are connected to. pthread_mutex_lock(&instance_mutex_); for (const auto& instance : connected_instances_) { nearby_connections_->Disconnect(instance); } connected_instances_.clear(); UpdateConnectedInstances(); pthread_mutex_unlock(&instance_mutex_); if (state() == kConnected || state() == kConnectedWithDisconnections) { QueueNextState(kIdle); } }
void GPGManager::FetchPlayer() { game_services_->Players().FetchSelf([this]( const gpg::PlayerManager::FetchSelfResponse &fsr) mutable { pthread_mutex_lock(&players_mutex_); if (IsSuccess(fsr.status)) { gpg::Player *player_data = new gpg::Player(fsr.data); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "GPG: got player info. ID = %s, name = %s, avatar=%s", player_data->Id().c_str(), player_data->Name().c_str(), player_data->AvatarUrl(gpg::ImageResolution::HI_RES).c_str()); player_data_.reset(player_data); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "GPG: failed to get player info"); player_data_.reset(nullptr); } pthread_mutex_unlock(&players_mutex_); }); }