|
forPower wrote:
vector(int s)
:sz(s),
elem(new double[s])
It means set the variable sz to the value of the constructor parameter s , and set the variable elem to point to a new array of doubles, of length s . It is a shorthand alternative to writing the lines
sz = s;
elem = new double[s];
|
|
|
|
|
A value can be put in a variable by either initialization and assignment.
Here is the difference -
double d = 25.4;
double d;
d = 25.4;
What you're doing is initializing a class member variable because you cannot do the initialization as I did above inside a class. (You can if the variable is a static const variable.)
Read about it here - Initializing C++ Class Members[^]
|
|
|
|
|
i have this code to load a bmp picture. but i don't know how to use it.!!!
<br />
#include "stdafx.h"<br />
#include "glaux.h"<br />
#include "glut.h"<br />
<br />
GLuint texture[6];<br />
<br />
int LoadGLTextures()<br />
{<br />
int Status=FALSE;
<br />
AUX_RGBImageRec *TextureImage[1];
<br />
memset(TextureImage,0,sizeof(void *)*2);
<br />
if (TextureImage[0]=LoadBMP("apple.bmp"))<br />
{<br />
Status=TRUE;
<br />
glGenTextures(3, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);<br />
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, <br />
TextureImage[0]->sizeX, TextureImage[0]->sizeY,0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);<br />
<br />
glBindTexture(GL_TEXTURE_2D, texture[1]);<br />
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);<br />
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);<br />
glTexImage2D(GL_TEXTURE_2D, 0, 3, <br />
TextureImage[0]->sizeX, TextureImage[0]->sizeY,0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);<br />
<br />
glBindTexture(GL_TEXTURE_2D, texture[2]);<br />
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);<br />
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX,TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE,TextureImage[0]->data);
<br />
<br />
if (TextureImage[0])
{<br />
if (TextureImage[0]->data)
{<br />
free(TextureImage[0]->data);
}<br />
free(TextureImage[0]);
}<br />
}<br />
<br />
return Status; <br />
}<br />
AUX_RGBImageRec * LoadBMP(char *Filename)<br />
{<br />
FILE *File=NULL;
<br />
if (!Filename)
{<br />
return NULL;
}<br />
<br />
File=fopen(Filename,"r");
<br />
if (File)
{<br />
fclose(File);
return auxDIBImageLoad(Filename);
}<br />
<br />
return NULL; <br />
}<br />
|
|
|
|
|
What you need to do is to get an idea on what to do to use an image as texture with OpenGL by reading the code you posted. Then you can incorporate that into your project. The basic idea is not that complicated.
If the piece of code you provided is part of a sample project, you can compile and run the project to see how it works.
Hope this helps. Happy programming!
|
|
|
|
|
Can you write a simple code which use this code as an example?
thank very much.
|
|
|
|
|
I think the code you've provided is already an example and "simple" enough (saw the inline comments?)
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
but i put apple.bmp in the same folder with main code, write int main() to use it. then it did not work.
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(0, 0);
glutCreateWindow("Hello OpenGL!");
OnInit();
glutDisplayFunc(OnDraw);
glutReshapeFunc(OnSize);
glutIdleFunc(OnIdle);
glutKeyboardFunc(OnKey);
glutMouseFunc(OnMouse);
glutSpecialFunc(OnKeySpecial);
LoadGLTextures();
glutMainLoop();
return 0;
}
|
|
|
|
|
Did you debug it to see if it could not find the file or bitmap failed to load? If you're using Visual Studio, I think you need to put the bitmap in the folder with the executable, not the source so Release or Debug.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
|
That's it? Where did the executable file end up?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
the problem is:
i have this code to load bmp picture, but i don't know how to use.
int LoadGLTextures();
i only need to load bmp picture.
|
|
|
|
|
Do you still have the box your computer came in?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
main.obj : error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
In your project settings, add the file Glaux.lib to your "import" box of the link section.
Hope this helps. Happy programming!
|
|
|
|
|
please share me link to down
|
|
|
|
|
You may download the latest OpenGL SDK here [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
OpenGL comes with Windows
|
|
|
|
|
Not higher than 1.1. Another standards body they should have not let Microsoft join.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
I have written a C program to insert a row in SQL Server 2000 but it seems not to work.
#include<stdio.h>
#include<conio.h>
int main(void)
{
int number;
char fname[80], lname[80];
clrscr();
printf("Enter a number : ");
scanf("%d",&number);
printf("Enter your first name : ");
scanf("%s",fname);
printf("Enter your last name : ");
scanf("%s",lname);
execl sql include sqlca;
execl sql insert into Table1
values(number,",'",fname,"','",lname,"'");
getch();
return 0;
}
|
|
|
|
|
Ishaan Karnik wrote: I have written a C program to insert a row in SQL Server 2000 but it seems not to work.
Could you explain what it is that does not work?
|
|
|
|
|
The error i recieve while compiling
Compiling ..\SOURCE\SQL.C
Error ..\SOURCE\SQL.C 15: Undefined symbol 'execl'
Error ..\SOURCE\SQL.C 15: Statement missing ;
Error ..\SOURCE\SQL.C 16: Statement missing ;
|
|
|
|
|
Ishaan Karnik wrote: Undefined symbol 'execl'
Well I guess there is no such command in the C language!
|
|
|
|
|
I have taken the command from SQL The Complete Reference.
|
|
|
|
|
It looks like unix command line codes instead of C, but maybe that's just me
|
|
|
|
|
Harold (above) is correct, these are Unix commands, so unless you are compiling in a UNIX system they will not be recognised. What exactly does the SQL book say about this?
|
|
|
|