Hey,
Thanks for the tip but this only seems to work fullscreen. Is there any way to get the buffer data in window mode?
Here is my test code, it just dumps the pixel RGB data out to a file for inspection...
#include "DarkGDK.h"
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
void dumpBackBuffer(std::string targetFile);
void DarkGDK ( void )
{
dbSyncOn();
dbSetDisplayMode(640, 480, 32);
dbSetWindowOff();
dbSyncRate(60);
dbMakeObjectCube(1, 10);
while (LoopGDK())
{
if (dbEscapeKey())
{
break;
}
if(dbSpaceKey())
{
dumpBackBuffer("bufferdata.txt");
}
dbRotateObject(1, dbObjectAngleX(1) + 0.1f, dbObjectAngleY(1) + 0.1f, dbObjectAngleZ(1) + 0.1f );
dbSync();
}
}
void dumpBackBuffer(std::string targetFile)
{
std::ofstream fout;
fout.open(targetFile.c_str());
dbLockBackbuffer();
DWORD* bufferData = (DWORD*)dbGetBackbufferPtr();
int width = dbGetBackbufferWidth();
int height = dbGetBackbufferHeight();
int pixelcount = width*height;
fout << "Buffer width = " << width << "\n";
fout << "Buffer height = " << height << "\n";
fout << "Total Pixels = " << pixelcount << "\n";
fout << "Pixel Data : \n";
fout.flush();
for(int i = 0; i < pixelcount; i++)
{
unsigned int pixel = (unsigned int)bufferData[i];
int b = (int)(pixel % 256);
int g = (int)(pixel / 256) % 256;
int r = (int)((pixel / 256)/256) % 256;
fout << "[" << i << "] : " << r << "\t" << g << "\t" << b << "\n";
}
fout.flush();
fout.close();
dbUnlockBackbuffer();
}
This works fine in full screen mode but not in window mode. In window mode dbGetBackBufferWidth() and dbGetBackBufferHeight() return -1 and if you try to access the buffer everything crashes.
Is ther a way to make this work for window mode apps or is there another way to get a handle on the window data?
Cheers
MACRO