|
I'm trying to add visual effects to the desktop.
I want to be able to use the desktop as normal at the same time.
This is what I have been coding so far. But the triangle is never painted to the screen.
<br />
#include <windows.h><br />
#include <gl/gl.h><br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)<br />
{<br />
HDC hDC;<br />
HGLRC hRC;<br />
float theta = 0.0f;<br />
<br />
<br />
PIXELFORMATDESCRIPTOR pfd;<br />
int format;<br />
<br />
hDC = GetWindowDC(NULL);<br />
<br />
ZeroMemory( &pfd, sizeof( pfd ) );<br />
pfd.nSize = sizeof( pfd );<br />
pfd.nVersion = 1;<br />
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;<br />
pfd.iPixelType = PFD_TYPE_RGBA;<br />
pfd.cColorBits = 24;<br />
pfd.cDepthBits = 16;<br />
pfd.iLayerType = PFD_MAIN_PLANE;<br />
format = ChoosePixelFormat( hDC, &pfd );<br />
SetPixelFormat( hDC, format, &pfd );<br />
<br />
hRC = wglCreateContext( hDC );<br />
wglMakeCurrent( hDC, hRC );<br />
<br />
<br />
while ( true )<br />
{<br />
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );<br />
glClear( GL_COLOR_BUFFER_BIT );<br />
<br />
glPushMatrix();<br />
glRotatef( theta, 0.0f, 0.0f, 1.0f );<br />
glBegin( GL_TRIANGLES );<br />
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );<br />
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );<br />
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );<br />
glEnd();<br />
glPopMatrix();<br />
<br />
SwapBuffers( hDC );<br />
<br />
theta += 1.0f;<br />
}<br />
<br />
return 0;<br />
<br />
}<br />
Have anyone done something like this before?
|
|
|
|
|
Firstly, what do the #include s actually include. I assume they are unimportant and have either been left out or forgotten.
But more to the point, you should have a look at PFD_DRAW_TO_WINDOW in the variable pfd.dwFlags . I too am using OpenGL for a small project I am making. I don't know that much about it but i think you might have to set it to draw to the DESKTOP . I think the desktop is just a special kind of window.
What you are trying to do sounds interesting. Let me know when you have it working
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
Is there anything out there as an Open Source, that I can use to open the AutoCAD drawing (*.DWG extension)without requiring AutoCAD. I have searched online a lot but didn't find anything useful that I can use in my application development.
Any help in this matter will be great. Thanks for your time. looking forward to hear from the experts out there.
|
|
|
|
|
|
Open Design Alliance[^] offers a full DWG API. It's free so long as you are using it internally. There are significant costs if you want to license it to include in a product you plan to sell.
Cheers,
Drew.
|
|
|
|
|
Hi, i am writing an app that copies the screen, warps/distorts the image, then draws it back. I already got the code working in a visualization i am making for Windows Media Player but for some reason it won't work now.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
enableBlend();
glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
renderBackground(wf);
enableTexture(image);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(0, 0);
glTexCoord2f(0, 0); glVertex2f(0, 512);
glTexCoord2f(1, 0); glVertex2f(512, 512);
glTexCoord2f(1, 1); glVertex2f(512, 0);
glEnd();
glBindTexture(GL_TEXTURE_2D, backTexture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
disableTexture();
disableBlend();
That's basically it, renderBackground() draws the texture over a grid of warp points which is stored in a WarpFile object. The enable/disable methods are just wrappers for the OpenGL commands. Is there anything i am doing wrong? I tried pbuffers do copy/render to but it was too hard.
If you need me to post more code (like the renderBackground method) just ask
thanks
--------------------------------
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
|
VizCoder wrote: That one bug has really been p...
You should consider switching to a modern programming language ...
|
|
|
|
|
Get in the habit of doing this:
if (BG_WARP == bgType)
That won't compile with the single =
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I wanna change Hue of image how can i do ??
Using ColorMatrix or using manual loop Lockbits(),Unlockbits..
Please help Urgent.
I tried to see QColorMatrix but its little complicated..
i am already doing lot of processing on image using color matrix as well as looping(lockbits and unlockbits.) also.
Also i waana know how can i control blur ?? if i Apply blur filter it does blur little if i waanna blur more do i have to apply blur filter again and again on the blurre image???
Is there way to control blurr using some factor in only one filter??
|
|
|
|
|
How can I highlight a specific part of an Image in a PictureBox or an Image on a Label in C#.NET.
|
|
|
|
|
I'm trying to turn my PPM (lossless image file) into a texture, but the texture is not showing up correctly. I've tried loading a bitmap image as a texture using glaux and a call to auxDIBImageLoad(), however, I would simply like to implement my own parser for PPM. Basically, in PPM, the line after the getting the value for "int maxValue" is a long line of binary data that stores the 8-bit RGB (total 24 bits) going from left to right, top to bottom in the image. If we think about this in a 2D coordinate system, parsing the file would first get you (x, y) = (0, 0), then (1, 0), then (2, 0), until the end of the width, then (0, 1), and etc.
Knowing this, does anyone know why my texture is being parsed incorrectly?
ifstream texFile("brickbump.ppm");
if (texFile.is_open())
{
char propBuf[8];
texFile.getline(propBuf, 8);
string format = propBuf;
texFile.getline(propBuf, 8);
int x = atoi(propBuf);
texFile.getline(propBuf, 8);
int y = atoi(propBuf);
texFile.getline(propBuf, 8);
int maxValue = atoi(propBuf);
char* texArray = new char[3 * x * y];
int count = 0;
while (!texFile.eof())
{
texFile.get(texArray[count]);
count++;
}
glGenTextures(1, &m_textures[0]);
glBindTexture(GL_TEXTURE_2D, m_textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, x, y, 0, GL_RGB, GL_UNSIGNED_BYTE, texArray);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
delete [] texArray;
}
|
|
|
|
|
I am allowing users to resize images dynamically using CRectTracker .
What i observed is while resizing using mouse sometimes images appears blurred and if i further resize again it becomes good this keeps on happening.
I have set Interpolation mode to InterpolationmodeHighQualityBicubic.
What can be the reason for image to appear blurred.??
i am little confused with this as everytime it follows same code flow.
and every time i am using one original image for resizing(the resized image is not used for further resizing.)
Some hellp or some hints would be highly appreciated.
Thanks,
Sandip.
|
|
|
|
|
What is CRectTracker ?
The blurring is what a bicubic filter does, it blends values from imaginary subpixels, so as not to create a harsher effect by simply rounding the values.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes but why it is different always?
I mean i draw image once it is acceptable
Second time i resize litle it becomes blurred than first
Third time i further resize again it becomes acceptable.
For each resize i am using original image so there cant be effect of previous resize operation.
??
Thanks,
Sandip.
|
|
|
|
|
How can I understand the GPU Gems 2?
I feel I cannot understand any part of it!!
Are there any knowledge I must know?
|
|
|
|
|
How about basic 3D math, modern techniques for modeling, meshes, lighting, testuring, rendering, how a GPU works, maybe some OpenGl, but definitely DirectX, ... These books are NOT for beginners. They're cookbooks for developers and graphics artists who have experience in 3D graphics, modelling, rendering, ...
|
|
|
|
|
If you are starting in graphics programming start with something like the OpenGL Superbible or a tutorial on 3D graphics. GPU gems I, II, and soon III are as was mentioned, cook-book recipes for advanced 3D chefs. I have used my two copies often and get a lot out of them. But you have to be in the need of something beyond what all the beginning graphics books give you. Even Graphics Gems series I would classify in the medium to advanced depending on category, but they are less advanced than the GPU Gems.
GPU Gems series assumes you have mastered 3D graphics programming on the PC and need only techniques of utilizing graphics on the GPU only. So you would need to know just about everything about graphics programming except techniques on the GPU. Even then it assumes you already know how to get the programming onto the GPU and interface with the CPU in a co-rendering cycle, that is a big assumption.
Stay away from any of the Gems series, until you have mastered all the beginning level books. When the tutorials and superbible leave you dry and begging for more, grab the Graphics Gems or Game programming Gems. When those two leave you dry and you are begging for more speed and capability out of a multi-pipe (and thus parallel) GPU to assist in the process, then and only then grab the GPU Gems series.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I'm relatively new to GDI+. I'm trying to create a texture brush from a bitmap stored in a resource file in a Visual C++ project. However, the image comes out much too small when I fill a shape with the texture brush.
The bitmap I'm using is 32x32 and is monochrome.
Bitmap bmpPattern(AfxGetResourceHandle(), (WCHAR*)lpszBmpName);<br />
TextureBrush *pBrush = new TextureBrush(&bmpPattern);
If I want to see the image as it's drawn when using GDI's CreateDIBPatternBrushPt, I have to do a scale tranform on the texture brush by about 10 times.
I'm not sure what's causing this, but I'm guessing it's something to do with the page units. Any clues? Thanks in advance!
|
|
|
|
|
Are you using GDI+ or GDI to draw a filled shape.
Taking from your GDI+ code, I did this in a CWnd-derived OnPaint()...
// IDB_BITMAP4 is a 32x32 monochrome bitmap resource, black 2-pixel-wide border filled with
// dithered pixels (from a color in the monochrome bitmap editor palette).
Graphics DstGraphics(*this);
Bitmap brushbitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP4));
TextureBrush texturebrush(&brushbitmap, WrapModeTile);
Rect ellipserect(0, 0, 640, 640);
DstGraphics.FillEllipse(&texturebrush, ellipserect);
The bitmap is drawn full size in the ellipse. Do you get the same result?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
No, mine is displayed at about 1/10th the size it should be.
I thought that my problem might be that the bitmap was created from a resource file bitmap. So, I tested just creating a bitmap by doing this:
Bitmap bmpTest(32, 32, PixelFormat32bppARGB);<br />
BitmapData bitmapData;<br />
bmpTest.LockBits(&Rect(0, 0, 32, 32),<br />
ImageLockModeRead | ImageLockModeWrite,<br />
PixelFormat32bppARGB,<br />
&bitmapData);<br />
UINT* pixels = (UINT*)bitmapData.Scan0;<br />
<br />
for(UINT row = 0; row < 32; ++row)<br />
for(UINT col = 0; col < 32; ++col)<br />
pixels[row * bitmapData.Stride / 4 + col] = (row == 0 || row == 31 || col == 0 || col == 31) ? 0xFF000000 : 0xFFFFFFFF;<br />
<br />
bmpTest.UnlockBits(&bitmapData);<br />
TextureBrush *pBrush = new TextureBrush(&bmpTest);
But it still displays much too small. I'm thinking maybe it's a problem of page units, but if that's the case, then why do all my ellipses and rectangles show up in the right place, just with their texture-filled insides too small?
|
|
|
|
|
Your code works for me too. I'm not sure what page units you're referring to, but the problem
seems to be in the Graphics object you're drawing to (i haven't seen ay code showing your
Graphics object creation and drawing ).
Maybe try this...
Right before you draw, call DstGraphics.ResetTransform();
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Ah, very true! I create my graphics object from a handle to a CDC that gets passed down from an OnPaint's CPaintDC.
I tried the reset transform on the graphics object, but no luck. By page units, I mean the SetPageUnit method of the Graphics class.
|
|
|
|
|
If you're using SetPageUnit() then maybe this will be of interest:
Types of Coordinate Systems[^]
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hi to All!
I have a problem to catch event from button on webcam using DirectX or WIA.
Any ideas.
|
|
|
|
|