|
hi everyone,
I have vista service pack 1(64bit) and I installed "Microsoft DirectX SDK (June 2006)" now my question is can I use of Directx 10 or I should use of Directx9?
how can I undrestand which one of them can I use? I asked this question because I have problem with "D3D10CreateDeviceAndSwapChain".
Thanks?
|
|
|
|
|
Initially, you want to determine the capabilities of your graphics card. That really is the main determinant for which APIs you can use in your application. Many applications call GetDeviceCaps when first initializing the Direct3D Device (this is the recommended technique both at MSDN, and in all the books written about DirectX 9 and 10 that I've read).
Have a look at: D3DCAPS Structure[^] over at MSDN.
|
|
|
|
|
My graphic card is 8600 gts and it supports of Directx 10.
|
|
|
|
|
Probably the most comprehensive approach is to look for the Utility that comes with the DirectX SDK (both version 9 and 10). It lives in the Utilities directory of wherever you installed the SDK on disc. As I recall, it's name is something obvious like, "DX9Capabilities". Launch it, and it will automatically query your Graphics Card and show you graphically what it's capabilities are. Then all you have to do is do a little research into what each designation actually means. The documentation that comes with the SDK should explain it all. You will discover that some DirectX APIs don't work because your Graphics Card doesn't perform a certain operation. It's a tedious process, but necessary in many circumstances where you are actually instructing the GPU to perform some computation (just by calling a standard DirectX API in your code). The API will often just fail silently, or return an almost useless error code like, D3DERR_INVALIDCALL. Determining your Graphics card capabilities beforehand prevents this kind of thing.
|
|
|
|
|
unsigned int ID;
int imageWidth;
int imageHeight;
unsigned char *image;
FILE *pFile = 0;
BITMAPINFOHEADER bitmapInfoHeader;
BITMAPFILEHEADER header;
unsigned char textureColors = 0;
pFile = fopen("桌面.bmp", "rb");
if(pFile == 0) return false;
fread(&header, sizeof(BITMAPFILEHEADER), 1, pFile);
if(header.bfType != BITMAP_ID)
{
fclose(pFile);
return false;
}
fread(&bitmapInfoHeader, sizeof(BITMAPINFOHEADER), 1, pFile);
imageWidth = bitmapInfoHeader.biWidth;
imageHeight = bitmapInfoHeader.biHeight;
if(bitmapInfoHeader.biSizeImage == 0)
bitmapInfoHeader.biSizeImage = bitmapInfoHeader.biWidth *
bitmapInfoHeader.biHeight * 3;
fseek(pFile, header.bfOffBits, SEEK_SET);
image = new unsigned char[bitmapInfoHeader.biSizeImage];
fread(image, 1, bitmapInfoHeader.biSizeImage, pFile);
for(int index = 0; index < (int)bitmapInfoHeader.biSizeImage; index+=3)
{
textureColors = image[index];
image[index] = image[index + 2];
image[index + 2] = textureColors;
}
fclose(pFile);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, &ID);
glBindTexture(GL_TEXTURE_2D, ID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imageWidth,
imageHeight, GL_RGB, GL_UNSIGNED_BYTE,
image);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
glPushMatrix();
glScaled(45.0,30.0,0);
glBindTexture(GL_TEXTURE_2D, ID);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-2.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, -1.0f, 0.0f);
glEnd();
glPopMatrix();
GLvoid ReShapeGLScene( GLsizei width,GLsizei height )
{
glViewport(0,0,(GLsizei)width,(GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho((GLdouble)-450.0,(GLdouble)450.0,(GLdouble)-300.0,(GLdouble)300.0,50.0,-10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
I think i must be somewhere wrong ,but i am not a expert,and cannot find it .The followings are some set about my code
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW|
PFD_SUPPORT_OPENGL|
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,
0,
0,
0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};
thanks advance
|
|
|
|
|
For the PIXELFORMATDESCRIPTOR you set the pixel type to PFD_TYPE_RGBA so i think you need to set the colorbits to 32 instead of 24.
And for the mipmaps
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, image);
try this instead
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imageWidth, imageHeight, GL_RGBA, GL_UNSIGNED_BYTE, image);
or
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imageWidth, imageHeight, GL_BGRA, GL_UNSIGNED_BYTE, image);
notice the fifth parameter. This is what I use for loading Windows bitmap into texture.
|
|
|
|
|
not work,The program work well in others' computer,But failed again in my computer.
My gpu is nViDIA, geforce G210M.
I think it something with my gpu.
But I knouw nothing about it
Thanks all the same
|
|
|
|
|
What size is the image you're trying to use as a texture? I haven't played with OpenGL for a bit but I seem to remember the image has to be sized to even powers of 2. For example, 2, 4, 8, 16, 32....
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
|
I have a third party dll that is written in C++ that saves a bitmap image as the actual grayscale values and not a Bitmap format. I am looking for a way to read in the grayscale values and convert them to use C#/.NET 's Bitmap class.
Thanks
|
|
|
|
|
I'm guessing you mean something like :
file: 256, 0,0 ,12,25,89.. val_n.. etc...EOF (for a 16X16 image)
then the easiest way (C#) is to read the values into program then create a bitmap and read the values into pixels as:
Bitmap.SetPixel(X,Y, Color.FromRGB(val_n,val_n,val_n));
iterate and save bitmap done.
|
|
|
|
|
I have a problem when two images are overlapping in a area. Then I have to draw both the images side by side in such a way that they seems to be merging. I am drawing first image and then second image on same memory buffer. Now my problem is how to determine which pixel to draw (old Image/new Image). As to show merging I don't want to overwrite all the pixels of old image with new image. I have four color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New Memory Buffer Color). All the images are color and using grayScale Alpha blending on edges so we will have lots of different color pixel in one image specially on edges. I hope some of graphics designer must have face this problem. Please let me know the approach or some algo to decide. Currently I am using one method to check the new memory color and old memory color distance from foreground color and printing the closer one. Also I did same with background color and printing which is far from background color. These are failing some time specially if I choose foreground and background color same.(Condition :-Main part of both Picture must be using foreground color as this is character text and that part should not be overwritten.).
Thanks in advance.
|
|
|
|
|
The general problem is called "image stitching" and a lot of software exists to handle stitching photographs into panoramic views. It sounds like your case is less general but the procedures probably are similar.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Thanks Tim.
This information helped me to find related stuff. But my problem is specially with same foreground and background color. You can think I have some text and each character is surrounded by clouds. Now I need to print these correctly rendered text in buffer so that surrounding cloud of text should be evenly overlapped but it should not overwrite the main text. My problem is mainly with same background and foreground color. Also my current code is very simple and I don't want to use any complex function(which is most of filters are doing) to get the correct pixel.
|
|
|
|
|
Ok, I think I understand your problem a bit better now. Is your text in any kind of regular pattern so that you can use OCR techniques to identify the margins and rows? If so, alignment of the text would be easy based on your layout rules. If there's something special about the background that also needs to be aligned somehow and it's fairly uniform, this sounds more like the problem of finding the back cat in the coal bin at midnight.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
thanks tim. You are correct about the problem. But I dont have background color as a seprator because of cloud color. Without this clude I am using the fore and back color distance logic to get the correct color. But with this 3rd color problem is .
Up to no efficient solution for this in case anyone can help with more ideas.
|
|
|
|
|
Good day folks!
Does anyone know what might cause IDirectDrawSurface7::IsLost() to hang? In a multithreaded application time to time it happens that when IsLost() is called on a surface (primary surface if that matters) to check if it needs restoring it never returns, execution sits somewhere in ddraw.dll or nt.dll...i guess it deadlocks on something but what? DDSCL_MULTITHREADED is specified when SetCooperativeLevel is used but not having it doesn't seem to change anything. Also this happens on multiple computers with different accelerator hardware and drivers so it shouldn't be any driver problem. So does anyone know what could cause IsLost() to never return?
Thanks in advance for any answers.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I got scanned forms (JPEG/PDF format) having check boxes in front of each question. I'm looking for a way to digitally read those images and determine whether box is checked or not. Is there any code/article that can help me achieve this goal?
Thanks in advance
|
|
|
|
|
Try this ot perhaps this
or search for IMAGE ANALYSIS.
However you are probably going to have issues unless the forms have a stable format, and are read into the jpeg or pdf in a somewhat reliable manner...
simply what you could do is find the xy locations of the boxes and test for darkness coverage say a value of 50 % darkened (or maybe 10 if you have handwritten data) and just pluck the marks out "manually"... --but this would only work in situations where the first check box is say in the Rectangle(75,125, 10,10) it would be trivial.
|
|
|
|
|
Dear all,
is there anybody who can suggest me a program (possibly free)or a way to convert a 32bpp image to RGB565 bmp format?
Thank you in advance
|
|
|
|
|
Sure, what I'd do is load the image into an HBITMAP and then get a pointer to the image's pixel data. Since you know it's a 32 bit image you know you need 4 bytes per pixel.
One of those is an alpha, and you can dump it. The other 3 are the rbg values.
I haven't compiled this, treat it as pseudo code - it outlines a mathod of iterating through an image and down-sampling it. I'm assuming its an 32 bit rgba image.
short procPixel(char r, char g, char b)
{
char tmp;
char lobyte, hibyte;
short result;
r >>= 3; // r = 000rrrrr
g >>= 2; // g = 00gggggg
b >>= 3; // b = 000bbbbb
// rrrrrggg gggbbbbb
tmp = g; // tmp = 00gggggg
tmp <<= 5; // tmp = ggg00000
lobyte = b; // lobyte = 000bbbbb
lobyte |= tmp; // lobyte = gggbbbbb
tmp = r; // tmp = 000rrrrr
tmp <<= 3; // tmp = rrrrr000
hibyte = tmp; // hibyte = rrrrr000
tmp = g; // tmp = 00gggggg
tmp >>= 3; // tmp = 00000ggg
hibyte |= tmp; // hibyte = rrrrrggg
result = hibyte;
result <<= 8;
result |= lobyte;
return nresult;
}
void myFunc(HBITMAP inputImage)
{
BITMAP bmInfo;
unsigned char *bitmapBits;
unsigned char *curPixel;
char r, g, b, a;
int width, height, x, y;
short r5g6b5;
GetObject(inputImage, sizeof(bmInfo), &bmInfo);
bitmapBits = (unsigned char*)bmInfo.bmBits;
curPixel = bitmapBits;
for (y=0; y<height; y++)
{
for (x=0; x<width; x++)
{
r = curPixel[0];
g = curPixel[1]; // I forget which one is which for r, g, b
b = curPixel[2];
a = curPixel[3]; // this one I'm sure about
r5g6b5 = procPixel(r, g, b);
doSomething(r5g6b5, x, y);
curPixel += 4;
}
}
}
|
|
|
|
|
Hi,
I want to display a static image as the background of the OpenGL window. It should be behind any object displayed in the scene. How to achieve this? Thanks in advance.
Ben
|
|
|
|
|
One way it to put your image on a big quad as a texture and position it perpendicular to the viewpoint. Depending on how you want it to appear as the camera moves, you'll have to recalculate it's position and orientation for each move. If you search for "billboarding" and OpenGL, you should find examples although it's often used for other background items.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Hi,i wanna get a Condition force feedback ,such as Friction ,Spring etc.,but i don'tknow why i can not feel it.I set the structure DICONTION and DIEFFECT as following :
DWORD dwAxes[1] = { DIJOFS_X } ;
LONG lDirection[1] = { 1 } ;
DICONDITION diCondtion;
DIEFFECT diEffect ;
diCondtion.dwNegativeSaturation=10000;
diCondtion.dwPositiveSaturation=10000;
diCondtion.lNegativeCoefficient=-10000;
diCondtion.lPositiveCoefficient=10000;
diCondtion.lOffset=0;
diCondtion.lDeadBand=2000;
diEffect.dwSize = sizeof(DIEFFECT) ;
diEffect.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS ;
diEffect.dwDuration = DI_SECONDS/10 ;
diEffect.dwSamplePeriod = 0 ;
diEffect.dwGain = DI_FFNOMINALMAX ;
diEffect.dwTriggerButton = DIEB_NOTRIGGER ;
diEffect.dwTriggerRepeatInterval = 0 ;
diEffect.cAxes = 1 ;
diEffect.rgdwAxes = dwAxes ;
diEffect.rglDirection = lDirection ;
diEffect.lpEnvelope = NULL ;
diEffect.cbTypeSpecificParams = sizeof(diCondtion) ;
diEffect.lpvTypeSpecificParams = &diCondtion ;
hr = g_lpDIDeviceJoystick->CreateEffect(GUID_Spring,&diEffect,
&g_lpdi,NULL) ;
is any wrong with what i do ? If replace DICONDITION with DICONSTANTFORCE ,DIRAMPFORCE or DIPERIODIC ,accordingly i can get Constantforce ,RampForce ,PeriodicForce.but when it comes to DICONDITION
i can not get any force. who can tell me why ? any adivice is approciated ! oh ,i almost forget one thing !the joystick i used is MicroSoft sidewinder force feedback 2.
|
|
|
|
|
I have some fisheye (360 degree view) images and want to "dewarp" them back into rectilinear projections - I was hoping that someone may have some source code to share (C# preferred). I know that there are several programs out there that can do this, but I was hoping to understand the "how" through source code.
Thanks!
|
|
|
|
|