Search Results

Search found 711 results on 29 pages for 'pos'.

Page 9/29 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • no instance of overloaded function getline c++

    - by Dave
    I'm a bit confused as to what i have incorrect with my script that is causing this error. I have a function which calls a fill for game settings but it doesn't like my getline. Also i should mention these are the files i have included for it: #include <fstream> #include <cctype> #include <map> #include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std;' This is what i have: std::map<string, string> loadSettings(std::string file){ ifstream file(file); string line; std::map<string, string> config; while(std::getline(file, line)) { int pos = line.find('='); if(pos != string::npos) { string key = line.substr(0, pos); string value = line.substr(pos + 1); config[trim(key)] = trim(value); } } return (config); } The function is called like this from my main.cpp //load settings for game std::map<string, string> config = loadSettings("settings.txt"); //load theme for game std::map<string, string> theme = loadSettings("theme.txt"); Where did i go wrong ? Please help! The error: settings.h(61): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::string'

    Read the article

  • How to do "map chunks", like terraria or minecraft maps?

    - by O'poil
    Due to performance issues, I have to cut my maps into chunks. I manage the maps in this way: listMap[x][y] = new Tile (x,y); I tried in vain to cut this list for several "chunk" to avoid loading all the map because the fps are not very high with large map. And yet, when I update or Draw I do it with a little tile range. Here is how I proceed: foreach (List<Tile> list in listMap) { foreach (Tile leTile in list) { if ((leTile.Position.X < screenWidth + hero.Pos.X) && (leTile.Position.X > hero.Pos.X - tileSize) && (leTile.Position.Y < screenHeight + hero.Pos.Y) && (leTile.Position.Y > hero.Pos.Y - tileSize) ) { leTile.Draw(spriteBatch, gameTime); } } } (and the same thing, for the update method). So I try to learn with games like minecraft or terraria, and any two manages maps much larger than mine, without the slightest drop of fps. And apparently, they load "chunks". What I would like to understand is how to cut my list in Chunk, and how to display depending on the position of my character. I try many things without success. Thank you in advance for putting me on the right track! Ps : Again, sorry for my English :'( Pps : I'm not an experimented developer ;)

    Read the article

  • plot 4 different plots inside 1 pdf

    - by ifreak
    I have 2 data frames which i want to generate 3 plots from them and place them inside 1 pdf file as a single column. i want all the plots to have the same x-axis limits(basically the same x-axis) even thought they differ in the name and how they were obtained. the dataframes looks something like that: d1 X Y Z 0.04939317 -0.4622222 13651 0.03202451 -0.4261000 13401 0.09950793 -0.3233025 13151 0.11548556 -0.4637981 12486 0.09817597 -0.4751886 12236 0.15770701 -0.5819355 11986 and d2 V0 V1 V2 V3 sign 1 1 0.379 0.612 pos 2 1 0.378 0.620 pos 3 1 0.578 0.571 neg 4 1 0.978 0.561 pos 5 1 0.758 0.261 neg 6 1 0.378 0.126 neg P.S : both data frames are bigger than this, this is only a part of them V0, V1 and Z range from 1 to 20000 the plots that i created are : From d2 d2plot=ggplot(d1, aes(V0,V1, fill=sign)) + geom_tile()+ scale_fill_manual(values = c("neg" = "yellow", "pos"="red")) +geom_vline(xintercept =10000 ) +geom_text(mapping=aes(x=10000,y=0, label="Stop"), size=4, angle=90, vjust=-0.4, hjust=0) From d1 d1plot = ggplot(d2) + geom_errorbarh(aes(x=z,xmin=z-50,xmax=z+50, y=Y, height = 0.02),color="red")+ opts(legend.position = "none") +geom_vline(xintercept = 10000) +geom_text(mapping=aes(x=10000,y=-0.3, label="Stop"), size=4, angle=90, vjust=-0.4, hjust=0) i've tried grid.arrange(d1plot,d2plot,ncol=1) but the x-axis is different for each plot, i tried changing the aspect ratio, but this will change the y-axis ..i've also tried to use facet_wrap but the problem that my x-axis values have different values, i just want the limits and breaks to be the same and the plots all be aligned in 1 column based on 1 x-axis to comapre the value of the statistical methods in an easy way.

    Read the article

  • Issues passing values to shader

    - by numerical25
    I am having issues passing values to my shader. My application compiles fine, but my cube object won't shade. Below is majority of my code. Most of my code for communicating with my shader is in createObject method myGame.cpp #include "MyGame.h" #include "OneColorCube.h" /* This code sets a projection and shows a turning cube. What has been added is the project, rotation and a rasterizer to change the rasterization of the cube. The issue that was going on was something with the effect file which was causing the vertices not to be rendered correctly.*/ typedef struct { ID3D10Effect* pEffect; ID3D10EffectTechnique* pTechnique; //vertex information ID3D10Buffer* pVertexBuffer; ID3D10Buffer* pIndicesBuffer; ID3D10InputLayout* pVertexLayout; UINT numVertices; UINT numIndices; }ModelObject; ModelObject modelObject; // World Matrix D3DXMATRIX WorldMatrix; // View Matrix D3DXMATRIX ViewMatrix; // Projection Matrix D3DXMATRIX ProjectionMatrix; ID3D10EffectMatrixVariable* pProjectionMatrixVariable = NULL; ID3D10EffectVectorVariable* pLightVarible = NULL; bool MyGame::InitDirect3D() { if(!DX3dApp::InitDirect3D()) { return false; } D3D10_RASTERIZER_DESC rastDesc; rastDesc.FillMode = D3D10_FILL_WIREFRAME; rastDesc.CullMode = D3D10_CULL_FRONT; rastDesc.FrontCounterClockwise = true; rastDesc.DepthBias = false; rastDesc.DepthBiasClamp = 0; rastDesc.SlopeScaledDepthBias = 0; rastDesc.DepthClipEnable = false; rastDesc.ScissorEnable = false; rastDesc.MultisampleEnable = false; rastDesc.AntialiasedLineEnable = false; ID3D10RasterizerState *g_pRasterizerState; mpD3DDevice->CreateRasterizerState(&rastDesc, &g_pRasterizerState); //mpD3DDevice->RSSetState(g_pRasterizerState); // Set up the World Matrix D3DXMatrixIdentity(&WorldMatrix); D3DXMatrixLookAtLH(&ViewMatrix, new D3DXVECTOR3(0.0f, 10.0f, -20.0f), new D3DXVECTOR3(0.0f, 0.0f, 0.0f), new D3DXVECTOR3(0.0f, 1.0f, 0.0f)); // Set up the projection matrix D3DXMatrixPerspectiveFovLH(&ProjectionMatrix, (float)D3DX_PI * 0.5f, (float)mWidth/(float)mHeight, 0.1f, 100.0f); if(!CreateObject()) { return false; } return true; } //These are actions that take place after the clearing of the buffer and before the present void MyGame::GameDraw() { static float rotationAngleY = 15.0f; static float rotationAngleX = 0.0f; static D3DXMATRIX rotationXMatrix; static D3DXMATRIX rotationYMatrix; // create the rotation matrix using the rotation angle D3DXMatrixRotationY(&rotationYMatrix, rotationAngleY); D3DXMatrixRotationX(&rotationXMatrix, rotationAngleX); //rotationAngleY += (float)D3DX_PI * 0.002f; //rotationAngleX += (float)D3DX_PI * 0.001f; WorldMatrix = rotationYMatrix * rotationXMatrix; // Set the input layout mpD3DDevice->IASetInputLayout(modelObject.pVertexLayout); // Set vertex buffer UINT stride = sizeof(VertexPos); UINT offset = 0; mpD3DDevice->IASetVertexBuffers(0, 1, &modelObject.pVertexBuffer, &stride, &offset); // Set primitive topology mpD3DDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //ViewMatrix._43 += 0.005f; // Combine and send the final matrix to the shader D3DXMATRIX finalMatrix = (WorldMatrix * ViewMatrix * ProjectionMatrix); pProjectionMatrixVariable->SetMatrix((float*)&finalMatrix); // make sure modelObject is valid // Render a model object D3D10_TECHNIQUE_DESC techniqueDescription; modelObject.pTechnique->GetDesc(&techniqueDescription); // Loop through the technique passes for(UINT p=0; p < techniqueDescription.Passes; ++p) { modelObject.pTechnique->GetPassByIndex(p)->Apply(0); // draw the cube using all 36 vertices and 12 triangles mpD3DDevice->Draw(36,0); } } //Render actually incapsulates Gamedraw, so you can call data before you actually clear the buffer or after you //present data void MyGame::Render() { DX3dApp::Render(); } bool MyGame::CreateObject() { //Create Layout D3D10_INPUT_ELEMENT_DESC layout[] = { {"POSITION",0,DXGI_FORMAT_R32G32B32_FLOAT, 0 , 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, {"COLOR",0,DXGI_FORMAT_R32G32B32A32_FLOAT, 0 , 12, D3D10_INPUT_PER_VERTEX_DATA, 0}, {"NORMAL",0,DXGI_FORMAT_R32G32B32A32_FLOAT, 0 , 24, D3D10_INPUT_PER_VERTEX_DATA, 0} }; UINT numElements = (sizeof(layout)/sizeof(layout[0])); modelObject.numVertices = sizeof(vertices)/sizeof(VertexPos); for(int i = 0; i < modelObject.numVertices; i += 3) { D3DXVECTOR3 out; D3DXVECTOR3 v1 = vertices[0 + i].pos; D3DXVECTOR3 v2 = vertices[1 + i].pos; D3DXVECTOR3 v3 = vertices[2 + i].pos; D3DXVECTOR3 u = v2 - v1; D3DXVECTOR3 v = v3 - v1; D3DXVec3Cross(&out, &u, &v); D3DXVec3Normalize(&out, &out); vertices[0 + i].normal = out; vertices[1 + i].normal = out; vertices[2 + i].normal = out; } //Create buffer desc D3D10_BUFFER_DESC bufferDesc; bufferDesc.Usage = D3D10_USAGE_DEFAULT; bufferDesc.ByteWidth = sizeof(VertexPos) * modelObject.numVertices; bufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER; bufferDesc.CPUAccessFlags = 0; bufferDesc.MiscFlags = 0; D3D10_SUBRESOURCE_DATA initData; initData.pSysMem = vertices; //Create the buffer HRESULT hr = mpD3DDevice->CreateBuffer(&bufferDesc, &initData, &modelObject.pVertexBuffer); if(FAILED(hr)) return false; /* //Create indices DWORD indices[] = { 0,1,3, 1,2,3 }; ModelObject.numIndices = sizeof(indices)/sizeof(DWORD); bufferDesc.ByteWidth = sizeof(DWORD) * ModelObject.numIndices; bufferDesc.BindFlags = D3D10_BIND_INDEX_BUFFER; initData.pSysMem = indices; hr = mpD3DDevice->CreateBuffer(&bufferDesc, &initData, &ModelObject.pIndicesBuffer); if(FAILED(hr)) return false;*/ ///////////////////////////////////////////////////////////////////////////// //Set up fx files LPCWSTR effectFilename = L"effect.fx"; modelObject.pEffect = NULL; hr = D3DX10CreateEffectFromFile(effectFilename, NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, mpD3DDevice, NULL, NULL, &modelObject.pEffect, NULL, NULL); if(FAILED(hr)) return false; pProjectionMatrixVariable = modelObject.pEffect->GetVariableByName("Projection")->AsMatrix(); pLightVarible = modelObject.pEffect->GetVariableByName("lightSource")->AsVector(); //Dont sweat the technique. Get it! LPCSTR effectTechniqueName = "Render"; D3DXVECTOR3 vLight(10.0f, 10.0f, 10.0f); pLightVarible->SetFloatVector(vLight); modelObject.pTechnique = modelObject.pEffect->GetTechniqueByName(effectTechniqueName); if(modelObject.pTechnique == NULL) return false; //Create Vertex layout D3D10_PASS_DESC passDesc; modelObject.pTechnique->GetPassByIndex(0)->GetDesc(&passDesc); hr = mpD3DDevice->CreateInputLayout(layout, numElements, passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &modelObject.pVertexLayout); if(FAILED(hr)) return false; return true; } And below is my shader effect.fx matrix Projection; float3 lightSource; float4 lightColor = {0.5, 0.5, 0.5, 0.5}; // PS_INPUT - input variables to the pixel shader // This struct is created and fill in by the // vertex shader struct PS_INPUT { float4 Pos : SV_POSITION; float4 Color : COLOR0; float4 Normal : NORMAL; }; //////////////////////////////////////////////// // Vertex Shader - Main Function /////////////////////////////////////////////// PS_INPUT VS(float4 Pos : POSITION, float4 Color : COLOR, float4 Normal : NORMAL) { PS_INPUT psInput; // Pass through both the position and the color psInput.Pos = mul( Pos, Projection ); psInput.Color = Color; psInput.Normal = Normal; return psInput; } /////////////////////////////////////////////// // Pixel Shader /////////////////////////////////////////////// float4 PS(PS_INPUT psInput) : SV_Target { float4 finalColor = 0; finalColor = saturate(dot(lightSource, psInput.Normal) * lightColor); return finalColor; } // Define the technique technique10 Render { pass P0 { SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetGeometryShader( NULL ); SetPixelShader( CompileShader( ps_4_0, PS() ) ); } }

    Read the article

  • Bladecenter-E Power Module fault

    - by Lihnjo
    We have problem on IBM Bladecenter-E Critical Events Power module 2 is off. DC fault. Power module 4 is off. DC fault. Warnings and System Events Insufficient chassis power to support redundancy What is the best solution for this problem? Thanks AMM Service Data Help SPAPP Capture Available 10/13/2010 17:03:47 1090347 bytes Time: 11/19/2012 11:02:31 UUID: 42E1 5D2F D7BF 41A6 A4A2 48D1 3FB7 0540 MAC Address xx:xx:xx:xx:xx:xx MM Information Name: nnnnn Contact: aaa, bbb, ccc, England Location: [email protected] IP address: 111.222.333.444 Date Time Information GMT offset: +1:00 - Central Europe Time (Western Europe, Algeria, Nigeria, Angola) Adjust for DST: Yes NTP: Enabled NTP Hostname/IP: 111.222.333.444 System Health: Critical System Status Summary One or more monitored parameters are abnormal. Critical Events Power module 2 is off. DC fault. Power module 4 is off. DC fault. Warnings and System Events Insufficient chassis power to support redundancy CHASSIS (BladeCenter-E) in CHASSIS slot: 01 TopoPath is "CHASSIS[1]". Description : BladeCenter-E Width : 1 Sub Type : BladeCenter (BC) Power Mode : 220 v KVM Owner : CHASSIS[1]/BLADE[9] MT Owner : CHASSIS[1]/MGMT_MOD[1] Component Type : CHASSIS Inventory: VPD ID: 336 (decimal) POS ID EXT: 0 (decimal) POS ID: 8 (decimal) Machine Type/Model: 86773RG Machine Serial Number: 99ZL816 Part Number: 39R8561 FRU Number: 39R8563 FRU Serial Number: YK109174W1HV Manufacturer ID: IBM Hardware Revision: 3 (decimal) Manufacture Date: 18 (wk), 07 (yr) UUID: 42E1 5D2F D7BF 41A6 A4A2 48D1 3FB7 0540 (hex) Type Code: 97 (decimal) Sub-type Code: 0 (decimal) IANA Num: 336 (decimal) Product ID: 8 (decimal) Manufacturer Sub ID: FOXC Enviroment data: -------------- Type: : POWER_USAGE Unit: : WATTS Reading: : 0xa Sensor Label: : Midplane Sensor ID: : 0x0 MGMT MOD (Advanced Management Module) in MGMT_MOD slot: 01 TopoPath is "CHASSIS[1]/MGMT_MOD[1]". Description : Advanced Management Module Name : kant Width : 1 Component Role : Primary Component Type : MGMT MOD Insert Time : 28050132 Inventory: VPD ID: 288 (decimal) POS ID EXT: 0 (decimal) POS ID: 4 (decimal) Part Number: 39Y9659 FRU Number: 39Y9661 FRU Serial Number: YK11836CE2RC Manufacturer ID: IBM Hardware Revision: 4 (decimal) Manufacture Date: 50 (wk), 06 (yr) UUID: 1D95 9937 8CA5 11DB 9499 0014 5EDF 1C98 (hex) Type Code: 81 (decimal) Sub-type Code: 1 (decimal) IANA Num: 20301 (decimal) Product ID: 65 (decimal) Manufacturer Sub ID: ASUS Firmware data: Type : AMM firmware Build ID : BPET50P File Name : CNETCMUS.PKT Release Date : 03/26/2010 Release Level : 50 Revision - Major: 80 Port info: ======================================================== Topology Path ID : 1 Label : External Phy Orientation : EXTERNAL Port Number : 1 Type : MGT Physical Meidum : Copper Number of Link Intferfaces : 1 ------------------------------------ Link Ifc ID Number : 1 Link Ifc Transport Protocol : ENET Link Ifc Addr Type : MAC Link Ifc Burned-in Addr : xx:xx:xx:xx:xx:xx Link Ifc Admin Addr : 00:00:00:00:00:00 Link Ifc Addr in use : xx:xx:xx:xx:xx:xx ---------------------------------------------------------- Configuration behaviors: Save Only Enviroment data: -------------- Type: : TEMPERATURE Unit: : DEGREES_C Reading: : 38.00 Sensor Label: : MM Ambient Sensor ID: : 0x0 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +4.81 Sensor Label: : +5V Sensor ID: : 0x1b -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +3.26 Sensor Label: : +3.3V Sensor ID: : 0x19 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +11.97 Sensor Label: : +12V Sensor ID: : 0x16 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : -4.88 Sensor Label: : -5V Sensor ID: : 0x1e -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +2.47 Sensor Label: : +2.5V Sensor ID: : 0x18 -------------- Type: : VOLTAGE Unit: : VOLTS Reading: : +1.76 Sensor Label: : +1.8V Sensor ID: : 0x15 -------------- Type: : POWER_USAGE Unit: : WATTS Reading: : 0x19 Sensor Label: : kant Sensor ID: : 0x0

    Read the article

  • XNA Class Design with Structs

    - by Nate Bross
    I'm wondering how you'd recommend designin a class, given the fact that XNA Framework uses Struct all over the place? For example, a spite class, which may require a Vector2 and a Rectangle (both defined as Struct) to be accessed outside of the class. The issue come in when you try to write code like this: class Item { public Vetor2 Position {get; set;} public Item() { Position = new Vector2(5,5); } } Item i = new Item(); i.Positon.X = 20; // fails with error 'Cannot modify the return value of Item because it is not a variable.' // you must write code like this var pos = i.Position; pos.X++; i.Position = pos; The second option compiles and works, but it is just butt ugly. Is there a better way?

    Read the article

  • Faulting DLL (ISAPI Filter)...

    - by Brad
    I wrote this ISAPI filter to rewrite the URL because we had some sites that moved locations... Basically the filter looks at the referrer, and if it's the local server, it looks at the requested URL and compared it to the full referrer. If the first path is identical, nothing is done, however if not, it takes the first path from the full referrer and prepends it to the URL. For example: /Content/imgs/img.jpg from a referrer of http://myserver/wr/apps/default.htm would be rewritten as /wr/Content/imgs/img.jpg. When I view the log file, everything looks good. However the DLL keeps faulting with the following information: Faulting application w3wp.exe, version 6.0.3790.3959, faulting module URLRedirector.dll, version 0.0.0.0, fault address 0x0002df25. Here's the code: #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <httpfilt.h> #include <time.h> #include <string.h> #ifdef _DEBUG #define TO_FILE // uncomment out to use a log file #ifdef TO_FILE #define DEST ghFile #define DebugMsg(x) WriteToFile x; HANDLE ghFile; #define LOGFILE "W:\\Temp\\URLRedirector.log" void WriteToFile (HANDLE hFile, char *szFormat, ...) { char szBuf[1024]; DWORD dwWritten; va_list list; va_start (list, szFormat); vsprintf (szBuf, szFormat, list); hFile = CreateFile (LOGFILE, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { SetFilePointer (hFile, 0, NULL, FILE_END); WriteFile (hFile, szBuf, lstrlen (szBuf), &dwWritten, NULL); CloseHandle (hFile); } va_end (list); } #endif #endif BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer) { /* Specify the types and order of notification */ pVer->dwFlags = (SF_NOTIFY_ORDER_HIGH | SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_PREPROC_HEADERS | SF_NOTIFY_END_OF_NET_SESSION); pVer->dwFilterVersion = HTTP_FILTER_REVISION; strcpy(pVer->lpszFilterDesc, "URL Redirector, Version 1.0"); return TRUE; } DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD NotificationType, VOID *pvData) { CHAR *pPhysPath; PHTTP_FILTER_URL_MAP pURLMap; PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo; CHAR szReferrer[255], szServer[255], szURL[255], szNewURL[255]; DWORD dwRSize = sizeof(szReferrer); DWORD dwSSize = sizeof(szServer); DWORD dwUSize = sizeof(szURL); int iTmp, iTmp2; CHAR *pos, tmp[255], *tmp2; switch (NotificationType) { case SF_NOTIFY_PREPROC_HEADERS : pHeaderInfo = (PHTTP_FILTER_PREPROC_HEADERS)pvData; if (pfc->GetServerVariable(pfc, "HTTP_REFERER", szReferrer, &dwRSize)) { DebugMsg(( DEST, "Referrer: %s\r\n", szReferrer )); if (pfc->GetServerVariable(pfc, "SERVER_NAME", szServer, &dwSSize)) DebugMsg(( DEST, "Server Name: %s\r\n", szServer )); if (pHeaderInfo->GetHeader(pfc, "URL", szURL, &dwUSize)) DebugMsg(( DEST, "URL: %s\r\n", szURL )); iTmp = strnstr(szReferrer, szServer, strlen(szReferrer)); if(iTmp > 0) { //Referred is our own server... strcpy(tmp, szReferrer + iTmp); DebugMsg(( DEST, "tmp: %s - %d\r\n", tmp, strlen(tmp) )); pos = strchr(tmp+1, '/'); DebugMsg(( DEST, "pos: %s - %d\r\n", pos, strlen(pos) )); iTmp2 = strlen(tmp) - strlen(pos) + 1; strncpy(tmp2, tmp, iTmp2); tmp2[iTmp2] = '\0'; DebugMsg(( DEST, "tmp2: %s\r\n", tmp2)); if(strncmp(szURL, tmp2, iTmp2) != 0) { //First paths don't match, create new URL... strncpy(szNewURL, tmp2, iTmp2-1); strcat(szNewURL, szURL); DebugMsg(( DEST, "newURL: %s\r\n", szNewURL)); pHeaderInfo->SetHeader(pfc, "URL", szNewURL); return SF_STATUS_REQ_HANDLED_NOTIFICATION; } } } break; default : break; } return SF_STATUS_REQ_NEXT_NOTIFICATION; } /* simple function to compare two strings and return the position at which the compare ended */ static int strnstr ( const char *string, const char *strCharSet, int n) { int len = (strCharSet != NULL ) ? ((int)strlen(strCharSet )) : 0 ; int ret, I, J, found; if ( 0 == n || 0 == len ) { return -1; } ret = -1; found = 0; for (I = 0 ; I <= n - len && found != 1 ; I++) { J = 0 ; for ( ; J < len ; J++ ) { if (toupper(string[I + J]) != toupper(strCharSet [J])) { break; // Exit For(J) } } if ( J == len) { ret = I + (J); found = 1; } } return ret; }

    Read the article

  • Which Devices Support Javascript Geolocation via navigator.geolocation ?

    - by Maciek
    The iPhone supports geolocation in mobile Safari via the following call: navigator.geolocation.getCurrentPosition( function(pos){ var lat = pos.coords.latitude; var long = pos.coords.longitude; }, function(){ /* Handler if location could not be found */ } ); I'd like to build a good list of devices that have one of the following: support this feature out of the box, or support this feature with an upgrade, or support geolocation with equivalent fidelity of data with some other snippet of Javascript. I'm only familiar with my own device, so this is my list so far: Out of the box: iPhone 3GS Supported, but only with an update iPhone 3G iPhone 2G (?) PC or Mac computer with Firefox 3.5 Supported with some other snippet ? What is the level of support in Blackberry, Android phones, etc?

    Read the article

  • OpenGL basics: calling glDrawElements once per object

    - by Bethor
    Hi all, continuing on from my explorations of the basics of OpenGL (see this question), I'm trying to figure out the basic principles of drawing a scene with OpenGL. I am trying to render a simple cube repeated n times in every direction. My method appears to yield terrible performance : 1000 cubes brings performance below 50fps (on a QuadroFX 1800, roughly a GeForce 9600GT). My method for drawing these cubes is as follows: done once: set up a vertex buffer and array buffer containing my cube vertices in model space set up an array buffer indexing the cube for drawing as 12 triangles done for each frame: update uniform values used by the vertex shader to move all cubes at once done for each cube, for each frame: update uniform values used by the vertex shader to move each cube to its position call glDrawElements to draw the positioned cube Is this a sane method ? If not, how does one go about something like this ? I'm guessing I need to minimize calls to glUniform, glDrawElements, or both, but I'm not sure how to do that. Full code for my little test : (depends on gletools and pyglet) I'm aware that my init code (at least) is really ugly; I'm concerned with the rendering code for each frame right now, I'll move to something a little less insane for the creation of the vertex buffers and such later on. import pyglet from pyglet.gl import * from pyglet.window import key from numpy import deg2rad, tan from gletools import ShaderProgram, FragmentShader, VertexShader, GeometryShader vertexData = [-0.5, -0.5, -0.5, 1.0, -0.5, 0.5, -0.5, 1.0, 0.5, -0.5, -0.5, 1.0, 0.5, 0.5, -0.5, 1.0, -0.5, -0.5, 0.5, 1.0, -0.5, 0.5, 0.5, 1.0, 0.5, -0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0] elementArray = [2, 1, 0, 1, 2, 3,## back face 4, 7, 6, 4, 5, 7,## front face 1, 3, 5, 3, 7, 5,## top face 2, 0, 4, 2, 4, 6,## bottom face 1, 5, 4, 0, 1, 4,## left face 6, 7, 3, 6, 3, 2]## right face def toGLArray(input): return (GLfloat*len(input))(*input) def toGLushortArray(input): return (GLushort*len(input))(*input) def initPerspectiveMatrix(aspectRatio = 1.0, fov = 45): frustumScale = 1.0 / tan(deg2rad(fov) / 2.0) fzNear = 0.5 fzFar = 300.0 perspectiveMatrix = [frustumScale*aspectRatio, 0.0 , 0.0 , 0.0 , 0.0 , frustumScale, 0.0 , 0.0 , 0.0 , 0.0 , (fzFar+fzNear)/(fzNear-fzFar) , -1.0, 0.0 , 0.0 , (2*fzFar*fzNear)/(fzNear-fzFar), 0.0 ] return perspectiveMatrix class ModelObject(object): vbo = GLuint() vao = GLuint() eao = GLuint() initDone = False verticesPool = [] indexPool = [] def __init__(self, vertices, indexing): super(ModelObject, self).__init__() if not ModelObject.initDone: glGenVertexArrays(1, ModelObject.vao) glGenBuffers(1, ModelObject.vbo) glGenBuffers(1, ModelObject.eao) glBindVertexArray(ModelObject.vao) initDone = True self.numIndices = len(indexing) self.offsetIntoVerticesPool = len(ModelObject.verticesPool) ModelObject.verticesPool.extend(vertices) self.offsetIntoElementArray = len(ModelObject.indexPool) ModelObject.indexPool.extend(indexing) glBindBuffer(GL_ARRAY_BUFFER, ModelObject.vbo) glEnableVertexAttribArray(0) #position glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ModelObject.eao) glBufferData(GL_ARRAY_BUFFER, len(ModelObject.verticesPool)*4, toGLArray(ModelObject.verticesPool), GL_STREAM_DRAW) glBufferData(GL_ELEMENT_ARRAY_BUFFER, len(ModelObject.indexPool)*2, toGLushortArray(ModelObject.indexPool), GL_STREAM_DRAW) def draw(self): glDrawElements(GL_TRIANGLES, self.numIndices, GL_UNSIGNED_SHORT, self.offsetIntoElementArray) class PositionedObject(object): def __init__(self, mesh, pos, objOffsetUf): super(PositionedObject, self).__init__() self.mesh = mesh self.pos = pos self.objOffsetUf = objOffsetUf def draw(self): glUniform3f(self.objOffsetUf, self.pos[0], self.pos[1], self.pos[2]) self.mesh.draw() w = 800 h = 600 AR = float(h)/float(w) window = pyglet.window.Window(width=w, height=h, vsync=False) window.set_exclusive_mouse(True) pyglet.clock.set_fps_limit(None) ## input forward = [False] left = [False] back = [False] right = [False] up = [False] down = [False] inputs = {key.Z: forward, key.Q: left, key.S: back, key.D: right, key.UP: forward, key.LEFT: left, key.DOWN: back, key.RIGHT: right, key.PAGEUP: up, key.PAGEDOWN: down} ## camera camX = 0.0 camY = 0.0 camZ = -1.0 def simulate(delta): global camZ, camX, camY scale = 10.0 move = scale*delta if forward[0]: camZ += move if back[0]: camZ += -move if left[0]: camX += move if right[0]: camX += -move if up[0]: camY += move if down[0]: camY += -move pyglet.clock.schedule(simulate) @window.event def on_key_press(symbol, modifiers): global forward, back, left, right, up, down if symbol in inputs.keys(): inputs[symbol][0] = True @window.event def on_key_release(symbol, modifiers): global forward, back, left, right, up, down if symbol in inputs.keys(): inputs[symbol][0] = False ## uniforms for shaders camOffsetUf = GLuint() objOffsetUf = GLuint() perspectiveMatrixUf = GLuint() camRotationUf = GLuint() program = ShaderProgram( VertexShader(''' #version 330 layout(location = 0) in vec4 objCoord; uniform vec3 objOffset; uniform vec3 cameraOffset; uniform mat4 perspMx; void main() { mat4 translateCamera = mat4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, cameraOffset.x, cameraOffset.y, cameraOffset.z, 1.0f); mat4 translateObject = mat4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, objOffset.x, objOffset.y, objOffset.z, 1.0f); vec4 modelCoord = objCoord; vec4 positionedModel = translateObject*modelCoord; vec4 cameraPos = translateCamera*positionedModel; gl_Position = perspMx * cameraPos; }'''), FragmentShader(''' #version 330 out vec4 outputColor; const vec4 fillColor = vec4(1.0f, 1.0f, 1.0f, 1.0f); void main() { outputColor = fillColor; }''') ) shapes = [] def init(): global camOffsetUf, objOffsetUf with program: camOffsetUf = glGetUniformLocation(program.id, "cameraOffset") objOffsetUf = glGetUniformLocation(program.id, "objOffset") perspectiveMatrixUf = glGetUniformLocation(program.id, "perspMx") glUniformMatrix4fv(perspectiveMatrixUf, 1, GL_FALSE, toGLArray(initPerspectiveMatrix(AR))) obj = ModelObject(vertexData, elementArray) nb = 20 for i in range(nb): for j in range(nb): for k in range(nb): shapes.append(PositionedObject(obj, (float(i*2), float(j*2), float(k*2)), objOffsetUf)) glEnable(GL_CULL_FACE) glCullFace(GL_BACK) glFrontFace(GL_CW) glEnable(GL_DEPTH_TEST) glDepthMask(GL_TRUE) glDepthFunc(GL_LEQUAL) glDepthRange(0.0, 1.0) glClearDepth(1.0) def update(dt): print pyglet.clock.get_fps() pyglet.clock.schedule_interval(update, 1.0) @window.event def on_draw(): with program: pyglet.clock.tick() glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) glUniform3f(camOffsetUf, camX, camY, camZ) for shape in shapes: shape.draw() init() pyglet.app.run()

    Read the article

  • java: decoding URI query string

    - by Jason S
    I need to decode a URI that contains a query string; expected input/output behavior is something like the following: abstract class URIParser { /** example input: * something?alias=pos&FirstName=Foo+A%26B%3DC&LastName=Bar */ URIParser(String input) { ... } /** should return "something" for the example input */ public String getPath(); /** should return a map * {alias: "pos", FirstName: "Foo+A&B=C", LastName: "Bar"} */ public Map<String,String> getQuery(); } I've tried using java.net.URI, but it seems to decode the query string so in the above example I'm left with "alias=pos&FirstName=Foo+A&B=C&LastName=Bar" so there is ambiguity whether a "&" is a query separator or is a character in a query component. edit: just tried URI.getRawQuery() and it doesn't do the encoding, so I can split the query string with a "&", but then what do I do? Any suggestions?

    Read the article

  • django 'if' statement improperly formatted

    - by Zayatzz
    Im getting strangest error in django so far: 'if' statement improperly formatted Template that raises the error is this: {% if diff >= 0 %} <span class="pos">+{{ diff }} {% else %} <span class="neg">-{{ diff }} {% endif %} </span> <span>{{ a }}</span> view that has a and diff in context is this: def add(request, kaart_id): if request.is_ajax() and request.method == 'POST': x = Kaart.objects.get(id=kaart_id) x.pos += 1 x.save x = Kaart.objects.get(id=kaart_id) from django.utils import simplejson diff = x.pos - x.neg a = "(+1)" context = { 'diff':diff, 'a':a } return render_to_response('sum.html', context, context_instance=RequestContext(request)) It does not matter what equation i use in if, , =, ==.. they all raise the same error. and as far as i can tell its all by the book: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#id5 Alan.

    Read the article

  • Recording/Reading C doubles in the IEEE 754 interchange format

    - by rampion
    So I'm serializing a C data structure for cross-platform use, and I want to make sure I'm recording my floating point numbers in a cross-platform manner. I had been planning on just doing char * pos; /*...*/ *((double*) pos) = dataStructureInstance->fieldWithOfTypeDouble; pos += sizeof(double); But I wasn't sure that the bytes would be recorded in the char * array in the IEEE 754 interchange format. I've been bitten by cross-platform issues before (endian-ness and whatnot). Is there anything I need to do to a double to get the bytes in interchange format?

    Read the article

  • Embedded media player gets inconsistent currentPosition on both IE8 and Firefox3

    - by logoin
    I have a embedded media player in the browser that is controlled by javascript to handle all the mediaChange event. The code looks like mediaChangeHandler: function(media) { if (media && this.offset && !this.offsetJumpPerformed) { if (parseFloat(media.duration) > this.offset) { pos = parseInt(pos); this.getPlayer().controls.currentPosition = pos; alert("jump to position: " + this.getPlayer().controls.currentPosition); this.play(); this.offsetJumpPerformed = true; alert("currentPosition:" + this.getPlayer().controls.currentPosition); } } } The first alert indicates the currentPosition is where I want it to be. However, the second alert would get currentPosition that's couple seconds less than what I have set up. Does anyone have idea why? I tried googled it but haven't found anything useful. Thanks!

    Read the article

  • Position of least significant bit that is set

    - by peterchen
    I am looking for an efficient way to determine the position of the least significant bit that is set in an integer, e.g. for 0x0FF0 it would be 4. A trivial implementation is this: unsigned GetLowestBitPos(unsigned value) { assert(value != 0); // handled separately unsigned pos = 0; while (!(value & 1)) { value >>= 1; ++pos; } return pos; } Any ideas how to squeeze some cycles out of it? (Note: this question is for people that enjoy such things, not for people to tell me xyzoptimization is evil.) [edit] Thanks everyone for the ideas! I've learnt a few other things, too. Cool!

    Read the article

  • Referencing a control inside a XSL Template from code behind ?

    - by Mina Samy
    Hi all I have a custom NewItem.aspx that I made by creating a new aspx from the exisiting one I wanted to put a control in a row inside the XSL Template like this <asp:DropDownList ID="ddlSectors" AutoPostBack="true" runat="server" __designer:bind="{ddwrt:DataBind('i',ddlSectors,'SelectedValue','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Sector')}"> </asp:DropDownList> <!--<SharePoint:FormField runat="server" id="ff7{$Pos}" ControlMode="New" FieldName="Sector" __designer:bind="{ddwrt:DataBind('i',concat('ff7',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Sector')}"/>--> <SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Sector" ControlMode="New"/> Now I want to reference ddlSectors from my code library but it always throws an object reference not set to an instatnce of an object. I believe that this is becuase the control is inside the XSL template. so is there any workaround for this ? thanks

    Read the article

  • XNA Class Design with Structs as Properties and issues because they are value types and not referenc

    - by Nate Bross
    I'm wondering how you'd recommend designin a class, given the fact that XNA Framework uses Struct all over the place? For example, a spite class, which may require a Vector2 and a Rectangle (both defined as Struct) to be accessed outside of the class. The issue come in when you try to write code like this: class Item { public Vetor2 Position {get; set;} public Item() { Position = new Vector2(5,5); } } Item i = new Item(); i.Positon.X = 20; // fails with error 'Cannot modify the return value of Item because it is not a variable.' // you must write code like this var pos = i.Position; pos.X++; i.Position = pos; The second option compiles and works, but it is just butt ugly. Is there a better way?

    Read the article

  • Where can I find a jQuery color animation plugin?

    - by George Edison
    I need an up-to-date jQuery color animation plugin that works in IE 8. I tried using the one at http://plugins.jquery.com/project/color but it causes errors like "Invalid property value." in the following line of code from color.js: fx.elem.style[attr] = "rgb(" + [ Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0), Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0) ].join(",") + ")"; Where can I get something that works? By the way, I really hate IE, if that helps.

    Read the article

  • How to read ident from an ini file?

    - by user367856
    i have store a list of items from gridView into registry as below: * frmPOSConfigSet.tblCatItems.First; while not frmPOSConfigSet.tblCatItems.Eof do begin RegItemSetting.WriteString('stk Group\Candy', frmPOSConfigSet.tblCatItemsCODE.Text, frmPOSConfigSet.tblCatItemsSPHOTO.Text); frmPOSConfigSet.tblCatItems.Next; end; * [In Registry Editor] stk Group - Candy - YUPI_GUM_HB , c:\Users\chai\Pictures\POS Item Images\image1.jpg - YUPI_GUM_SBKISS , c:\Users\chai\Pictures\POS Item Images\image2.jpg After i close the form and open again, all values in gridView is gone, how do i retrieve the ident (eg. YUPI_GUM_HB) and it's value (eg.c:\Users\chai\Pictures\POS Item Images\image1.jpg) from registry to the gridView when load the form?

    Read the article

  • match elements from two files, how to write the intended format to a new file

    - by user2489612
    I am trying to update my text file by matching the first column to another updated file's first column, after match it, it will update the old file. Here is my old file: Name Chr Pos ind1 in2 in3 ind4 foot 1 5 aa bb cc ford 3 9 bb cc 00 fake 3 13 dd ee ff fool 1 5 ee ff gg fork 1 3 ff gg ee Here is the new file: Name Chr Pos foot 1 5 fool 2 5 fork 2 6 ford 3 9 fake 3 13 The updated file will be like: Name Chr Pos ind1 in2 in3 ind4 foot 1 5 aa bb cc fool 2 5 ee ff gg fork 2 6 ff gg ee ford 3 9 bb cc 00 fake 3 13 dd ee ff Here is my code: #!/usr/bin/env python import sys inputfile_1 = sys.argv[1] inputfile_2 = sys.argv[2] outputfile = sys.argv[3] inputfile1 = open(inputfile_1, 'r') inputfile2 = open(inputfile_2, 'r') outputfile = open(outputfile, 'w') ind = inputfile1.readlines() cm = inputfile2.readlines()[1:] outputfile.write(ind[0]) #add header for i in ind: i = i.split() for j in cm: j = j.split() if j[0] == i[0]: outputfile.writelines(j[0:3] + i[3:]) inputfile1.close() inputfile2.close() outputfile.close() When I ran it, it returned a single column rather than the format i wanted, any suggestions? Thanks!

    Read the article

  • Mouseup not working after mousemove on img

    - by leyou
    I'm trying to do a simple drag script. The idea is to save the position when the mouse is down, update the view while the mouse is moving, and stop when mouse is up. Problem, mouseup event isn't working properly. See the code: var target = $('a') var pos = 0; var dragging = false; $(document).mousedown(function(e) { pos=e.pageX; dragging = true }) $(document).mouseup(function() { dragging = false }) $(document).mousemove(function(e) { if(dragging){ target.css('left', e.pageX-pos); } }) ? Why mouseup works with a "a" tag: http://jsfiddle.net/leyou/c3TrG/1/ And why mouseup doesn't work with a "img" tag: http://jsfiddle.net/leyou/eNwzv/ Just try to drag them horizontally. Same probleme on ie9, ff and chrome.

    Read the article

  • XNA 2d camera with arbitrary zoom center

    - by blooop
    I have a working 2D camera in XNA with these guts: ms = Mouse.GetState(); msv = new Vector2(ms.X, ms.Y); //screenspace mouse vecor pos = new Vector2(0, 0); //camera center of view zoom_center = cursor; //I would like to be able to define the zoom center in world coords offset = new Vector2(scrnwidth / 2, scrnheight / 2); transmatrix = Matrix.CreateTranslation(-pos.X, -pos.Y, 0) * Matrix.CreateScale(scale, scale, 1) * Matrix.CreateTranslation(offset.X, offset.Y, 0); inverse = Matrix.Invert(transmatrix); cursor = Vector2.Transform(msv, inverse); //the mouse position in world coords I can move the camera position around and change the zoom level (with other code that I have not pasted here for brevity). The camera always zooms around the center of the screen, but I would like to be able to zoom about an arbitrary zoom point (the cursor in this case), like the indie game dyson http://www.youtube.com/watch?v=YiwjjCMqnpg&feature=player_detailpage#t=144s I have tried all the combinations that make sense to me, but am completely stuck.

    Read the article

  • QWinWidget's position is always 0 (zero)

    - by Kevin
    I hosted a QWinWidget in a CView and want it to stay at a designated position when resizing. But QWinWidget always moves to (0, 0), i.e. left-top corner of the CView. I tried to debug in this way: QWinWidget* pWidget = new QWinWidget(pCView); pWidget->move(50, 50); QPoint pos = pWidget->pos(); Note that: the pos is always (0, 0). Why is that?

    Read the article

  • How to read ident and it's value from registry?

    - by user367856
    i have store a list of items from gridView into registry as below: * frmPOSConfigSet.tblCatItems.First; while not frmPOSConfigSet.tblCatItems.Eof do begin RegItemSetting.WriteString('stk Group\Candy', frmPOSConfigSet.tblCatItemsCODE.Text, frmPOSConfigSet.tblCatItemsSPHOTO.Text); frmPOSConfigSet.tblCatItems.Next; end; * [In Registry Editor] stk Group - Candy - YUPI_GUM_HB , c:\Users\chai\Pictures\POS Item Images\image1.jpg - YUPI_GUM_SBKISS , c:\Users\chai\Pictures\POS Item Images\image2.jpg After i close the form and open again, all values in gridView is gone, how to retrieve the ident (eg. YUPI_GUM_HB) and it's value (eg.c:\Users\chai\Pictures\POS Item Images\image1.jpg) from registry to the gridView when load the form?

    Read the article

  • How do you handle options that can't be used together with OptionParser?

    - by Joel
    My Python script (for todo lists) is started from the command line like this: todo [options] <command> [command-options] Some options can not be used together, for example todo add --pos=3 --end "Ask Stackoverflow" would specify both the third position and the end of the list. Likewise todo list --brief --informative would confuse my program about being brief or informative. Since I want to have quite a powerful option control, cases like these will be a bunch, and new ones will surely arise in the future. If a users passes a bad combination of options, I want to give an informative message, preferably along with the usage help provided by optparse. Currently I handle this with an if-else statement that I find really ugly and poor. My dream is to have something like this in my code: parser.set_not_allowed(combination=["--pos", "--end"], message="--pos and --end can not be used together") and the OptionParser would use this when parsing the options. Since this doesn't exist as far as I know, I ask the SO community: How do you handle this?

    Read the article

  • Fixing CSS positioning and scaling

    - by Louis
    I was contemplating writing a UI toolkit where setting the position and size of an element/widget was intuitive and powerful. Here are some examples of how it would be used (not currently implemented): ui("Panel").size(". 40").pos("0 0").attach(element); ui("Textarea").size(". %-10").pos("0 40").attach(element); ui("Panel").size(". 10").pos("0 bottom+5"); Where . means auto, % means 100% and the possibility to add pixels to percentages. Does anything like said exist (even as a jQuery plugin or something)? Somethings just aren't possible with pure CSS.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >