Jump to content
  • Advertisement

uncle_rico

Member
  • Content Count

    557
  • Joined

  • Last visited

Community Reputation

415 Neutral

About uncle_rico

  • Rank
    Advanced Member
  1. uncle_rico

    Duke Nukem Forever Screenshot

    Are they still planning an N64 version?
  2. Hello. I am writing an MFC app, single-document, with a document template. Just one window frame, one view, and one document. I need to be able to enable and disable items within the main menu (File, Edit, etc.), but I am having a very difficult time doing it. I've tried using AfxGetApp()->m_pMainWnd->GetMenu() to get the menu, and then I use CMenu::EnableMenuItem() to enable the specific items. For the UINT nEnable parameter, I pass MF_ENABLED to enable the menu item, and MF_GRAYED to disable it. However, it does not seem to work. All menu items remain enabled, despite this. I ran it in debug mode to see if these functions are being called. They are, and they're returning valid values (it is supposed to return the previous nEnable state if the function is successful, otherwise it returns -1; in my case, they all return MF_ENABLED). Since these items are all within the File submenu, I tried using CMenu::GetSubMenu(0) to get a pointer to the proper CMenu item that represents the File menu. With this, I get the same result. There is a Q&A article on MFC that says that I should try instead to catch the ON_ UPDATE_COMMAND_UI message, and set the menu items at that time. The problem is, I get the following compile error: error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMyView::* )(void)' to 'void (__thiscall CCmdTarget::* )(CCmdUI *)' So, the message map macro seems to be expecting a function name from the CCmdTarget class (or something derived from it, I imagine), and won't work within my View class. But I sort of need it to work from within my view class, because the enable state of these menu items depends on variables found within the document that is associated with that view. I tried doing this from within my CFrameWnd-derived class, using CFrameWnd::GetActiveView()->GetDocument() to get at the document, but I run into the same error as before. Any ideas? I had no idea that this would be the hardest thing I had to do with this tool! ;)
  3. uncle_rico

    Hiding in the Atheist Closet

    Quote:Original post by polly In fact, Bhuddism is the main reason I disagree with with the "All religions are evil" argument put forward by Richard Dawkins.; had he said "All theistic religions are evil" or "All the Abrahamic religions are evil", I may have partly agreed. FWIW, he takes care to define what he means by "religion" in his new book (something about belief in a personal God who reads your thoughts, yadda yadda yadda), and his argument isn't so much that all religions (by this definition) are evil, but rather that they're illogical and irrational, and irrational thinking can lead to evil, and is perhaps the leading cause of evil.
  4. uncle_rico

    Endian Swap Question

    That worked great, thanks! I guess I made the mistake of thinking that casting doesn't affect the actual bits. I should have known that I was wrong about that, because I cast from float to int all the time, and the value never changes (i.e., when I case an int with a 255 value to a float, the result is 255.0, which would not be the case if casting were merely a reinterpretation of the same bit pattern).
  5. I usually just run the program from a console window that I've opened beforehand. I use Windows XP, so I go to Start then Run, then I type cmd and hit OK. When the console window comes up, I go to the folder that my program is in, type the name of the program, and that's all there is to it. When the program returns, it will return you to the C:> prompt instead of closing the console window itself.
  6. uncle_rico

    Endian Swap Question

    Hello. I am trying to figure out how to handle endian swaps with float data. I have a program where I read .lwo files into a buffer of BYTES (which is just a typedef's unsigned char). The .lwo files are big-endian, and so whenever I need to grab a piece of data, I need to perform an endian swap before I can use it. I have one for ints that uses bit shifts and works just fine. So, to grab a piece of int data, I'd do something like this: int iData = *(int*)&buffer[10]; endian_swap(iData); Where 10 is the location of the first byte in the datum. But since the endian_swap function uses bit shifts, I can't pass a float to it. So, what I've been doing is just casting the float to an int reference, like this: float fData = *(float*)&buffer[10]; endian_swap((int&)fData); I was thinking about devising a better solution. I thought I'd create some functions, like GetInt() and GetFloat, where I pass the address of the first byte in the buffer to the function, and it returns the data of the right type, with the right byte order. So I started to make a float function that looks something like this: float GetFloat(BYTE *input) { return (float) (input[0] | (input[1] << 8) | (input[2] << 16) | (input[3] << 24)); } Shouldn't this work? I tested this out with some real data. The value that it is SUPPOSED to return is -0.5f. Instead, it returns 191.0f. What gives? I thought that maybe I had inadvertantly set this up so that it would return the little-endian value, so I changed which bytes were shifted such that input[0] was shifted by 24 and input[3] was not shifted at all, but for some reason it yields the same exact value of 191.0f. I suspect I have completely the wrong idea.
  7. uncle_rico

    Advice on reading binary files in C?

    That's awesome advice, especially on how to read from the buffer. Thanks! I've been doing stuff like this: int myInt = (buffer[5] << 24) | (buffer[6] << 16) | (buffer[7] << 8) | buffer[8]; Awesome news: LWO files apparently are written in big-endian format. Hahahaha. I found this out through trial and error and confimed it in the docs, which is why what I did above yielded weird data, I guess.
  8. uncle_rico

    Advice on reading binary files in C?

    Quote:Original post by LessBread Does the file format have a header? Do you have a definition for it's structure? Does the header have a field for the size of the file or other data points that can be used to determine the size of the file? Yes, you're absolutely right. The header starts with the string FORM and then the next four bytes give the size of the file, minus 8 (which I'm guessing is the size of the file minus the FORM and the size bytes themselves). So I suppose that would be much better than relying on SEEK_END. I'm curious to know what people do when there is no header, but that is a question for another day! I'm starting to rethink the whole "read the whole file into a buffer" idea, because some data is larger than others and it doesn't seem convenient to access it all on a byte-by-byte fashion. For instance, if I have a piece of data that I know is 100 bytes into the file, and it's a 4-byte int, I could just call fread(&MyInt, sizeof(int), 1, pFile) or I could try to access the 4 bytes using my buffer, one byte at a time, and combine them into one datum somehow (using the bitwise OR maybe?). Hmmmm
  9. uncle_rico

    Advice on reading binary files in C?

    It seems to have worked on my platform, which is just fine by me :)
  10. uncle_rico

    Advice on reading binary files in C?

    Ah, so do you think if I did something like this: fseek(pFile, 0, SEEK_END); and called fgetpos(), that might work? I'm only using C because that's where I feel most out of practice, but I'm starting to think that I'm more out of practice with binary reading in general. Come to think of it, all other projects I worked on involved text files. This is going to be especially wierd, because LWO files are littered with text tags like FORM, PNTS, etc. I guess I'm just going to have to figure out how to know when the bytes represent text and cast them as chars?
  11. Ugh, this is just one of those things that I don't do often enough. I've decided to write something that can read LightWave LWO files and maybe write them out to human-readable text, just for practice. I have the SDK documentation for the LWO format, and I'm ready to being programming. I figure that the best way to do it is to read the whole file into a buffer, and then close the file. That way, I can work directly on the buffer. I am a little better with C++ strings and file I/O than I am with C, so I've decided to try to do this with straight stdio/stdlib stuff. I figure that I should start by finding the size of the file in bytes. Then, I can create an unsigned char*, assign it to the return value of malloc( iFileSize * sizeof(unsigned char) ), and then I have the perfect amount of space. Then, I can read it in byte by byte and then I can close the file. I'm trying to find a way to get the right file size, but that is proving troublesome. I tried using fseek, moving one byte at a time, until I encounter an EOF character, but then my program crashes. I'm more used to reading text files, and so I think I'm getting confused at the difference between binary and text reading, but I'm not sure. Does anyone have any general advice about this?
  12. That worked wonderfully. Thanks so much!
  13. Hey people. I was just wondering if anyone has encountered this before. I have a full-featured version of Visual Studio at work, and I have no problem calling functions like MessageBox() and just passing a literal string like "Error!" or "Hello, World!". When I try to do this at home with Visual C++ Express, I get a compile error, saying that it cannot convert these parameters from "const char[5]" to "LPCWSTR." So, I cast the strings to an LPCWSTR, and it sort of works. It compiles, but I get these blank character boxes. I'm just wondering if there is some compiler setting that I could use which is perhaps less pedantic and will allow me to just pass a string literal through. Thanks! Edit - Here is my code (after adding the cast): #include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, (LPCWSTR)"Goodbye, cruel world!", (LPCWSTR)"Note", MB_OK); return 0; } And here is what I get at runtime: [Edited by - uncle_rico on December 23, 2006 1:59:15 AM]
  14. uncle_rico

    Mormon (LDS) for President?

    Quote:Original post by Platinum314 Quote:Original post by Machaira Quote:Original post by Platinum314 Tithing isn't forced on people, it is completely volentary, just like every other commandment in the church. Voluntary in that if you don't do it you can't get a temple recommend, right? Correct, it is a requirement to have a temple recommend. That doesn't really seem leave members much of a choice if they are at all interested in attaining the highest degree of glory in heaven.
  15. I think I can wrap my mind around obtaining the derivative of a curve in 2D space. I took a cursory look at it, and I think I have the general concept down. The way I picture it, the derivative allows me to determine the slope at some arbitrary point along the curve. The slope itself can be represented as a line, which is a tangent to that point. But in 3D, there are an infinite number of coplanar lanes which are tangent to any point along the curve. So, it seems that the tangent of a 3D curve is a plane. Perhaps, if I could get the normal to that plane, then I would have the vector I'm looking for? I think it's the multidimensionality of it that I'm confused about.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!