Click here to Skip to main content
15,909,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMAPISendMail() fails with Thunderbird, error code -2147467259 Pin
Dave Calkins14-Jun-10 5:49
Dave Calkins14-Jun-10 5:49 
AnswerRe: MAPISendMail() fails with Thunderbird, error code -2147467259 Pin
Dave Calkins14-Jun-10 10:48
Dave Calkins14-Jun-10 10:48 
QuestionGame State using C++ Pin
T.RATHA KRISHNAN14-Jun-10 4:39
T.RATHA KRISHNAN14-Jun-10 4:39 
AnswerRe: Game State using C++ Pin
Chris Losinger14-Jun-10 4:46
professionalChris Losinger14-Jun-10 4:46 
AnswerRe: Game State using C++ Pin
Aescleal14-Jun-10 7:30
Aescleal14-Jun-10 7:30 
AnswerRe: Game State using C++ Pin
Stephen Hewitt14-Jun-10 14:14
Stephen Hewitt14-Jun-10 14:14 
QuestionHow can specific type details be filtered from Dia2Dump ? Pin
glitteringsound14-Jun-10 0:45
glitteringsound14-Jun-10 0:45 
Questionhow to bounce balls on quad Pin
nearest13-Jun-10 23:57
nearest13-Jun-10 23:57 
I have made a quad in open gl in vc++ and balls.Now i want to bounce the balls on the quad repeadetly but i donot know how to do this.I thought of timer function to use to be called repeatedly but i donot know how to use it??which functions to use to set the position of y axis???I am sending thw code.Can anyone tell???

//#include <GL/gl.h>

#include <windows.h>
#include <stdio.h>
#include <GL/glut.h>
#include<math.h>
//GLuint texture;
void drawEllipse(float xradius, float yradius,float h,float k,int i);
void TimerFunction(int value);
void ChangeSize(int w, int h); 
void SetUpRC();
float angle=90.0;
GLfloat rsize = 25;
int a=10;
int b=10;
//////////////////////////////////////////////////////

float pi=180;
const float DEG2RAD = 3.14159/180;
float z=0.0f;
float u=1.0f;
// Initial square position and size
GLfloat x[10];
GLfloat y[10];
//GLfloat rsize = 25;
//int a=10;
//int b=10;
// Step size in x and y directions
// (number of pixels to move each time)
GLfloat xstep[10]; 
GLfloat ystep[10];

// Keep track of windows changing width and height
GLfloat windowWidth;
GLfloat windowHeight;
////////////////////////////////////////////////////////////////
double frame;
//void display2 (void);
/*GLuint LoadTexture( const char * filename, int width, int height )
{
    GLuint texture;
    unsigned char * data;
    FILE * file;

    //The following code will read in our RAW file
    file = fopen( filename, "rb" );
    if ( file == NULL ) 
		return 0;
    data = (unsigned char *)malloc( width * height * 3 );
    fread( data, width * height * 3, 1, file );
    fclose( file );

    glGenTextures( 1, &texture ); //generate the texture with the loaded data
    glBindTexture( GL_TEXTURE_2D, texture ); //bind the texture to it’s array
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //set texture environment parameters

    //here we are setting what textures to use and when. The MIN filter is which quality to show
    //when the texture is near the view, and the MAG filter is which quality to show when the texture
    //is far from the view.

    //The qualities are (in order from worst to best)
    //GL_NEAREST
    //GL_LINEAR
    //GL_LINEAR_MIPMAP_NEAREST
    //GL_LINEAR_MIPMAP_LINEAR

    //And if you go and use extensions, you can use Anisotropic filtering textures which are of an
    //even better quality, but this will do for now.
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR );

    //Here we are setting the parameter to repeat the texture instead of clamping the texture
    //to the edge of our shape. 
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

    //Generate the texture with mipmaps
    gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height,GL_RGB, GL_UNSIGNED_BYTE, data ); 
    free( data ); //free the texture
    return texture; //return whether it was successfull
}

void FreeTexture( GLuint texture )
{
  glDeleteTextures( 1, &texture ); 
}*/





void cube (void) {
    glBindTexture( GL_TEXTURE_2D, texture );
	//glColor3f(0.0,0.0,0.0);
  //  glScalef(2,2,1);
    glBegin (GL_QUADS);
    //glTexCoord2d(0,0); 
    glVertex3f(-2,2,0);
   // glTexCoord2d(1,0); 
    glVertex3f(2,2,0);
    //glTexCoord2d(1,1); 
    glVertex3f(2,-2,0);
    //glTexCoord2d(0,1); 
    glVertex3f(-2,-2,0);
    glEnd();
}

void display (void) {
		GLfloat aspectRatio;
    glClearColor (0.0,0.0,0.0,1.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glLoadIdentity(); 
   glPushMatrix();
	//texture calling
	glEnable( GL_TEXTURE_2D );
	 glTranslatef(2,0,-10);
      cube();
	  glPopMatrix();
	
//////////////////////////////////////////////////////////	

glPushMatrix();
//sets the size of bubbles
	glTranslatef(0,0,-2.5);

aspectRatio = (GLfloat)640 / (GLfloat)480;
   
windowWidth = 100;
windowHeight = 100 / aspectRatio;
glOrtho (-100.0, 100.0, -windowHeight, windowHeight, 1.0, -1.0);
//draw bubbles	
for(int i=0;i<1;i++)
		{
//glTranslatef(i+20,0,-5);

//glRotatef (angle, 0, 0, 1);
//glRotatef (angle, 0, 0, 5);

//glRotatef (angle, 0, 0, 5);
//glRotatef (angle, 0, 0, 5);
//glRotatef (angle, 0, 0, 0);

drawEllipse(a+2, b+2,x[i],y[i] - rsize,i);

		}

//sets the rendering scene


 

 // glBlendFunc(GL_SRC_ALPHA, GL_ONE);
SetUpRC();
glPopMatrix();
glutSwapBuffers();

    
   	
}
	//angle=angle+0.02;



//}
void SetUpRC()
{

{
int a=0,b=0;
    // Set clear color to blue
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
for(int i=0;i<1;i++)
{
//xstep[i]=2.0;
ystep[i]=1.5;
	}
x[0]=60;
y[0]=50;

x[1]=20;
y[1]=30;
x[2]=-25;
y[2]=45;
x[3]=-70;
y[3]=70;
x[4]=-75;
y[4]=20;
x[5]=-60;
y[5]=40;
x[6]=70;
y[6]=45;
x[7]=-100;
y[7]=40;
x[8]=-140;
y[8]=60;
x[9]=-170;
y[9]=50;

}

}

void reshape (int w, int h) {

    glViewport (0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
	 
    glMatrixMode (GL_MODELVIEW);

}

void drawEllipse(float xradius, float yradius,float h,float k,int i)
{
   glBegin(GL_POLYGON);
   
 

   for (int i1=0; i1< 360; i1++)
   {
	   
		  //glColor3f(0.0f,1.0f, 0.0f); 
	   glColor3f(z+1.0f, 0.0f, u+1.0f);
	   

      //convert degrees into radians
      float degInRad = i1*DEG2RAD;
      glVertex2f(cos(degInRad)*xradius+h,sin(degInRad)*yradius+k);
   }
   glBegin(GL_TRIANGLE_FAN);
 
   for ( i1=0; i1 < 360; i1++)
   {
	 	 //glColor3f(0.0f,1.0f, 0.0f);
	   glColor3f(z+1.0f, 0.0f, u+1.0f);
      //convert degrees into radians
      float degInRad = i1*DEG2RAD;
	    glColor3f(1.0,z+1.0,u+2.0);
      glVertex2f(cos(degInRad)*xradius+h,sin(degInRad)*yradius+k);
   }
 
   glEnd();
}






///////////////////////////////////////////////////////////
// Called by GLUT library when the window has chanaged size

///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
void init (void) 
{
	
    //texture[0] = LoadTexture( "grey.bmp", 1024,677 );
//texture = LoadTexture( "Island_2.raw", 1024, 768 );
   //texture[2] = LoadTexture( "niagrafall.raw", 800, 600 );
//	texture[3] = LoadTexture( "waterfall.raw", 2344, 1768 );
	//texture[4] = LoadTexture( "nadia.raw", 720,553);

}




int main (int argc, char **argv) {
    glutInit (&argc, argv);
    glutInitDisplayMode (GLUT_DOUBLE);
    glutInitWindowSize (800, 600);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("A basic OpenGL Window");
    init();
    glutDisplayFunc (display);
	glutReshapeFunc (reshape);
    glutIdleFunc (display);
	 :((  :(( 	
    glutMainLoop ();
    return 0;
}

AnswerRe: how to bounce balls on quad Pin
Maximilien14-Jun-10 0:52
Maximilien14-Jun-10 0:52 
AnswerRe: how to bounce balls on quad Pin
Cedric Moonen14-Jun-10 1:29
Cedric Moonen14-Jun-10 1:29 
AnswerRe: how to bounce balls on quad [modified] Pin
CPallini14-Jun-10 1:31
mveCPallini14-Jun-10 1:31 
Questionget the process' path by its pid Pin
Krauze13-Jun-10 23:07
Krauze13-Jun-10 23:07 
AnswerRe: get the process' path by its pid Pin
CPallini13-Jun-10 23:20
mveCPallini13-Jun-10 23:20 
GeneralRe: get the process' path by its pid Pin
Krauze14-Jun-10 1:52
Krauze14-Jun-10 1:52 
AnswerRe: get the process' path by its pid Pin
Richard MacCutchan13-Jun-10 23:40
mveRichard MacCutchan13-Jun-10 23:40 
GeneralRe: get the process' path by its pid Pin
Krauze14-Jun-10 1:53
Krauze14-Jun-10 1:53 
GeneralRe: get the process' path by its pid Pin
Richard MacCutchan14-Jun-10 3:58
mveRichard MacCutchan14-Jun-10 3:58 
QuestionRe: get the process' path by its pid Pin
norish14-Jun-10 8:41
norish14-Jun-10 8:41 
AnswerRe: get the process' path by its pid Pin
Krauze14-Jun-10 15:55
Krauze14-Jun-10 15:55 
QuestionListBox (CListBox) focus frame problems introduced with a shlwapi.dll security update in Windows XP 32 bit Pin
User 2694213-Jun-10 21:52
professionalUser 2694213-Jun-10 21:52 
QuestionC2061 Pin
T.RATHA KRISHNAN13-Jun-10 21:06
T.RATHA KRISHNAN13-Jun-10 21:06 
AnswerRe: C2061 Pin
«_Superman_»13-Jun-10 21:15
professional«_Superman_»13-Jun-10 21:15 
AnswerRe: C2061 PinPopular
Richard MacCutchan13-Jun-10 21:35
mveRichard MacCutchan13-Jun-10 21:35 
GeneralRe: C2061 Pin
Aescleal13-Jun-10 21:38
Aescleal13-Jun-10 21:38 
GeneralRe: C2061 Pin
Richard MacCutchan13-Jun-10 22:46
mveRichard MacCutchan13-Jun-10 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.