|
Hi all,
4 points are defined as follows:
float[,] ctrlpoints = new float [4,3] {{ -4.0f, -4.0f, 0.0f }, { -2.0f, 4.0f, 0.0f }, { 2.0f, -4.0f, 0.0f }, { 4.0f, 4.0f, 0.0f }};
When the 4 points are called in following method:
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
OpenGL gl = openGLControl.OpenGL;
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
int i;
gl.Color(1.0f, 1.0f, 1.0f);
gl.Begin(OpenGL.GL_LINE_STRIP);
for (i = 0; i <= 30; i++)
{
gl.EvalCoord1((float)i / 30.0);
}
gl.End();
gl.PointSize(5.0f);
gl.Color(1.0f, 1.0f, 0.0f);
gl.Begin(OpenGL.GL_POINTS);
for (i = 0; i < 4; i++)
{
gl.Vertex(&ctrlpoints[i][0]);
}
gl.End();
gl.Flush();
}
The &ctrlpoints[i][0] in gl.Vertex(&ctrlpoints[i][0]) was displayed to be an error.
How to fix the problem? Thanks!
|
|
|
|
|
Which language are you using? Most of your syntax looks like C#, but &ctrlpoints[i][0] looks like C++ (or possibly C# in an unsafe context).
If it's C#, what's the signature of the Vertex method in the Object Browser?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
pvpeng wrote: was displayed to be an error. What error; please do not expect people to guess what messages you are seeing. I cannot find a description for either a Vertex function, or class constructor; is this something you have created yourself?
|
|
|
|
|
|
I am working in C++. I am trying to draw a perpendicular hash mark from the start of a sloped line. My code below draws a perpendicular line but when the slope of the original line changes the hash mark appears to change length. When the line is close to horizontal the hash mark looks longest and shortest when the line is close to vertical. I believe the problem is the fixed value for HashLength. Can you show a better way to calculate the end of the perpendicular line(px2,py2) so my hash mark always looks the same size.
Orig_Line_Slope = (y1-y2)/(x1-x2);
Recipical_Slope = ((1.0 / Orig_Line_Slope)*-1);
HashLength = 10.0;
px2 = (x1+HashLength);
py2 = (y1+(Orig_Line_Slope*HashLength));
MoveToEx(hdc, x1, y1, NULL);
LineTo(hdc, px2, py2 );
|
|
|
|
|
//Denote change in x =dx
//Denote change in y =dy
float dx=0.0;
float dy=0.0;
//Then dx^2 + dy^2 = HashLength ^2 ..eq 1
//We can express dy in terms of dy because
// dy/dx= Recipical_Slope
// simplifying..
// dy=Recipical_Slope*dx
//Replacing dy in eq 1, we have
//dx^2 + (Recipical_Slope *dx)^2= HashLength^2
//simplifying..
dx=sqrt(HashLength^2/(1+Recipical_Slope^2));
dy=Recipical_Slope * dx;
px2=x1+dx;
py2=y1+dy;
|
|
|
|
|
To Yang Kok Wah
I tested your solution and it works very well.
Thank You
|
|
|
|
|
Dear All,
I am a starter in OpenGL and SharpGL. I am using C# and SharpGL. However, I do not know how to write glutSwapBuffers() in OpenGL to SharpGL format.
Thanks in advance.
|
|
|
|
|
I am using SharpGL to add a solid object to a scene by clicking a button.
private void InitElements(Scene scene)
{
var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" };
scene.SceneContainer.AddChild(objectRoot);
// This implements free rotation(with translation and rotation).
var camera = GetCamera();
float cmX = camera.Position.X; float cmY = camera.Position.Y; float cmZ = camera.Position.Z;
float tgX = camera.Target.X; float tgY = camera.Target.Y; float tgZ = camera.Target.Z;
float upX = camera.UpVector.X; float upY = camera.UpVector.Y; float upZ = camera.UpVector.Z;
objectArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ);
objectRoot.AddEffect(objectArcBallEffect);
var axisRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "axis root" };
scene.SceneContainer.AddChild(axisRoot);
axisArcBallEffect = new ArcBallEffect(cmX, cmY, cmZ, tgX, tgY, tgZ, upX, upY, upZ);
axisRoot.AddEffect(axisArcBallEffect);
InitLight(objectRoot);
InitAxis(objectRoot);
InitAxis(axisRoot);
InitFrameElement(6, 24, 7, objectRoot);
}
After I initiate the solid elements in scene, I would like to add a solid object to that scene by clicking a button. I successfully add it in scene. But I cannot drag and rotate it with the initial elements in the scene. It means I didn't successfully add it to the same scene. Thanks in advance.
private void btnAddEllement_Click(object sender, EventArgs e)
{
var objectRoot = new SharpGL.SceneGraph.Primitives.Folder() { Name = "Root" };
var scene = this.sceneControl1.Scene;
addCylinder(objectRoot, 50, 30, 100, 5);
scene.SceneContainer.AddChild(objectRoot);
}
|
|
|
|
|
|
Hi,
When I printed a text on screen, I saw the text height equal to "tmHeight- tmInternalLeading".
For example: I printed a text size "8" on screen, I got the actual text height "tmHeight - tmInternalLeading" which is less than "8".
I printed a letter of "H" which height is less than "8", when I used "Arial" true type font of size "8".
Is there a way to make a actual text height (on screen) (ascent) equal to "8"?
Best,
-- modified 12-Jun-14 15:38pm.
|
|
|
|
|
8 points, 8 pixel, 8em? And where?
transoft wrote: Is there a way to make a actual text height (on screen) (ascent) equal to "8"? Yes, by setting the font-size. Do keep in mind that different characters have different heights', unless you're using a monospace font like courier.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for reply.
Maybe I did not make clear.
I set font size to be 8 unit which should be printed on screen to be (suppose) 100. But I got 90 (letter height) which equals to ascent.
It looks like font size is defined to be equal to "ascent + InternalLeading".
My question is: Is there a way to let (letter height) to be "ascent + InternalLeading".
|
|
|
|
|
transoft wrote: Maybe I did not make clear.
True. Which "unit"? A pixel can be a unit, a centimeter can be one.
Printed on screen? On a form as a label? Drawed as a bitmap?
transoft wrote: It looks like font size is defined to be equal to "ascent + InternalLeading". Where did you get that information? The font size is usually set by specifying the size property, as shown here[^]. Can you post some code that explains what you're doing?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The information -- is correct. There is internal leading (rhymes with sledding) and external leading. They are there to pad the character within its space and to provide space between lines for things like ascenders and descenders, which exceed the character's space.
|
|
|
|
|
I am using C++ and GDI+. I am drawing 2D diagrams. I am using the standard lines, ellipse, rotation transformations and Fonts. I need to scale the print so the screen image fills a single page. I need to avoid pixilation, the print should retain the curved lines and curves in the font. The GDI+ print tutorials I am finding are very basic. Can someone point me to a GDI+ printing tutorial that shows this type of scaled printing.
Thanks
Larry
|
|
|
|
|
|
I have been surprised how difficult it is to print a GDI+ screen as a rescaled fit-to-page. I will go back to google but I have not yet found any c++ code to do this.
|
|
|
|
|
|
Member 10853121 wrote: I need to avoid pixilation, the print should retain the curved lines and curves in the font. If you scale/zoom, then you will have pixelation. You could throw in a smoothing-effect, but that would simply blur them pixels.
If you don't want pixelation, draw the image again. Adjust coordinates to match the desired size.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi friends,
I am working on a biomedical application. I need to import a 3D model
of heart and displaying it after rotation. I use C# and the model is
stored in a 3ds file (I have an obj file,too). I don't need high
performance, engines. I just need the simplest engine for rotating and
displaying this model.
I was wondering if you could help me.
I am looking forward to hearing from you,
|
|
|
|
|
Please don't cross post. You have posted this in the C# forum as well.
|
|
|
|
|
|
Greetings!
I have a camera attached on my windows-pc (win7) and view the camera output in a window from the camera software (RsCap_1.11.exe).
Now I try to capture this window with BitBlt and GetDIBits, however I get a black screen only.
This method works with the full desktop or other windows.
Any hints how I have to access the video window?
|
|
|
|
|