|
|
|
You can use the Windows API: UrlDownloadToFileA or UrlDownloadToFileW .
|
|
|
|
|
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <gl\glew.h>
#include <gl\gl.h>
#include <gl\glut.h>
static GLfloat f1,f2,f3;
static void initA(void)
{
GLfloat fogColor[4]={0.0,0.25,0.25,1.0};
f1=1.0f;
f2=5.0f;
f3=10.0f;
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_EXP);
glFogfv(GL_FOG_COLOR,fogColor);
glFogf(GL_FOG_DENSITY,0.25);
glHint(GL_FOG_HINT,GL_DONT_CARE);
glFogi(GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE_EXT);
glClearColor(0.0,0.25,0.25,1.0);
}
void displayA(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.75,0.0);
glBegin(GL_TRIANGLES);
glFogCoordfEXT(f1);
glVertex3f(0.2f,0.2f,0.0f);
glFogCoordfEXT(f2);
glVertex3f(-0.2f,0.0f,-0.5f);
glFogCoordfEXT(f3);
glVertex3f(0.0f,0.2f,-1.0f);
glEnd();
glutSwapBuffers();
}
void reshapeA(int w,int h)
{
glViewport(0,0,(GLint)w,(GLint)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,1.0,0.25,25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0,0.0,-5.0);
}
void keyboardA(unsigned char key,int x,int y)
{
switch(key)
{
case 'c':
glFogi(GL_FOG_COORDINATE_SOURCE_EXT,GL_FRAGMENT_DEPTH);
glutPostRedisplay();
break;
case 'C':
glFogi(GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE);
glutPostRedisplay();
break;
case '1':
f1=f1+0.25;
glutPostRedisplay();
break;
case '2':
f2=f2+0.25;
glutPostRedisplay();
break;
case '3':
f3=f3+0.25;
glutPostRedisplay();
break;
case '8':
if(f1&amp;amp;amp;amp;amp;gt;0.25)
{
f1=f1-0.25;
glutPostRedisplay();
}
break;
case '9':
if(f2&amp;amp;amp;amp;amp;gt;0.25)
{
f2=f2-0.25;
glutPostRedisplay();
}
break;
case '0':
if(f3&amp;amp;amp;amp;amp;gt;0.25)
{
f3=f3-0.25;
glutPostRedisplay();
}
break;
case 'b':
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0,0.0,-0.25);
glutPostRedisplay();
break;
case 'f':
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0,0.0,0.25);
glutPostRedisplay();
break;
case 27:
exit(0);
break;
default:
break;
}
}
int main(int argc,char** argv)
{
glutInit(&amp;amp;amp;amp;amp;amp;argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(400,400);
glutCreateWindow("Fog effect Demo");
initA();
glutReshapeFunc(reshapeA);
glutKeyboardFunc(keyboardA);
glutDisplayFunc(displayA);
glutMainLoop();
return 0;
}
The code can be impiled,but it can not run. when it runs, the operate system give an exception message.I use vc6.0 as a tool.
modified on Tuesday, November 24, 2009 4:02 AM
|
|
|
|
|
Is there a question in there somewhere?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Yes,it can not run. There is an abnormal essage.
|
|
|
|
|
Please read the posting guidelines before posting on this message board (this is the message called "How to ask a question").
Points which require your attention:
1) Formatting of the code (use the code tag to format code properly)
2) No clear description of the problem (please provide details about it)
3) You say there's a "abnormal essage", then give the exact error message and in which conditions it occurs.
|
|
|
|
|
I am sorry for that. This is my fist time to ask help in this site.
|
|
|
|
|
You still didn't provide a lot of information. What is the exact error message ? Did you try to debug to see where your code causes problem ?
|
|
|
|
|
I have tried to debug. when it runs to the
" glFogCoordfEXT(f1); ",the program stops.
this is the error message:
AppName: fog.exe AppVer: 0.0.0.0 ModName: unknown
ModVer: 0.0.0.0 Offset: 00000000
|
|
|
|
|
Can you send an array of longs through a pipe? If it is possible, how would you do it?
Thanks in advance.
|
|
|
|
|
Typecast the array to whatever data type the function to send expects and give sizeof(array) as the size to be sent.
|
|
|
|
|
I never thought to do that, thanks so much, you're a lifesaver!
|
|
|
|
|
double a = 0.0000005;
char aa[50];
sprintf(aa,"s%lf",a);
printf("%s",aa);
Output:s0.000000
In the above code snippet, the variable aa can contain only 6 decimal precision. I would like to get an output "s0.0000005".
Could you please advice me on how to achieve this?
Thanks
|
|
|
|
|
See the MSDN documentation on printf format options[^]. It contains all the details of how you may customise this to your exact requirements.
|
|
|
|
|
|
I was hoping that my reply would encourage them to actually learn something beyond how to print to seven decimal places!
|
|
|
|
|
If they really want to, they will learn more after wondering what 9.7 means.
Otherwise they will never learn no matter what.
Just my opinion.
|
|
|
|
|
«_Superman_» wrote: If they really want to, they will learn more after wondering what 9.7 means.
I so want to believe that, but at my age I have more than 60 years of life experience to look back on ...
|
|
|
|
|
Ever the cockeyed optimist.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
Sorry if this is a basic question, I'm new to C++. How would I go about creating a DC for an image from a file (.png) and then getting the HDC of said DC.
|
|
|
|
|
The MSDN documentation on Device Contexts[^] contains the functions you may use to paint onto any surface real or virtual.
See also the documentation on Windows GDI for useful tutorials, or this CodeProject Article[^] on bitmaps.
|
|
|
|
|
Hi,
I am currently trying to insert a picture control with more than 256 colors in a MFC dialog in a VC 6.0 project. However, when I paste the bitmap, the IDB_BITMAP resource looks correct, but when I try to reference it in a static picture control, the color depth is decreased dramatically.
How can I display a bitmap ressource with 24 or 32 bit in a MFC 6.0 dialog?
|
|
|
|
|
Try replacing the .BMP file that is created in the res sub folder with the high color bitmap file.
|
|
|
|
|
Hey,
I would like to write a c++ program that compares 2 images.In fact, I have many B&W images of a boat. I want to compare the contours, so that I could know how alike the images are. And, I want to be able to know the error percentage after comparing.
Do you have any advice or can you tell me any paper or book could help me.
Thanks in advance,
Franckesh
|
|
|
|