Search Results

Search found 15137 results on 606 pages for 'global state'.

Page 30/606 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • Saving an interface instance into a Bundle

    - by user22241
    All I've have an interface that allows me to switch between different scenes in my Android game. When the home key is pressed, I am saving all of my states (score, sprite positions etc) into a Bundle. When re-launching, I am restoring all my states and all is OK - however, I can't figure out how to save my 'Scene', thus when I return, it always starts at the default screen which is the 'Main Menu'. How would I go about saving my 'Scene' (into a Bundle)? Code import android.view.MotionEvent; public interface Scene{ void render(); void updateLogic(); boolean onTouchEvent(MotionEvent event); } I assume the interface is the relevant piece of code which is why I've posted that snippet. I set my scene like so: ('options' is an object of my Options class which extends MainMenu (Another custom class) which, in turn implements the interface 'Scene') SceneManager.getInstance().setCurrentScene(options); //Current scene is optionscreen

    Read the article

  • Why does a proportional controller have a steady state error?

    - by Qantas 94 Heavy
    I've read about feedback loops, how much this steady state error is for a given gain and what to do to remove this steady state error (add integral and/or derivative gains to the controller), but I don't understand at all why this steady state error occurs in the first place. If I understand how a proportional control works correctly, the output is equal to the current output plus the error, multiplied by the proportional gain (Kp). However, wouldn't the error slowly diminish over time as it is added (reaching 0 at infinite time), not have a steady state error? From my confusion, it seems I'm completely misunderstanding how it works - a proper explanation of how this steady state error eventuates would be fantastic.

    Read the article

  • ssao implementation

    - by Irbis
    I try to implement a ssao based on this tutorial: link I use a deferred rendering and world coordinates for shading calculations. When saving gbuffer a vertex shader output looks like this: worldPosition = vec3(ModelMatrix * vec4(inPosition, 1.0)); normal = normalize(normalModelMatrix * inNormal); gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(inPosition, 1.0); Next for a ssao calculations I render a scene as a full screen quad and I save an occlusion parameter in a texture. (Vertex positions in the world space: link Normals in the world space: link) SSAO implementation: subroutine (RenderPassType) void ssao() { vec2 texCoord = CalcTexCoord(); vec3 worldPos = texture(texture0, texCoord).xyz; vec3 normal = normalize(texture(texture1, texCoord).xyz); vec2 noiseScale = vec2(screenSize.x / 4, screenSize.y / 4); vec3 rvec = texture(texture2, texCoord * noiseScale).xyz; vec3 tangent = normalize(rvec - normal * dot(rvec, normal)); vec3 bitangent = cross(normal, tangent); mat3 tbn = mat3(tangent, bitangent, normal); float occlusion = 0.0; float radius = 4.0; for (int i = 0; i < kernelSize; ++i) { vec3 pix = tbn * kernel[i]; pix = pix * radius + worldPos; vec4 offset = vec4(pix, 1.0); offset = ProjectionMatrix * ViewMatrix * offset; offset.xy /= offset.w; offset.xy = offset.xy * 0.5 + 0.5; float sample_depth = texture(texture0, offset.xy).z; float range_check = abs(worldPos.z - sample_depth) < radius ? 1.0 : 0.0; occlusion += (sample_depth <= pix.z ? 1.0 : 0.0); } outputColor = vec4(occlusion, occlusion, occlusion, 1); } That code gives following results: camera looking towards -z world space: link camera looking towards +z world space: link I wonder if it is possible to use world coordinates in the above code ? When I move camera I get different results because world space positions don't change. Can I treat worldPos.z as a linear depth ? What should I change to get a correct results ? I except the white areas in place of occlusion, so the ground should has the white areas only near to the object.

    Read the article

  • HLSL: An array of textures and sampler states

    - by nate142
    The shader must switch between multiple textures depending on the Alpha value of the original texture for each pixel. Now this would word fine if I didn't have to worry about SamplerStates. I have created my array of textures and can select a texture based on the Alpha value of the pixel. But how do I create an Array of SamplerStates and link it to my array of textures? I attempted to treat the SamplerState as a function by adding the (int i) but that didn't work. Also I can't use Texture.Sample since this is shader model 2.0. //shader model 2.0 (DX9) texture subTextures[255]; SamplerState MeshTextureSampler(int i) { Texture = (subTextures[i]); }; float4 SampleCompoundTexture(float2 texCoord, float4 diffuse) { float4 SelectedColor = SAMPLE_TEXTURE(Texture, texCoord); int i = SelectedColor.a; texture SelectedTx = subTextures[i]; return tex2D(MeshTextureSampler(i), texCoord) * diffuse; }

    Read the article

  • XNA Monogame GameState Management not deserilaizing

    - by Pectus Excavatum
    I am having some trouble serializing/deserializing in a little game I am doing to teach myself monogame. Basically, I am using the gamestatemnanagement resources common to monogame (screen manager etc). Then I am serializing my screen manager component and all associated screens in the OnDeactivated method: protected override void OnDeactivated(Object sender, EventArgs args) { foreach (GameplayScreen screen in mScreenManager.GetScreens()) { DataManager.SaveData(screen.Level.LevelData); } mScreenManager.SerializeState(); } The Save data bit is to do with something else. Then I then override OnActivated to de serialize protected override void OnActivated(Object sender, EventArgs args) { //System.Diagnostics.Debug.WriteLine("here activating"); mScreenManager.DeserializeState(); } However, when this runs it just loads a blank screen - it goes into the game initialize and the game draw method, but doesnt go down into the screens initialize or draw methods. I have no idea why this might be - any help would be greatly appreciated. I am not the only one who has encountered this - I found this post also - https://monogame.codeplex.com/discussions/391117

    Read the article

  • processing gamestate with a window of commands across time?

    - by rook2pawn
    I have clients sending client updates at a 100ms intervals. i pool the command inputs and create a client command frame. the commands come into the server in these windows and i tag them across time as they come in. when i do a server tick i intend to process this list of commands i.e. [ {command:'duck',timestamp:350,player:'a'}, {command:'shoot',timestamp:395,player:'b'}, {command:'move', timestamp:410,player:'c'} {command:'cover',timestamp:420,player:'a'} ] how would i efficiently update the gamestate based on this list? the two solutions i see are 1) simulate time via direct equation to figure out how far everyone would move or change as if the real gameupdate was ticking on the worldtick..but then unforseen events that would normally trigger during real update would not get triggered such as powerups or collissions 2) prepare to run the worldupdate multiple times and figure out which commands get sent to which worldupdate. this seems better but a little more costly is there a canonical way to do this?

    Read the article

  • In Ruby, how to implement global behaviour?

    - by Gordon McAllister
    Hi all, I want to implement the concept of a Workspace. This is a global concept - all other code will interact with one instance of this Workspace. The Workspace will be responsible for maintaining the current system state (i.e. interacting with the system model, persisting the system state etc) So what's the best design strategy for my Workspace, bearing in mind this will have to be testable (using RSpec now, but happy to look at alternatives). Having read thru some open source projects out there and I've seen 3 strategies. None of which I can identify as "the best practice". They are: Include the singleton class. But how testable is this? Will the global state of Workspace change between tests? Implemented all behaviour as class methods. Again how do you test this? Implemented all behaviour as module methods. Not sure about this one at all! Which is best? Or is there another way? Thanks, Gordon

    Read the article

  • Where is the .NET Framework Global Assembly Cache?

    - by Carlos Loth
    Hi, I installed the VS2010 and .NET 4.0, then I compiled an assembly and ran the gacutil using the exe available on %ProgramFiles%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools The output of the executable said the assembly was sucessfully installed on Global Assembly Cache. However, when I go to %WINDIR%\assembly folder I cannot find the assembly I installed using the .NET Framework 4.0 gacutil. I've seen some posts saying the .NET Framework 4.0 has a separated GAC, but what I haven't found was where it is located. May someone to help me to check where can I see the Global Assembly Cache of .NET Framework, as it used to work on previous version (%WINDIR%\assembly)?

    Read the article

  • WCF Global(.asax) Behavior

    - by Theofanis Pantelides
    Hi, I want to create a global option that when a REST call contains &format=json to output the response as a JSON string. If I enter the following String in my method it works: WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json; However, if I add this line, anywhere in my Global.asax file, I get a nullException for Current Context: String format = ""; if (HttpContext.Current.Request.QueryString["format"] != null) format = HttpContext.Current.Request.QueryString["format"]; if (String.Equals("json", format, StringComparison.OrdinalIgnoreCase)) System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.Format = System.ServiceModel.Web.WebMessageFormat.Json; The exception is triggered here: System.ServiceModel.Web.WebOperationContext.Current Anyone know how I can add this functionality globally (WCF)?

    Read the article

  • How to set global hook for WH_CALLWNDPROCRET ?

    - by user261882
    Hello I want to set global hook that tracks which application is active. In my main program I am doing the foloowing : HMODULE mod=::GetModuleHandle(L"HookProcDll"); HHOOK rslt=(WH_CALLWNDPROCRET,MyCallWndRetProc,mod,0); The hook procedure which is called MyCallWndRetProc exists in separate dll called HookProcDll.dll. The hook procedure is watching for WM_ACTIVATE message. The thing is that the code stucks in the line where I am setting the hook, i.e in the line where I am calling ::SetWindowsHookEx. And then Windows gets unresponsive, my task bar disappears and I am left with empty desktop. Then I must reset the computer. What am doing wrong, why Windows get unresponsive ? and Do I need to inject HookProcDll.dll in every process in order to set the global hook, and how can I do that ?

    Read the article

  • Global WH_CBT hook DLL is loaded into some processes only

    - by kriau
    The main program calls the function SetHook in the wi.dll to install global WH_CBT hook. bool WI_API SetHook() { if (!g_hHook) { g_hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC) CBTProc, g_hInstDll, 0); } return g_hHook != NULL; } I presume after installing global hook, wi.dll should be loaded into each process' address space. However wi.dll is loaded in to some processes only. For example, if I start Skype, MS Word I can see that wi.dll is loaded into these processes as well (using Process Explorer), however if I run Firefox, uTorrent, Adobe Reader then wi.dll is not loaded into these processes. I'm using W7 64-bit, main program and wi.dll is 32-bit, all programs mentioned here is 32-bit programs as well. Any ideas why that happens? Thanks in advance.

    Read the article

  • [JavaScript] Global variables across multiple files

    - by Goro
    Hello, A bunch of my JavaScript code is in an external file called helpers.js. Inside the HTML that calls this JavaScript code I find myself in need of knowing if a certain function from helpers.js has been called. I have attempted to create a global variable by defining: var myFunctionTag = true; In global scope both in my HTML code and in helpers.js. Heres what my html code looks like: <html> ... <script type='text/javascript' src='js/helpers.js'></script> ... <script> var myFunctionTag = false; ... //I try to use myFunctionTag here but it is always false, even though it has been se t to 'true' in helpers.js </script> Is what I am trying to do even doable? Thanks,

    Read the article

  • How do I change variables from different classes?

    - by Dan T
    Before I delve into it, I'm very new to Android and I have just started learning Java last month. I've hit bumps while trying to develop my first simple app. Most of these hurdles were jumped thanks to random tutorials online. MY CODE IS VERY MESSY. Any tips are appreciated. The question above is quite broad, but this is what I want to do: It's a essentially a blood alcohol content calculator / drink keeper-tracker. Basic layout: http://i.imgur.com/JGuh7.jpg The buttons along the bottom are just regular buttons, not ImageButtons (had problems with that) Here's some example code of one: <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_marginRight="5dp" android:background="@drawable/addbeer"/> The buttons and TextView are all in main.xml. I have variables defined in a class called Global.java: package com.dantoth.drinkingbuddy; import android.app.Activity; public class Global extends Activity{ public static double StandardDrinks = 0; public static double BeerOunces = 12; public static double BeerPercentAlcohol = .05; public static double BeerDrink = BeerOunces * BeerPercentAlcohol; public static double BeerDrinkFinal = BeerDrink * 1.6666666; public static double ShotOunces = 1.5; public static double ShotPercentAlcohol = .4; public static double ShotDrink = ShotOunces * ShotPercentAlcohol; public static double ShotDrinkFinal = ShotDrink * 1.6666666; public static double WineOunces = 5; public static double WinePercentAlcohol = .12; public static double WineDrink = WineOunces * WinePercentAlcohol; public static double WineDrinkFinal = WineDrink * 1.6666666; public static double OtherOunces; public static double OtherPercentAlcohol; public static double OtherDrink = OtherOunces * (OtherPercentAlcohol * .01); public static double OtherDrinkFinal = OtherDrink * 1.6666666; public static double GenderConstant = 7.5; //9 for female public static double Weight = 180; public static double TimeDrinking = 60; public static double Hours = TimeDrinking / 60; public static double Bac = ((StandardDrinks / 2) * (GenderConstant / Weight)) - (0.017 * Hours); } The last variable is the important part. It calculates your BAC based on the factors involved. When I press the add beer button (Button01) I make it add 1 to StandardDrinks, simulating drinking one beer. The other variables in the Bac formula have values assigned to them in Global.java. The code that makes the beer button do stuff is in my regular class, drinkingbuddy.java: public class DrinkingBuddy extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.Button01); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Global.StandardDrinks = Global.StandardDrinks + Global.BeerDrinkFinal; Toast.makeText(DrinkingBuddy.this, "Mmmm... Beer", Toast.LENGTH_SHORT).show(); } }); By my perception, StandardDrinks should now have a value of 1. However, when I click the Calculate BAC button (Button05) it merely outputs the variable Bac as if StandardDrinks was still set to 0. Here is the code for the Calculate BAC button (Button05): Button button4 = (Button) findViewById(R.id.Button05); button4.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TextView texty; texty = (TextView) findViewById(R.id.texty1); texty.setText("Your BAC is " + Global.Bac ); } }); It outputs the following to the text view: "Your BAC is -0.017". This is the Bac value for if StandardDrinks was still 0, so obviously there is some problem communicating between the classes. Can anyone help me?? The other elements of the formula (weight, time spent drinking, and the alcohol %'s and such) are variables because I will ultimately allow the user to change those values in the settings. I've heard around the water cooler that global variables are not good programming style, but this is the closest I've come to getting it to work. Any other ways of doing it are very much welcomed!

    Read the article

  • Does .NET Regex support global matching?

    - by Dave
    I haven't been able to find anything online regarding this. There's RegexOptions, but it doesn't have Global as one of its options. The inline modifiers list also doesn't mention global matching. In a nutshell, I've got a regex to parse something like --arga= "arg1" --argb ="arg2" into separate argument name/value pairs using this regex: --(\\w+)\\s*=\\s*\"(\\w+)\"\\s* but the .NET Regex class doesn't do it globally (iteratively). So in order for me to get this to work, I'd have to do a match, then remove this from the argument string, and loop over and over again until I've exhausted all of the arguments. It would be nicer to run the regex once, and then loop over the match groups to get the name value pairs. Is this possible? What am I missing?

    Read the article

  • Creating an URL without global variables

    - by dygi
    I have a code like this below, which gives me a $link that equals to: http://mydomain.com/image/photo.JPG if (!empty($_SESSION['item'][$i])) { $path = dirname(__FILE__).'/image/'.basename($_SESSION['item'][$i]); if (move_uploaded_file($_SESSION['item'][$i], $path)) global $url; if ( $url ) { $link = $url.'/image/'.basename($_SESSION['item'][$i]); echo "<td><img src='" . $link . "' width='50' height='50' /></td>"; } } I wonder, how should I properly ommit using global variable here to achieve the same result.

    Read the article

  • asp.net MVC - how to get complete local and global resources

    - by Buthrakaur
    I'm localizing application and need to provide JSON representation of local and global resources for JS part of application for all views. My current idea is I'd implement HtmlHelper extension methods like GetLocalResourcesJSON/GetGlobalResourcesJSON which should encode all resource keys+values and return them JSON encoded as string (I'd implement caching as well). At the moment I'm able to retrieve single specific key from global or local resource belonging to current view (using httpContext.GetGlobalResourceObject/GetLocalResourceObject), but I'm not able to find out how to retrieve whole resource object and iterate all its keys+values. Is there any method how to achieve this? it looks like ResourceProviderFactory could be the the key to this problem, but it's not accessible publicly anywhere. I could instantiate ResourceExpressionBuilder and use reflection to retrieve the provider using GetLocal/GlobalResourceProvider() methods, but I don't like using reflection here at all...

    Read the article

  • Global qualification in a class declarations class-head

    - by gf
    We found something similar to the following (don't ask ...): namespace N { struct A { struct B; }; } struct A { struct B; }; using namespace N; struct ::A::B {}; // <- point of interest Interestingly, this compiles fine with VS2005, icc 11.1 and Comeau (online), but fails with GCC: global qualification of class name is invalid before '{' token From C++03, Annex A, it seems to me like GCC is right: the class-head can consist of nested-name-specifier and identifier nested-name-specifier can't begin with a global qualification (::) obviously, neither can identifier ... or am i overlooking something?

    Read the article

  • google app engine persistent globals

    - by Joey
    Hi, I'm looking for a way to keep the equivalent of persistent global variables in app engine (python). What I'm doing is creating a global kind that I initialize once (i.e. when I reset all my database objects when I'm testing). I have things in there like global counters, or the next id to assign certain kinds I create. Is this a decent way to do this sort of thing or is there generally another approach that is used?

    Read the article

  • Why isn't WH_MOUSE hook global anymore?

    - by Valentin Galea
    I have this global mouse hook setup in a DLL that watches for mouse gestures. Everything works perfectly but with a hook set for WH_MOUSE_LL which is a low-level hook and one that doesn't need to be in an external injectable DLL. Once I switch - to the more suitable one would say - WH_MOUSE mouse hook, everything falls apart. Once I click outside my main application (the one that installs the hook), the hook gets corrupted - ::UnhookWindowsHookEx will fail. I only found this guy saying at experts exchange: "No way, at least under Windows XP + SVP2 WH_MOUSE won't go global, you must use WH_MOUSE_LL instead." I setup the hooks correctly: in a DLL using a shared data section, posting and not sending messages from the hook proceduce. Why has this changed? And why is not documented? Anyone encountered this? Thanks! BTW: I've reverse engineered a bit the popular StrokeIt application and it uses a combination of WH_GETMESSAGE and WH_MOUSE hooks and still works on XP/Vista...

    Read the article

  • Error : The Type Initializer of Deamon.Global threw an exception in c#

    - by srk
    I am using the below class file, where some variables are declared to use in the entire application. Now i used that variable [BlockLogOut] in another class file to make the value True. I just put this below line and getting error in it.. "TypeInitializationException" Global.BlockLogOut = True; The wired thing is, it was working fine for many months and i am getting this error now on the above line. Of course i was modifying some other stuffs in the application, but surely not this class file. What would have been the problem ? namespace Daemon { class Global { public static bool BlockLogOut = false; } }

    Read the article

  • Unable to access global variable defined in settings.php [Drupal]

    - by Senthil
    I am developing a website using Drupal 6.16. I want to define a variable in settings.php like $ge_path = 'some/path/here'; And I want to use it inside my modules. function mymodule_block(....) { global $ge_path; $fullPath = $ge_path . '/another/path'; doSomething($fullPath); } But I am getting NULL as the value of $ge_path. Why am I not able to access the global variable defines in settings.php? How can I get the proper value inside my module functions? The funny thing is, I am able to access $db_url['default'] and $db_url['mydatabase'] etc.. which are defined just two lines above $ge_path in settings.php!

    Read the article

  • Oracle global lock across process

    - by Jimm
    I would like to synchronize access to a particular insert. Hence, if multiple applications execute this "one" insert, the inserts should happen one at a time. The reason behind synchronization is that there should only be ONE instance of this entity. If multiple applications try to insert the same entity,only one should succeed and others should fail. One option considered was to create a composite unique key, that would uniquely identify the entity and rely on unique constraint. For some reasons, the dba department rejected this idea. Other option that came to my mind was to create a stored proc for the insert and if the stored proc can obtain a global lock, then multiple applications invoking the same stored proc, though in their seperate database sessions, it is expected that the stored proc can obtain a global lock and hence serialize the inserts. My question is it possible to for a stored proc in oracle version 10/11, to obtain such a lock and any pointers to documentation would be helpful.

    Read the article

  • New to C# and trying to use a global variable

    - by Andrew G. Johnson
    Is it possible to use global variables in C#? I'm coming from mainly a PHP background so variables are either accessible everywhere or just a global definition away. My main issue is I have a User class that I built myself to wrap around the current users table on my company's database. I am defining it in the MasterPage but can't seem to access it from the actual pages (I don't know if there's a better word to describe them but they are the pages that inherit the styles and format from the MasterPage) Any general tips or implementation practices for me? EDIT: here's some code snippets of what I'm trying to do: Site.master.cs public partial class SiteMaster : System.Web.UI.MasterPage { public User user = new User(); } logout.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="logout.aspx.cs" Inherits="logout" %> <%@ MasterType virtualPath="~/Site.master"%> logout.aspx.cs public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { User user = Master.user; } }

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >