Jump to content

  • Log In with Google      Sign In   
  • Create Account

Necr0Potenc3

Member Since 22 Apr 2004
Offline Last Active Oct 17 2012 12:40 AM

Topics I've Started

Acquiring game art through DirectX API hooks

16 October 2012 - 11:35 PM

There is an old game, circa 199Xs, which I'd like to do a remake. It's an old project of mine and I finally have the time to start it.

The game is definitely abandonware so I don't see the problem in re-using the game's art for the remake.

So far I have reverse engineered the sound format and successfully extracted the game's sound. However, the file formats for the graphics is way more tricky... being a 199xs game, there is a whole lot of indices across files and different color palettes.

The game's code (binary) doesn't help much either... its code over code, a real mess to reverse. Instead of this laborious approach I'm moving towards a smart one.

The game uses DirectX, which I'm not familiar with, I've only used OpenGL all my life. Still, I'm fairly certain it's possible to intercept (hook) the DirectX calls the game uses and extract the graphics art there.

Not being familiar with DX, I have no idea which APIs I should hook, what I should look at or even if there are existent tools that will perform this task.

Could anyone offer ideas? Tips?

easy,fast resizing image to bypass "not a power of 2" problem [+contribution]

18 August 2005 - 03:35 AM

here is the function that does it, I wrote it based on a microsoft article:
void ResizeImage(int Width, int Height, unsigned char *RGB, int *NewWidth, int *NewHeight, unsigned char **NewRGB, int MaxRes)
{
   GLint glMaxTexDim;
   double xPow2, yPow2;
   int ixPow2, iyPow2;
   int xSize2, ySize2;
   
   unsigned char *Data = NULL;

   glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMaxTexDim);
   if(glMaxTexDim > MaxRes) glMaxTexDim = MaxRes;

   if (Width <= glMaxTexDim)
      xPow2 = log((double)Width) / log(2.0);
   else
      xPow2 = log((double)glMaxTexDim) / log(2.0);

   if (Height <= glMaxTexDim)
      yPow2 = log((double)Height) / log(2.0);
   else
      yPow2 = log((double)glMaxTexDim) / log(2.0);

   ixPow2 = (int)xPow2;
   iyPow2 = (int)yPow2;

   if (xPow2 != (double)ixPow2)
      ixPow2++;
   if (yPow2 != (double)iyPow2)
      iyPow2++;

   xSize2 = 1 << ixPow2;
   ySize2 = 1 << iyPow2;

   Data = (unsigned char*)malloc(xSize2 * ySize2 * 3);
   
   gluScaleImage(GL_RGB, Width, Height, GL_UNSIGNED_BYTE, RGB, xSize2, ySize2, GL_UNSIGNED_BYTE, Data);
   
   *NewRGB = Data;
   *NewWidth = xSize2 ;
   *NewHeight = ySize2 ;
    
    return;     
}
its pretty much plug and play. Width, Height and RGB are the "in" parameters. RGB is a buffer with RGB data. NewWidth, NewHeight and NewRGB are "out" parameters, all of them pointers to the variables where the info will be dumped. NewRGB is actually allocated by the function so you have to take care of freeing the memory once you're done with it "ermm... ok. so how do I use it?" just a sample:
static void GenTextures(void)
{
    int bmWidth = 0, bmHeight = 0, error = 0;
    unsigned char *Data = NULL;
    
    unsigned int newWidth = 0, newHeight = 0;
    unsigned char *newData = NULL;
    
    error = LoadBMP("background.bmp", &bmWidth, &bmHeight, &Data);
    if(error)
    {
        sprintf(ErrorTxt, "Could not load background.bmp error: %d", error);
        return;
    }
    
    ResizeImage(bmWidth, bmHeight, Data, &newWidth, &newHeight, &newData, 800);
    
    glGenTextures(1, &texture[0]);
    glBindTexture(GL_TEXTURE_2D, texture[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, newWidth, newHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, newData);
    
    free(Data);
    free(newData);
    
       
    return;
}
hope it helps -gR

glPushMatrix doubt

14 August 2005 - 07:05 AM

lets say I have the following pseudo code: glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); .... drawing on this 1st matrix ... glPopMatrix(); ... some code ... glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); ... drawing on this 2nd matrix ... glPopMatrix(); whenever I call glPushMatrix I'm setting up a new matrix, is that correct? if so, are the attributes from the 1st matrix inherited by the second one or is the second matrix a completly new one? I did some testing on my own and I didn't understand when to use glPushMatrix and when not to use it thanks

PARTNERS