Jump to content
  • Advertisement

Guy Perfect

Member
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Guy Perfect

  • Rank
    Member
  1. Guy Perfect

    Is this code optimized?

    At a cursory glance, not knowing the context of the code in the program it's a part of, I can see that minimal instructions are being given and I don't see a way to simplify them any further. I believe the code is optimized.
  2. Guy Perfect

    2 byte ints from 4 bytes?

    The typical solution used in such a scenario is the use of a RAM-based file buffer which is written to the file once it is prepared. This makes the data being written explicit as well as minimizing the required number of transfers between the program and the storage device. #include <stdio.h> #include <stdlib.h> #define GetUInt16(Addr) (*Addr << 8 | *(Addr + 1)) #define PutUInt16(Addr, Num) *Addr = (Num >> 8); *(Addr + 1) = Num & 0xFF int main() { FILE *FilePtr; unsigned int FileSize; unsigned char *FileBuff; short SomeNum; // Open the file FilePtr = fopen("File.dat", "rb"); // Get the file's size fseek(FilePtr, 0, SEEK_END); FileSize = ftell(FilePtr); fseek(FilePtr, 0, SEEK_SET); // Read all the file data into memory FileBuff = malloc(FileSize); fread(FileBuff, 1, FileSize, FilePtr); // Close the file fclose(FilePtr); // Read some data, change it, and put it back SomeNum = GetUInt16(&FileBuff[2]); SomeNum /= 7; PutUInt16(&FileBuff[2], SomeNum); // Write the output file FilePtr = fopen("File_Edit.dat", "wb"); fwrite(FileBuff, 1, FileSize, FilePtr); fclose(FilePtr); // Free the memory free(FileBuff); return 0; }
  3. I have the desire to include a resource archive file within the compiled binary in order to prevent the needs to have a collection of files in once place to run. Basically what I need is this: Textures + Program = Single EXE File. I'm working cross-platform with gcc, Microsoft VC++, and potentially any number of any compilers. I need as close to a standard method as I can get. I'm also working strictly with C (no C++ code here), so I need something compatible with it. I'm not exactly sure where to start looking or what the official term for what I need is, so I'm asking here. What can I do to get resource files bundled up inside the compiled binary using C?
  4. Guy Perfect

    Transparency with Scene Textures

    Take a look at my prevoius post to see the order in which I am doing things. 0 or 1 for the fourth parameter of glClearColor, it doesn't change the results. Can you provide a full-source example of a working scene texture with transparency?
  5. Guy Perfect

    Transparency with Scene Textures

    After some research and some experimentation, I'm still without satisfactory results. What I'm doing is the following: Setup: - Setting up an OpenGL Rendering Context in Win32 with PFD_TYPE_RGBA in both dwFlags and iPixelType of the pixel format descriptor Each frame: - Using glClearColor with values 0, 0, 0, 0 - Resetting the framebuffer with glClear; color and depth bits - Rendering a textured cube to a viewport of 256×256 pixels - Copying to a texture with glCopyTexImage2D; internal format of GL_RGBA - Using glClearColor with values 0, 0.6, 1, 0 - Resetting the framebuffer with glClear; color and depth bits - Enabling blending with GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA - Drawing a triangle strip with the previously-copied texture mapped to it in a full-window viewport - Disabling blending - Swapping buffers - Deleting temporary texture The result is a textured square in the new scene with the textured cube from the previous scene within it. However, the black texels of the previous scene's clear color still exist and do not become transparent. It's as though blending were not enabled. Could someone provide a working example that I can refer to? Here is a screenshot to clarify:
  6. Guy Perfect

    Transparency with Scene Textures

    The problem is that the model I cast into a texture may very well have black pixels in it. Specifically, may include pixels the same color as the clear color. I need a solution that specifically removes any pixels where polygons aren't. Also, GL_SRC_COLOR isn't a valid function for sfactor of glBlendFunc.
  7. Guy Perfect

    Transparency with Scene Textures

    That would do the trick, but the idea of using the depth values as alpha is new to me. Is there an easy way to implement this with hardware accelleration?
  8. What I want to do is render an object to a scene and copy it to a texture using glCopyTexImage2D. That much is doable. The problem is that the clear color pixels are also copied to the texture and thusly end up in a subsequent scene when the texture is used. I want the extraneous pixels around the desired object to become transparent when used in a subequent scene. For example, if the clear color is black and I draw, say, a rabbit, I can copy the image of that rabbit to a texture using glCopyTexImage2D. Then, let's say I draw a second scene where there's a 2D holographic projection of the rabbit in the middle of an advanced war room. If I use the texture as-is, the resulting render will show a black box with a rabbit in it. The quandary is that I want only the rabbit, but not the blackness around it. Try as I may, however, I can't find any option to remove the unwanted pixels that take on the clear color. Is there an easy way to do this, or should I learn to live with the extra blackness?
  9. United States and international copyright laws permit you to redistribute original works if doing so is not harmful to the originator. You can't claim them as your own, you can't use them for sale or trade, and if the author is currently making money off of it, you cannot distribute it at all without permission. Unless GameDev.Net is bringing in profits on those tutorials, you are legally allowed to repost them citing all applicable credit. Still, permission is ALWAYS a good thing to have.
  10. Guy Perfect

    Loading texture maps

    That would be lesson 7. Look for "mipmap" http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=07
  11. Guy Perfect

    tutorial 6(texture mapping)

    Textures used by your program need to stay in the memory they started in once you load it into OpenGL. In order to load multiple textures, you need to have them all stored in your program's memory individually. You'll probably have to dynamically allocate arrays to do this. You can keep track of different textures using the "textures" parameter of glGenTextures. Simply call glBindTexture with that parameter to switch the currently-used texture. The "textures" parameter of glGenTextures will basically act as a GL-savvy ID number for the texture.
  12. The idea is to make your objects move faster. If it takes more time between frames than intended, then it should move the object that much more to compensate for it. This allows for frames being rendered faster as well, as it will move the object less. But if the object is noticably varying in speed on the screen, then my bet is you're implementing the chronology limiter incorrectly.
  13. Guy Perfect

    Switching Texture Filtering Modes

    Alright. The program loads a good number of textures (some 400 of them) and I just wanted to know if I could switch between linear and nearest on the fly without reloading the textures, since that can take upwards of three seconds on some computers. Thanks for the heads-up.
  14. Out of curiosity, is there any easy way to force textures that are loaded with "glTexParameteri GL_TEXTURE_2D, [whatever], GL_LINEAR" to be drawn without linear filtering? That'd be convenient, since the project I'm working on loads a good number of textures and I'd like an option for the user to test performace with and without linear filtering on the fly without reloading all those textures. So is there any switch I can throw to "disable linear filtering"?
  15. Guy Perfect

    Dynamic updation of XML file

    You can easily manage the file system on a web server using CGI. Set up the server to allow for "Execute" permissions on web programs. You can program CGI applications in C++. The following link should contain ample information for doing this: http://cgi.resourceindex.com/
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!