|
Does it? I can't get it to work...
I'm running the Feb 2003 SDK. It there maybe an update that fixes this?
Thanks!
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Not that familiar with OpenGL - but had fun(!) with this type of thing before.
First thing to check is your graphics card. Does it support alpha? If so then check the configuration setup in the control panel. You may also want to check that you have the latest drivers from your manufacturer.
I once spent hours trying to get anti-aliasing working on my laptop's card
Graham
|
|
|
|
|
using alpha is a combination effort. In otherwords you cannot simply use alpha transparency, you first have to enable it, and also provide a function for method of processing alpha. The whole process is called blending since you are using a source color value, an alpha transparency, a function for combining the two into a new blended color.
Try looking here for an example, it is my personal favorite OpenGL site: NeHe[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Is it possible to use alpha with OpenGL??
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Thanks a lot, that really helps!
He says "You should SORT THE TRANSPARENT POLYGONS BY DEPTH and draw them AFTER THE ENTIRE SCENE HAS BEEN DRAWN, with the DEPTH BUFFER ENABLED, or you will get incorrect results."
How do I determine the depth of the object? What is the proper function to use to get the distance between the viewpoint and the object?
Thanks,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
distance is distance is distance.... You can project the xyz data into viewer references, in which case you will get your depth as a valid number. Or you can just use the old distance formula d=sqrt(deltax*deltax+deltay*deltay+deltaz*deltaz).
however since all you need is a compare and sort, drop the sqrt. The square of the distance won't make one distance shorter than another.
The author is primarily referring to the fact that the programmer often has knowlege of what he is doing that the computer does not. So you can order your logic to provide the computer with an easier time. You generally do not have to depth sort opaque objects, draw them all and let the hardware z-buffer sort them out. So then you are left with your alpha transparent objects. Some of them you may already know their order.
When you have limited knowledge of what you are going to draw and when (or simply providing the power of flexibility), that is when you start getting into game-engines and scene-graphs. If you have n number of objects of unknown type, and unknown complexity as far as alpha-objects, you toss all n-objects onto a scene-graph and issue a scene-graph draw command. The scene-graph-API handles sorting, culling and other tasks that will have to be performed every time you draw (as objects move in relative position to each other and on their own axis -- a plane doing a barrel roll with a transparent glass canopy for example will generate a new z-sort every time).
www.openscenegraph.org[^] has one of many scene graphs (there are a dozen I could rattle off off the top of my head -- google on opengl scenegraph)
www.delta3d.org[^] has one of many gaming engines (based on openscenegraph API for a core), google will again turn up many more (some for a cost).
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-- modified at 15:19 Monday 7th November, 2005
|
|
|
|
|
Well that's the whole thing really. The user can set the camera angle viewpoint anywhere they want, inherently reversing the order of the objects in my scene. So I need a generic way of sorting these objects by calculating the depth from the camera.
I would have liked most to have a general sort for this. I guess there's no OpenGL option I can enable for this, huh?
And what if you don't know (or don't wanna know) why objects are transparent and which are not...? Or what if some objects are partially transparent or have gradient alphas?
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Swinefeaster wrote: Well that's the whole thing really. The user can set the camera angle viewpoint anywhere they want, inherently reversing the order of the objects in my scene. So I need a generic way of sorting these objects by calculating the depth from the camera.
Well, yes and no. OpenGL is a programming API, so it is designed for your flexibility and power, but it is very low-level. If you are trying to make sure a user can drive a car, OpenGL is the transmission and engine block. When you start talking about making it easy for the user, you are talking higher level stuff, you are talking scene-graphs and gaming engine APIs.
Swinefeaster wrote: I would have liked most to have a general sort for this. I guess there's no OpenGL option I can enable for this, huh?
Use any sort. OpenGL doesn't remember objects from frame to frame, in fact it doesn't even have any knowledge of "objects" per se. OpenGL knows triangles and can draw them in many different references with multiple textures, color blending methods, etc. But OpenGL doesn't know a car from a baseball bat. If you build a vector using STL and sort it using your favorite sort, you have your beginnings of a gaming engine/storage system. If you want to drop something in and not have to repeat it again everyframe forever, again you are talking scene graphs. nVidia has a scene graph, there is several open scene graphs (though only one by that name).
Swinefeaster wrote: And what if you don't know (or don't wanna know) why objects are transparent and which are not...? Or what if some objects are partially transparent or have gradient alphas?
Again, you are talking scene graph material. OpenGL knows the basics, triangles, lines, points, colors, textures, etc. Even the shaders are fancy ways of coloring a triangle. Don't get me wrong, both DirectX and OpenGL are incredibly powerful, but they are much lower level than you are talking about.
With open scene graph you do just drop an object (not triangle lists, but a physical object) into a node. The scene graph breaks the object into triangles of opaque and transparent nature and zsorts appropriately. You then move the object as you would moving a plane or a car, or a cartoon character, by manipulating centers of parts (rotate, translate, scale, etc). With a scene graph or gaming engine, you think in object/part rather than every triangle. Although a single point, or a single triangle is still considered an object, so you can always go lowerlevel from the high.
Jeff
_________________________
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 really appreciate your input... But, I have tried everything I can think of, and still nothing works. I can get two cubes to appear, but they don't blend correctly no matter what I do.
For now, I would just like one of them to be semi transparent and the other one opaque. I'm assuming if I don't sort them, then they should be correct from at least one viewing angle. But the opaque cube is always opaque, and the semi transparent cube seems to alpha blend with the black background ok, but they don't blend together no matter what the viewing angle.
I still can't find a simple example showing correct alpha blending with two simple polygons --- I don't need any crazy texture mapping with targa files...
The latest I've tried is:
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_CULL_FACE);
But that stil doesn't work....
Any ideas???
Much thanks!
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
I assume the semi-transparent cube is always drawn first? Then yes, it will blend with the background, then you draw the opaque cube and it will either cover up the semi-transparent cube or it will clip it (as in it will not be drawn due to GL_CULL_FACE). Since you say you are blending with the background, you are in fact blending, period.
you've also partially stumbled across the example where alpha-blending fails to provide a true result in any case. If you draw as whole objects, things start breaking down.
You can help the situation by breaking all objects into triangles and sorting the triangles. At the very least you will want to draw the opaque square first, then draw the semi-transparent, that's a simple object sort, but not always true, especially with large triangles.
There is another method called depth peeling that draws using multi-frame rendering techniques multiple depth slices to cut the scene in many sections drawing piece by piece.
nVidia layers program[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Ok after trial and error over and over, I found the lucky combination:
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDepthFunc(GL_LEQUAL);
if(m_transparent)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_COLOR);
}
With this implementation, it doesn't matter which order the objects are drawn in. However, for some reason it still ignores how transparent an object is --- it is either somewhat transparent, or opaque. Any ideas?
BTW I couldn't get the nvidia samples to work with vc6.
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Choice of your blending function depends on what result you want. Once again, this is point where OpenGL is more than a draw-and-forget system.
Try a couple of these examples for blending and see how they do:
http://www.opengl.org/resources/code/basics/redbook/[^]
http://nehe.gamedev.net/lesson.asp?index=02[^]
http://nehe.gamedev.net/lesson.asp?index=07[^]
(blender.c)[^]
I tend to use the following sequence only for alpha blended objects (inside your if statement)
<br />
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
glEnable(GL_BLEND);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDepthMask(0);
without knowing what you are expecting in the alpha blending, I don't know if you should use my model or another. There are several alpha-blending methods. In fact I used to know where a demo was of all the alpha-blending modes so you could see what each did as an effect and choose the function that was most like what you expected to see. Unfortunately, I have been searching for it without any luck.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
|
|
Finally somebody helps. Thanks Mircea ::- ). I'll take a look.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Nope. It's not useful. That's a call from VB to VC++. I wanted the other way around using the address of a VB function. And it doesn't even work so well, there are several limitations that the code has, not to mention some assumptions that the dude makes and I don't like that. I pass arrays from VB to VC++ using a different, more effective and safe method, but they can't be modified just as I would like. Anyway, I did find other ways, but that particular way (with calling VB from VC++ still doesn't work). Maybe somebody'll figure it out after I post the article.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I am using Visual Studio .NET 2003. I have a solution with multiple projects inside it. Some projects depend on others to build (I added them as references) and the dependencies are correctly set.
I keep getting this error ...
wilogic error LNK2019: unresolved external symbol "public: __thiscall wanderingidiot::Wi_object::Wi_object(void)" (??0Wi_object@wanderingidiot@@QAE@XZ) referenced in function "public: __thiscall wanderingidiot::logic::Wi_charachter::Wi_charachter(void)" (??0Wi_charachter@logic@wanderingidiot@@QAE@XZ)
The solution consists of 3 dll's and an executable. Wi_object resides inside a particular dll ... and I am trying to inhert from it to another class residing in another dll. Any idea what I'm missing over here?
|
|
|
|
|
Use DumpBin /EXPORTS and make sure the class members got exported from the DLl with the
decoration the linker is looking for.
Either they did not get exported with that naming convention, or else you are not trying to import them correctly , in which case your header file needs modification to perhaps imply _import.
Give that a try
|
|
|
|
|
Okay ..
Found about this in MSDN
#define DllExport __declspec( dllexport )
now it seems to be working.
Thankyou.
|
|
|
|
|
I wrote a hook message to record all the messages on the choosen windows(it is choose by the first mouse click)but it did not do right.
//////////globle variable///////////////
#pragma data_seg(".SHARDAT")
static HHOOK hkb=NULL;
FILE *f1;
BOOL bfist=FALSE;
HWND m_handlechoosen;
#pragma data_seg()
//////////////////////////
LRESULT __declspec(dllexport)__stdcall CALLBACK MessageProc(int nCode,WPARAM wParam,LPARAM lParam)
{
PMSG mesg = (PMSG)lParam;
if (nCode>0) {
//get the first window handle choosen
if (bfist==FALSE&&mesg->message==WM_LBUTTONDOWN) {
bfist=TRUE;
m_handlechoosen=mesg->hwnd;
}
//recorder message belong to the handle choosen
if (bfist==TRUE&&mesg->hwnd==m_handlechoosen) {
f1=fopen("c:\\report.txt","a+");
int nLen = ::GetWindowTextLength(mesg->hwnd);
TCHAR *tszWindowName = new TCHAR;
::GetWindowText(mesg->hwnd, tszWindowName, nLen + 1);
if (nLen>0) {
fprintf(f1, "code=0x%X wParam=0x%X lParam=0x%X | msg->hwnd(Window name)=%s msg->message=0x%X msg->wParam=0x%X msg->lParam=0x%X\n",
nCode,
wParam,
lParam,
tszWindowName,
mesg->message,
mesg->wParam,
mesg->lParam
);
}
else
{
fprintf(f1, "code=0x%X wParam=0x%X lParam=0x%X | msg->hwnd(Window name)=Desktop Window msg->message=0x%X msg->wParam=0x%X msg->lParam=0x%X\n",
nCode,
wParam,
lParam,
mesg->message,
mesg->wParam,
mesg->lParam
);
}
delete tszWindowName;
fclose(f1);
}
}
else
{
CallNextHookEx( hkb, nCode, wParam, lParam );
return 0;
}
return CallNextHookEx( hkb, nCode, wParam, lParam );
}
->The result are all the messages....
...Please help me ...
|
|
|
|
|
mcnam wrote: ...but it did not do right.
Ok, and?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I'm working on a windows ce development project, and on my compact flash card containing the distribution is "the registry file". I want to be able to edit, off-line, this file. According to Windows CE doc, the format is the same as Windows XP, etc.
When I attempt to open the file on my desktop with regedit, it asks me "Would you like to merge this file?" Noooo, I don't want to do *that*, I want to just see what is in it.
Is there a way to open a registry file on disk - I don't want the live version.
Before you say windows ce is windows ce.... imagine if I have an OS disk that won't boot. I remove the disk from one machine and mount the disk in another workstation. Now I can access the registry file on the off-line disk. But can I?
I see nothing in msdn about opening a static registry file.
Ideas?
C. Gilley
Will program for food...
My son's PDA is an M249 SAW.
|
|
|
|
|
Is it a .reg file, or the actual registry (ntuser.dat)?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
In my case, it's a .reg file.
C. Gilley
Will program for food...
My son's PDA is an M249 SAW.
|
|
|
|
|
No why not just open it with Notepad (or equivalent)?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|