|
Hello..
I have recently shifted from Display lists to VBOs... It's a very nice thing in OpenGL i found to render huge amount of data smoothly..
Let me explain you the scenario.. I have maintained a list of triangle objects as
std::map<unsigned int, EObjects*> MeshElements
Thus, MeshElements contains all the triangles generated by the mesh generator. Now in order to display, i call a routine first as shown below:
mVertexCount = MeshElements.size();
mVertices = new GLfloat[mVertexCount * 6];
mIndices = new GLuint[mVertexCount * 3];
int v_ind = 0, i_ind = 0;
for( std::map<unsigned int, EObjects*>::iterator it = MeshElements.begin(); it != MeshElements.end(); it++ )
{
EObjects *ob = (*it).second;
mVertices[v_ind] = ob->GetNodeOne().GetX(); v_ind++;
mVertices[v_ind] = ob->GetNodeOne().GetY(); v_ind++;
mIndices[i_ind] = ob->GetNodeOneIndex(); i_ind++;
mVertices[v_ind] = ob->GetNodeTwo().GetX(); v_ind++;
mVertices[v_ind] = ob->GetNodeTwo().GetY(); v_ind++;
mIndices[i_ind] = ob->GetNodeTwoIndex(); i_ind++;
mVertices[v_ind] = ob->GetNodeThree().GetX(); v_ind++;
mVertices[v_ind] = ob->GetNodeThree().GetY(); v_ind++;
mIndices[i_ind] = ob->GetNodeThreeIndex(); i_ind++;
}
glGenGuffersARB(BufferSize, BufferName);
where BufferSize and BufferName are declared globally as follows:
enum{
INDEX_OBJECT = 0,
POSITION_OBJECT = 1
};
static const int BufferSize = 2;
static GLuint BufferName[BufferSize];
Below is my rendering code:
glBindBufferARB( GL_ARRAY_BUFFER_ARB, BufferName[POSITION_OBJECT]);
glBufferDataARB( GL_ARRAY_BUFFER_ARB, mVertexCount * 6 * sizeof(float), mVertices, GL_STREAM_DRAW_ARB );
glVertexPointer(2, GL_FLOAT, 0, 0);
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, BufferName[INDEX_OBJECT] );
glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mVertexCount * 3 * sizeof(GLuint), mIndices, GL_STREAM_DRAW_ARB );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);
glDrawElements( GL_TRIANGLES, mVertexCount*3, GL_UNSIGNED_INT, NULL );
glDisableClientState(GL_INDEX_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
This code is working fine.. But, only the outer part of the mesh is displayed.. the Inner part is not displayed.. I mean to say, if the mesh is of shape "D", it should have filled all the triangles in "D".. Instead of doing so, it is rather, drawing triangles only along the border of the shape "D" Inner part, triangles are not drawn..
Before using glDrawElements(), i was using glDrawArrays().. It also produced the same output.. So I used, GL_POINTS with glDrawArrays(), just to check if it is reading all the points.. In response to this test, it rendered all the points.. But when i said, GL_TRIANGLES, it is not rendering the inner part..
On the other hand, GL_POINTS with glDrawElements() is also rendering only at the boundaries.. Not inner part like glDrawArrays()..
Is something wrong with my code above..?? Please someone guide me properly..
Thanks in advance..
|
|
|
|
|
At a guess, I'd say it sounds as if you have issues with vertex winding direction and normal vector polarity. If you haven't already, try enabling double-sided rendering and lighting of the triangles and see if they show up. I suspect that the invisible triangles aren't being rendered because you're looking at their backsides, as defined by the normal and the order in which the vertices are fed to the GL engine.
Just a guess.
|
|
|
|
|
how do i do that double sided rendering..?? Sorry i'm new but, i guess, by any chance are you speaking about glEnable(CULL_FACE)...??
|
|
|
|
|
Disable back-face culling - glDisable(GL_CULL_FACE) ; specify double -sided material properties - e.g., glMaterialfv(GL_FRONT_AND_BACK...) ; enable double-sided lighting - glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, TRUE) .
|
|
|
|
|
i want to draw 2D graphic using OpenGL in smartphone or PDA with windows mobile system. but where can i download the opengl libs suport the embed system application?
thanks.
|
|
|
|
|
There is no stock implementation, but there's a freeware library called Vincent[^] that might meet your needs.
|
|
|
|
|
Hi,
Is there any software which can generate OpenGL RGB color code?
|
|
|
|
|
Hi there,
I was messing around with DirectDraw and UpdateOverlay. Unfortunately, there is no transparency support after all. Color keying can only hide certain pixels from a Bitmap, but not parts of the overlay itself.
Is there any other way to draw a hardware overlay with transparency? DirectDraw is pretty old..
Thanks for the upcoming advises.
|
|
|
|
|
Hi everybody,
I'm here in the graphics corner coz it's much more of a general graphics question which starts like "Is it possible...?" or "Does the approach make sense"?
We're restoring an ancient movie, which has severe damage on the blue layer over a huge number of frames. One of the ideas for restoration is to safe a non-damaged frame/image from every scene as reference, erase the blue layer from all the frames and compute it newly for the damaged frames, based on the reference image from the same scene. Seems to make sense, but how to implement such a task in a VB program?
How would I extract the blue histogram from the reference image and implant it into the other frames in VB?
Any advice and/or better idea is very welcome!
Thank you in advance
Michael
|
|
|
|
|
Michael Schäuble wrote: Seems to make sense, but how to implement such a task in a VB program?
it's hard to answer that without knowing how you are storing your image data. the format you use to hold the image data will determine what you have to do to get at the blue channel.
|
|
|
|
|
Hi Chris, thanks for your time.
The files are in 10-bit DPX format (linear RGB), which is basically an uncompressed bitmap format and unsupported from GDI+. By now I read it into a RGB Array and throw 2 bits in order to have it displayed, so I have a System.Drawing.Image object I can access and e.g. put it into a picture box. Is that the additional information you needed or did I misunderstand you?
|
|
|
|
|
if you have the RGB array, you should be able to simply copy the B data out of it, right?
maybe i'm misunderstanding now..
|
|
|
|
|
Maybe I didn't make it clear enough... I don't want to extract the blue channel. What I want is to
1. detect some kind of 'blue level' in a reference picture (only one, non-damaged frame)
2. transfer it to a complete series of other frames/images (the whole scene), from which the (damaged) blue channel had been erased before.
Like when you re-adjust the color levels in a histogram in order to get natural colors - but automatically, using a reference instead of user interaction. Is that clearer?
|
|
|
|
|
Even if you have the blue data from an undamaged frame, how are you going to decide which pixels in the damaged frames to apply it to? The pixels will move around as the scene progresses. (I'm assuming the blue data in the damaged frames is total garbage) If you could partition each frame into regions and match the regions between frames, you might apply the blue by region and maybe adjust it based on correlation with the red and green channels with some hand adjustment if needed and that "if" is more like "probably".
Have you researched how they apply the colors to old black and white movies? I know in the early days they did that by identifying regions and hand selecting colors which were then automatically propagated forward with hand touchups. Hopefully, that has progressed since the last time I read anything about it.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
what if you simply copy the blue channel from an undamaged frame to the next N frames? it won't match perfectly, but it might be better than nothing.
otherwise, yes, you could generate a histogram from the blue channel of an undamaged frame, then try to force the blue channel in subsequent frames into a similar distribution (find black % and white % from the good frame and then stretch the bad frames to match those %s). that would be pretty simple.
|
|
|
|
|
Chris,
this sounds exactly what I imagined ...! And 'that would be pretty simple' sounds extremely teasing .
The blue channel isn't completely damaged, it's more or less stained in the blue resulting from fungus that affected irregular regions on the upper/outside layer of some frames. Playing the movie, it looks a bit like ghosts swirling around.
Since there seems to be a way on the basic ideas path, I'll try to find some code samples when I have some extra time again. Or do you even have a link or snippet available that leads in the right direction?
Thanks for now,
and have a nice day
Mick
|
|
|
|
|
|
Hi,
I am displaying 3D models using opengl and VC++.
I have implemented code to rotate, move, zoom the model by moving camera (using gluLookAt() )
Now I want to add one cross hair cursor in front of camera view port(at center of screen), but when I tried to rotate or zoom the model the cursor also rotates or zoom along with model.
How I can make cursor lie at same position while rotating model.
Please help me
|
|
|
|
|
After you are done rendering the rest of the scene, reset your view matrix and projection matrix to width and height of your screen and with and ortho projection. Then Draw your cross hair in the center. It does not have to exist in world space. Basically, it is a HUB display on the near plan of your view.
ARon
|
|
|
|
|
But I want to do only rotation on cursor (it is same as three unit axes rotates about one fixed point) which was done on entire 3d model but to avoid pan and zoom operations. How to do this ???
|
|
|
|
|
I not sure what you are trying to do but this is how I draw an object(s) in space. Forgive me it I c#.
static public void RenderScence()
{
Object LockThis = new Object();
lock (LockThis)
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
#region Draw Scene From Camera View
#region Set the Current Camera Matrix
Matrix_44 HTotal = CurrentCamera.HTotal;
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Gl.glLoadMatrixf(HTotal.GetListValues());
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
#endregion
foreach (ISpatialNode obj in WorldObjectList)
if (obj.IsVisible) obj.RenderOpenGL();
#endregion
Gl.glFinish();
}
}
Base on your description I would create a crosshair class and maintain it orientation and position in the world. When it is time to render the crosshair I would just loaded its Position and Rotation in to the ModelView matrix and then draw it as if it were in free space.
References.
My article on transforms easily adapted to c++.
Space and Matrix Transformations - Building a 3D Engine[^]
Others probably better
Interactive Techniques in Three-dimensional Scenes (Part 1): Moving 3D Objects with the Mouse using OpenGL 2.1[^]
A New Perspective on Viewing[^]
Arcball Module in C# - Tao.OpenGL[^]
ARon
|
|
|
|
|
Thanks for ur reply.
I have tried to reset the modelview matrix and projection matrix and I am successful to display axes 90 percent, the remaining problem is that while rotating the 3d model flickers (at start zoom - in and at end at normal size and position).
I have tried this code after finishing of rest 3d model drawing :
glMatrixMode(GL_PROJECTION);
glGetDoublev (GL_PROJECTION_MATRIX, projMatrix);
glLoadIdentity();
GLdouble gldAspectRatio = (GLdouble) ViewportSize.right/(GLdouble) ViewportSize.bottom;
glOrtho ( pViewVolumeAxe[0], pViewVolumeAxe[1],
pViewVolumeAxe[2]/gldAspectRatio,
pViewVolumeAxe[3]/gldAspectRatio,
pViewVolumeAxe[4], pViewVolumeAxe[5] );
glMultMatrixd(projMatrix);
glMatrixMode(GL_MODELVIEW);
glGetDoublev (GL_MODELVIEW_MATRIX ,modelMatrix);
glLoadIdentity();
glTranslated(-modelMatrix[12], -modelMatrix[13], -modelMatrix[13]);
glMultMatrixd(modelMatrix);
glPushMatrix();
glTranslatef(fXTrans, fYTrans, fZTrans);
|
|
|
|
|
Hi.
I can not good speack english . I want to collapsible regions (selected text) in the richtextbox control .
please see this image ::
http://www.sapphiresteel.com/IMG/gif/collapsible_region.gif
My language is C# .
|
|
|
|
|
Hi.
If I understand you correctly. the term you're searching for is 'Code Folding[^]'
|
|
|
|
|
The program in OpenGL with Texture just didnot work in my cimputer,which work well in others' computer.
where is the crux,any help is appreciated.
The code is in the former message.
|
|
|
|