Jump to content

  • Log In with Google      Sign In   
  • Create Account

Dimension10

Member Since 27 Jan 2011
Offline Last Active Jul 20 2013 08:49 PM

Posts I've Made

In Topic: Invalid arguments when creating texture.

18 July 2013 - 12:17 PM

Yeah, no kidding. I was so used to all of those tools and then they stopped working when i started using 2012.

 

The thing is, it has never worked. Ever since I first started. Even without the DXSDK.

 

One thing I AM trying to do lately is avoid the D3DX files. I would rather avoid dependency on the standalone SDK whenever possible, now that MS has shied away from it.

 

 

I'll try tweaking that setting real quick...

 

Oh wow. That did it! Thanks!

 

Of course, the intent is to be able to access the 1x1 mipmap level to output the color, will removing CPU readability affect it? If so, I think I have a workaround, but I would prefer all the speed I can get.

 

 

Edit: Okay, now I'm curious as to how you grab the front or back buffer. Do I have to create a swap chain first? And if so, would I still be able to get data that includes the windows GUI?


In Topic: Invalid arguments when creating texture.

18 July 2013 - 11:16 AM

Debug mode doesn't work, I guess it's because of VS Express? Debugging information could not be found or does not match.

 

 

But I tried several formats to no avail.


In Topic: Does the Windows 7 interface (GDI?) utilize the framebuffer?

17 July 2013 - 12:03 PM

That's a good idea, perfect for my usage. though I worry about initializing devices and windows. How much initialization is generally required before I can create a texture and sample it down to 1 pixel?


In Topic: Does the Windows 7 interface (GDI?) utilize the framebuffer?

16 July 2013 - 10:10 PM

int main()
{
	// Establish Arduino as a color controller on COM7.

	cColorController *Arduino;				
	Arduino = new cColorController("COM7");
	Arduino->setAdjust(	1,		//Red Multiplier
				0.8,		//Green Multiplier
				0.4,		//Blue Multiplier
				2.0		//Gamma
				);			

	// Create a Device Context handle to grab some pixels.

	HDC hdcScreen = GetDC(NULL);
	COLORREF CurrentColor;
	SetStretchBltMode(hdcScreen,HALFTONE);
	SetBrushOrgEx(hdcScreen, 0, 0, NULL);
	int ScreenWPix = GetDeviceCaps(hdcScreen,HORZRES);
	int ScreenHPix = GetDeviceCaps(hdcScreen,VERTRES);

	// Create a Buffer device to send data to. Todo: Buffer not working.
	HDC hdcBuffer = CreateCompatibleDC(NULL);
	BITMAPINFO hdcInfo;
	ZeroMemory( &hdcInfo.bmiHeader , sizeof(BITMAPINFOHEADER));
	hdcInfo.bmiHeader.biBitCount	= 24;
	hdcInfo.bmiHeader.biPlanes	=  1;
	hdcInfo.bmiHeader.biHeight	=  1;
	hdcInfo.bmiHeader.biWidth	=  1;
	hdcInfo.bmiHeader.biSizeImage   =  0;
	hdcInfo.bmiHeader.biSize	= sizeof(BITMAPINFOHEADER);
	hdcInfo.bmiHeader.biClrUsed	=  0;
	hdcInfo.bmiHeader.biClrImportant=  0;
	VOID *pvBits;
	HBITMAP bmpBuffer = CreateDIBSection(hdcBuffer,
					&hdcInfo,
					DIB_RGB_COLORS,
					&pvBits,
					NULL,
					0);
	
	SelectObject(hdcBuffer, bmpBuffer);
	

	



	while(1)
	{
		//Stretch the screen down to a single pixel.
		StretchBlt(hdcScreen, 0, 0, 1, 1,
			hdcScreen, 0, 0, ScreenWPix, ScreenHPix,
			SRCCOPY);
		//Get this pixel's color, rather than call GetPixel for r, g, and b.
		CurrentColor = GetPixel(hdcScreen, 0, 0);

		Arduino->setColor(GetRValue(CurrentColor), //Send this color to the Arduino
				GetGValue(CurrentColor),
				GetBValue(CurrentColor)); //Todo: Have Arduino read COLORREF


		//Sleep(16);
	}


	ReleaseDC(NULL, hdcScreen);
	return 1;
}

In Topic: Does the Windows 7 interface (GDI?) utilize the framebuffer?

16 July 2013 - 09:54 PM

"You could sample 1 pixel out of every 4x4 pixel square across the screen and cut your work to 1/16th of the StretchBlt method"

 

I figured that much. I was working on a method, actually, for creating a pixel density function so that the samples are more dense near the edges of the screen.

 

But I figured stuff like BitBlt and StretchBlt would grab a whole chunk of data while it's open, THEN extract what it needs.

 

I figure the only method I would really have for grabbing individual pixels is GetPixel(). But since it would re-access the device context each time, I figured that would be like shutting off the engine in your car every time you make a new turn.

 

I like your idea of keeping a few frames. It would also be interesting to dither the samples in a sense, like take a random pixel out of each 4x4 block, and keep the previous two or so frames.

 

 

Edit: And one more quick thing, if possible. How would I go about creating a buffer HDC? I tried creating one, and all I really got was a mess of digits that remained static. So as it is, I'm writing the average color to a pixel, and writing that pixel at 0,0 on my screen, then accessing the whole screen again just to grab that pixel.


PARTNERS