Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Pixinger77

@Pixinger77
About
Posts
23
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • DirectX: "render to surface" or "render to device" (unmanaged)
    P Pixinger77

    Hi, I googled around a lot and found basically two ways to render contents to a directX device. The first way is to render directly to the device (that's what I call it :~): IDirect3DDevice9* pDevice; //for simplicity no initialization code here pDevice->Clear(); pDevice->BeginScene(); HRESULT hResult = pDevice->DrawPrimitiveUP( /* ... */ ); pDevice->EndScene(); pDevice->Present(); The second way I found is to render first to a surface and then the complete surface at once to the device: IDirect3DDevice9* pDevice; //for simplicity no initialization code here // now comes the new part of the code: I will first render to surface... CSurface* pBackBuffer; // created by D3DXCreateTexture() and GetSurfaceLevel(); ID3DXRenderToSurface* pRenderTarget; // created by D3DXCreateRenderToSurface(); pRenderTarget->BeginScene(pSurface, 0); pDevice->SetTexture(0); pDevice->DrawPrimitiveUP( /* ... */ ); pRenderTarget->EndScene(D3DTEXF_NONE); // ... and then to the device: the whole surface at once. pDevice->Clear(); pDevice->BeginScene(); pDevice->SetTexture(pTexture); pDevice->DrawPrimitiveUP( /* ... */ ); //Rendering now the Texture to the device. pDevice->EndScene(); pDevice->Present(); --------------------- My question now is: What benefits do I get from the second approach? Is it faster? For me it looks like I just put one more step in the row. Is there less flickering? Do I have more possibilities with the second approach? My second question is: I found a forum-thread where they told that it is no advised to render directly into a surface, because it would destroy performance. The thread applied to managed directx. Is this true? Does it apply to unmanaged DirectX also? Is it slower to render to surfaces? Thanks in advance Snowprog

    C / C++ / MFC question css graphics game-dev performance

  • Bluebox - Chromakey etc
    P Pixinger77

    Hello I'm looking for a fast way to scan a buffer and check if a pixel color is between a color range, or not. Maybe some code explains it better: I have a buffer with 32Bits per Pixel (RGBA => R=8Bit, G=8Bit, B=8Bit, A=8Bit => 32Bit). This buffer is... let's say 200x200 pixels.

    // Defining color ranges
    char redUpper = 100;
    char redLower = 50;
    char greenUpper = 150;
    char greenLower = 130;
    char blueUpper = 20;
    char blueLower = 10;

    //creating my pixel buffer
    int* pBuffer = new int[200*200];
    fillBufferWithData(pBuffer, 200*200); //some magic function the gets the image data into the buffer.

    //analysing
    char* pCursor = (char*)pBuffer;
    for (int i = 0; i < 200*200; i++)
    {
    //Every Pixel that is between the color range...
    if ((pCursor[0] > redLower) && (pCursor[0] < redUpper)
    && (pCursor[1] > greenLower) && (pCursor[1] < greenUpper)
    && (pCursor[2] > blueLower) && (pCursor[2] < blueUpper))
    {
    pCursor[3] = 0;
    }
    else
    {
    pCursor[3] = 255
    }

    pCursor += 4;
    }
    delete [] pBuffer;

    Okay. I hope that helps to understand what i want to do. I know thats not the fastest way (at least I hope so). Maybe someone knows a better way, perhaps with bit-shifting, or bit-masking? Thanks in advance, SnowProg

    C / C++ / MFC question

  • unmanaged callback (for dll interaction)
    P Pixinger77

    Hi, My problem is to create a delegate for the following callback definition (c++ syntax): typedef void (__stdcall *UnmanagedCallback)(std::wstring& WStringObject, const wchar_t* StringData, unsigned __int32 StringLength); I tried something like this: public delegate void UnmanagedCallbackDelegate(ref string stringObject, string stringData, UInt32 stringLength); or: public delegate void UnmanagedCallbackDelegate(ref string stringObject, [MarshalAs(UnmanagedType.LPWStr)]string stringData, UInt32 stringLength); The callback fired from the dll is a _stdcall. Someone has a clue what I do wrong? Thanks in advance... Uwe.

    C# c++ help question

  • Encryption and Decryption
    P Pixinger77

    I cant help you with SHA256, but maybe another solution is acceptable for you. I'am using the MD5, but this is only a unidirectional encryption. I show a dialog to enter a password and encrypt the password via MD5. The encrypted result will then be stored in a database. When the user logs on again, he must enter the password, which will be encrypted again with MD5. To verify if the password is correct i compare the encryption stored in the database, with the new encryption. To get the MD5 encryption do the following:

        public static string StringToMd5(string text)
                {
                    byte[] data = System.Text.Encoding.Unicode.GetBytes(text);
                    System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                    byte[] result = md5.ComputeHash(data);
                    System.Text.StringBuilder s = new System.Text.StringBuilder();
                    foreach (byte b in result)
                    {
                        s.Append(b.ToString("x2").ToLower());
                    }
                    return s.ToString();
                }
    

    may be it suits you... greets Snow

    C# database sql-server sysadmin algorithms security

  • confused arabic when reading from excel-file
    P Pixinger77

    Does arabic really work with totally mirrored desktops? I didnt keep this in mind :-(

    C# csharp help tutorial question

  • confused arabic when reading from excel-file
    P Pixinger77

    Worked for 100%, thanks for your help (even when this leads me into some new problems :-) ).

    C# csharp help tutorial question

  • confused arabic when reading from excel-file
    P Pixinger77

    Hi I have an excel-table wich i use for a translation project. left side english right side the language that needs to be translated. I wrote a program that parses this table and will merge it with the C# resx files. in chinese it works very well but in arabic i fell into some problems. I can see this text in the excel table: {النتيجة الإجمالية - {0 If I convert the text, I finally get something like that (there is something twisted): النتيجة الإجمالية - {0} By the way, the same thing happends if you copy the cell from excel and paste it into the notepad. I tried to convert the string by using system.text.encoding... but didn't get far. Any suggestions or hints how to handle this problem? Thanks in advance, greets Snow.

    C# csharp help tutorial question

  • multilingual pages in asp.net
    P Pixinger77

    I'm not familiar to ASP.NET but i guess the problem is similar to a Standard WindowsApplication. The cultureInfo is devided in three groups: invariant languages, neutral languages and specific languages. Invariant languages and neutral languages can not be used as a language in a thread. You always need to define a specific language (in your case it should be "ur-PK"). The three groups of languages are build up like a tree.

    invariant--- neutral A -- specific AA
    | |-------- specific AB
    |
    |------ neutral B -- specific BA
    |-------- specific BB

    In case that the system can not find a "specific AA"-ResX it will fallback to a "neutral A"-ResX. If it doesn't find a "neutral A"-ResX it will fallback to the "invariant"-ResX. The specific languages are like dialects. Localization is quite a complex theme and should be handled carfully. You can find a lot of articles in the internet and the MSDN. Take your time to read a few of them. --good luck-- greets snowprog

    C# csharp asp-net json learning

  • Localization Project
    P Pixinger77

    Hi, I'm not absolut sure, but if you use .NET2.0 there should be an editor where you can edit the ressource file's and the GUI. But I havent worked with it yet (just having a quick look). I wrote my own ressource file parser that creates an excel file wich I can send to our customers. Actually i cant send this parser to you because its company restricted (sorry) and offcourse a bit buggy (lol). But its not that hard to do on your own. You simply need to watch out for Attributes that ends with ".Text". I saved the control text along with the control name to the excel file so that I am able to write the modified excel table back to the ressource. Thats all... a simple recompile and the software is localized (of course you need to check the GUI *hehe*). Good luck, Snow

    C# question

  • Strange Socket behaviour on Shutdown
    P Pixinger77

    Hi, I have tracked a strange behavior when I close a .NET TCP Socket. I wrote a TCP-Server which listens on port 6000. I now connect with an self written TCP-Client and everything works fine. When I want to disconnect the client from the server I call code like this: public void Disconnect() { if (socket.Connected) socket.Shutdown(SocketShutdown.Both);:~ socket.Close(); socket = null; } When I now run "netstat -a -p tcp" from the commadline I can still see the connection with the state: localhost:6000 -> localhost:6001 = CLOSING_WAIT (translated from german: SCHLIESSEN_WARTEN) localhost:6001 -> localhost:6000 = FIN_WAIT_2 (translated from german: FIN_WARTEN_2) Looks like there are some fragments of the connection still there. By the way... I am not able to create new connection on the same port at this time. Only when I finish my application, the connection between 6000:6001 in "netstat" is gone. The strange thing is, that if I disconnect with the code below, everything works fine. I cant find any connections with "netstat" after the disconnection, and I'm able to create a new connection with the same ports... :confused: Here is the code: public void Disconnect() { //Do NOT shutdown!!! //if (socket.Connected) // socket.Shutdown(SocketShutdown.Both); socket.Close(); socket = null; } So... can someone tell me what is happening here? As far as I know it should be right and neccessary to call socket.Shutdown(...) with the TCP-Protocol. I read a lot of MSDN documentation but couldnt find any clues to this. As far as I tracked the problem, it only appears when I call socket.Shutdown(Socketshutdown.Send). socket.Shutdown(Socketshutdown.Receive) works apperntly fine. Maybe there is some socket coder outside that can help me.;) Thanks in advance, Snow.

    C# help question csharp sysadmin

  • Localization issue with UserControls
    P Pixinger77

    Hello, I'm working on a localized project and have the following problem now: PROBLEM: The Visual-Studio-2003-Designer does not show the correct language. What i did is that: WAY: 1. Create a new WindowsForm-Project and place a button on the form. 2. Add a new userControl and place a button in the userControl (compile it). 3. Place the userControl on the Form. 4. Localize the project to "invariant", "german", "english"... (compile...) I named all buttons according to the localized language (invairant, german, english). EFFECTS: When I now open the Form with the designer, and the language of the Form is set to "invariant", the button of the form is named "invariant" but the button of the control is named "german". It doesnt matter in wich language set when I compile the userComponent. Most of the time it's "german" (sometimes I saw "invariant" but I couldnt figure out why :confused: ). During runtime everything works normal and I can see the language that is set in "System.Threading.Thread.CurrentThread.CurrentUICulture". ;) PRESUMPTIONS: I suppose that it may depend on the language of the Visual Studio or on the language of Windows (both is german in my case). But I would like to understand WHY EXACTLY this happens (and what I can do to prevent it). Thanks in advance Snow

    C# help csharp visual-studio

  • Change Thread Name in MFC
    P Pixinger77

    Thanks thats what i wanted ;-)

    C / C++ / MFC c++ csharp question

  • Fast reading of unmanaged buffers.
    P Pixinger77

    Thanks for your hint. But I knew already that I can use pointers and I also used code simiar to the example. What I dont like in this solution is the "byte per byte" transfer to the new buffer. Isnt there a way to copy a complete block (like in C++ "memcpy" wich should be faster than a byte per byte transfer)? Thanks again Snow

    C# csharp graphics help question

  • Fast reading of unmanaged buffers.
    P Pixinger77

    Hi all, I'm working in C# with a unmanged Dll that provides me a pointer to a byte buffer (768x576) that holds some video data. Is there any fast way to access the data and work e.g. with a bitmap object? Currently I'm converting the data by the help of: System.Runtime.InteropServices.Marshal.ReadByte But that is to slow for me. Any suggestions? Thanks, Snow.

    C# csharp graphics help question

  • Change Thread Name in MFC
    P Pixinger77

    Hi, is it possible to change the Threadname of a Thread that was created with "AfxBeginThread()"? In C# it is quite easy, but i couldn't find out a method for C++/MFC. It would be nice to read the correct threadname in the debuggerwindow. Right now it always tells me: "The Thread 'Win32 Thread' finished with code 0 (0x0).". Thanks, Snow

    C / C++ / MFC c++ csharp question

  • MFC: CCriticalSection problem
    P Pixinger77

    Thanks a lot!

    C / C++ / MFC c++ debugging help question

  • MFC: CCriticalSection problem
    P Pixinger77

    both are true

    C / C++ / MFC c++ debugging help question

  • MFC: CCriticalSection problem
    P Pixinger77

    I create a new project (MFC Dialog) and place a button on the dialog. The code that the button performs is the following: CCriticalSection c; c.Lock(); c.Lock(); c.Unlock(); c.Unlock(); When I start the Program in DEBUG-Mode I expect the following behaviour: 1. The CritSec is created. 2. The first Lock is applied. 3. The second call to Lock should result in a deadlock. :omg: But that is not the case. The code will run without any problems. WHY:confused:!!!! Is there some different behaviour in DEBUG-Mode, or what? Greets Snow

    C / C++ / MFC c++ debugging help question

  • &lt;queue&gt; queue threadsafe?
    P Pixinger77

    Thanks for your answer Tim. I found an MSDN article "Thread Safety in the Standard C++ Library" which statet that some of the STL container classes are threadsafe (but only in certain cases). But I think it will be better to write a wrapper for the queue class as you wrote before. It seems to be the only way to be on the safe side. Thanks, Snow.

    C / C++ / MFC question data-structures

  • &lt;queue&gt; queue threadsafe?
    P Pixinger77

    Hi, I speak of the class std::queue / #include In my case the question is: 1. Is it safe to execute m_queue.push from thread A, while thread B executes m_queue.pop? 2. Is it safe to execute m_queue.push from thread A, while thread B executes m_queue.empty? 3. Is it safe to execute m_queue.push from thread A and also from thread B? I hope you understand what i mean, thanks in advance Snow.

    C / C++ / MFC question data-structures
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups