Click here to Skip to main content
16,005,080 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: data not write at .txt file Pin
Y_Kaushik3-Aug-07 21:59
Y_Kaushik3-Aug-07 21:59 
AnswerRe: data not write at .txt file Pin
CPallini2-Aug-07 23:42
mveCPallini2-Aug-07 23:42 
GeneralRe: data not write at .txt file Pin
Y_Kaushik3-Aug-07 0:10
Y_Kaushik3-Aug-07 0:10 
GeneralRe: data not write at .txt file Pin
CPallini3-Aug-07 0:22
mveCPallini3-Aug-07 0:22 
AnswerRe: data not write at .txt file Pin
David Crow3-Aug-07 3:43
David Crow3-Aug-07 3:43 
QuestionHow to import opengl programs in VC++? Pin
vikramkarthik2-Aug-07 22:39
vikramkarthik2-Aug-07 22:39 
AnswerRe: How to import opengl programs in VC++? Pin
Hamid_RT2-Aug-07 22:52
Hamid_RT2-Aug-07 22:52 
GeneralRe: How to import opengl programs in VC++? Pin
vikramkarthik2-Aug-07 22:57
vikramkarthik2-Aug-07 22:57 
thank u for reply..
actually below codes are opengraphical language(OpenGL)..
this program should be called in VC++ ..
how i have to call in my program..
help me..


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#include <gl glut.h="">


/*
* Window properties
*/
#define WINDOW_WIDTH 500
#define WINDOW_HEIGHT 500
#define WINDOW_X 100
#define WINDOW_Y 100
#define WINDOW_TITLE "RGB-ColorCube"

/*
* Perspective properties
*/
#define FOV_ANGLE 30

#define CENTER_X 0.0
#define CENTER_Y 0.0
#define CENTER_Z 0.0

#define VIEWER_X 0.0
#define VIEWER_Y 0.0
#define VIEWER_Z -2.1

#define UP_X 0.0
#define UP_Y 1.0
#define UP_Z 0.0

#define CLIPPLANE_NEAR 1.0
#define CLIPPLANE_FAR 20.0


#define ROTATION_SPEED 2.0

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

GLfloat rot_x = 0.0, rot_y = 0.0;
GLfloat saved_x, saved_y;

/*
* Material colors used for shading
*/
GLfloat red[4] = {.8, 0.0, 0.0, 1.0};
GLfloat white[4] = {.8, .8, .8, 1.0};

/*
* Function prototypes
*/
void usage(void);
void draw_scene(void);
void draw_object(void);
void init(int argc, char **argv, void (*draw)(void));
void save_position(int button, int state, int x, int y);
struct point get_coords(double a, double b);
void vertex(double a, double b);
void rotate(int x, int y);
void set_color(int angle);

int main(int argc, char **argv) {
/*
* Init OpenGL and enter the event loop
*/
init(argc, argv, draw_scene);

return 0;
}

/*
* Handle rotations and buffer swapping and call the function draw_object
* which does the actual drawing
*/
void draw_scene(void) {
static GLfloat old_rot_matrix[16];
static int initialized = 0;
GLfloat new_rot_matrix[16];

/* calculate new rotation matrix */
glPushMatrix();
glLoadIdentity();
glRotatef(rot_x, 1.0, 0.0, 0.0);
glRotatef(rot_y, 0.0, 1.0, 0.0);
glGetFloatv(GL_MODELVIEW_MATRIX, new_rot_matrix);
glPopMatrix();

/* calculate total rotation */
glPushMatrix();
glLoadIdentity();
glMultMatrixf(new_rot_matrix);
if (initialized) {
glMultMatrixf(old_rot_matrix);
}

glGetFloatv(GL_MODELVIEW_MATRIX, old_rot_matrix);
initialized = 1;
glPopMatrix();

glPushMatrix();
glMultMatrixf(old_rot_matrix);

draw_object();

glPopMatrix();
glFlush();
glutSwapBuffers();
}

/*
* Initialize the OpenGL machine
*/
void init(int argc, char **argv, void (*draw)(void)) {
GLfloat light0_pos[] = {100.0, 100.0, 100.0, 1.0};
GLfloat light0_color[] = {1.0, 1.0, 1.0, 1.0};
GLfloat ambient_light[] = {0.8, 0.8, 0.8, 1.0};

glutInit(&argc, argv);

/* Create a window */
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
glutInitWindowPosition(WINDOW_X, WINDOW_Y);
glutCreateWindow(WINDOW_TITLE);
glClearColor(0.0, 0.0, 0.0, 0.0);

/* Set up some light sources */
glLightfv(GL_LIGHT0, GL_POSITION, light0_pos);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_color);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light);

glEnable(GL_LIGHT0);
/* glEnable(GL_LIGHTING); */

glEnable(GL_DEPTH_TEST);

glShadeModel(GL_SMOOTH);

/* Create a viewing frustum */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(FOV_ANGLE, WINDOW_WIDTH/WINDOW_HEIGHT, CLIPPLANE_NEAR,
CLIPPLANE_FAR);
gluLookAt(VIEWER_X, VIEWER_Y, -VIEWER_Z, CENTER_X, CENTER_Y, CENTER_Z,
UP_X, UP_Y, UP_Z);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(VIEWER_X, VIEWER_Y, VIEWER_Z);

glutDisplayFunc(draw);
glutMouseFunc(save_position);
glutMotionFunc(rotate);
glutMainLoop();

/* Not reached */
}

/*
* Save the position of the mouse pointer where the bottun press occured
*/
void save_position(int button, int state, int x, int y) {
if (state == GLUT_DOWN) {
saved_x = x;
saved_y = y;
}
}

/*
* Calculate the angle the object has rotated by since the last update
*/
void rotate(int x, int y) {
rot_y = (GLfloat)(x - saved_x) * ROTATION_SPEED;
rot_x = (GLfloat)(y - saved_y) * ROTATION_SPEED;
saved_x = x;
saved_y = y;

glutPostRedisplay();
}

/*
* Draw a object
*/
void draw_object(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBegin(GL_QUAD_STRIP);

glNormal3f(0,0,1);

glColor3f(0,0,0);
glVertex3f(-0.5,-0.5,-0.5);

glColor3f(0,1,0);
glVertex3f(-0.5,0.5,-0.5);

glColor3f(1,0,0);
glVertex3f(0.5,-0.5,-0.5);

glColor3f(1,1,0);
glVertex3f(0.5,0.5,-0.5);

glNormal3f(1,0,0);
glColor3f(1,0,1);
glVertex3f(0.5,-0.5,0.5);

glColor3f(1,1,1);
glVertex3f(0.5,0.5,0.5);

glNormal3f(0,0,1);
glColor3f(0,0,1);
glVertex3f(-0.5,-0.5,0.5);
glColor3f(0,1,1);
glVertex3f(-0.5,0.5,0.5);

glNormal3f(-1,0,0);
glColor3f(0,0,0);
glVertex3f(-0.5,-0.5,-0.5);
glColor3f(0,1,0);
glVertex3f(-0.5,0.5,-0.5);

glEnd();


glBegin(GL_QUADS);

glNormal3f(0,1,0);

glColor3f(0,1,0);
glVertex3f(-0.5,0.5,-0.5);

glColor3f(0,1,1);
glVertex3f(-0.5,0.5,0.5);

glColor3f(1,1,1);
glVertex3f(0.5,0.5,0.5);

glColor3f(1,1,0);
glVertex3f(0.5,0.5,-0.5);

glEnd();

glBegin(GL_QUADS);

glNormal3f(0,-1,0);

glColor3f(0,0,0);
glVertex3f(-0.5,-0.5,-0.5);

glColor3f(0,0,1);
glVertex3f(-0.5,-0.5,0.5);

glColor3f(1,0,1);
glVertex3f(0.5,-0.5,0.5);

glColor3f(1,0,0);
glVertex3f(0.5,-0.5,-0.5);

glEnd();

}
GeneralRe: How to import opengl programs in VC++? Pin
Hamid_RT3-Aug-07 1:12
Hamid_RT3-Aug-07 1:12 
QuestionHow to get HTML output from *.asmx file Pin
Pankaj.Jain2-Aug-07 21:33
professionalPankaj.Jain2-Aug-07 21:33 
QuestionManually deleting the Menu Pin
Anu_Bala2-Aug-07 21:07
Anu_Bala2-Aug-07 21:07 
AnswerRe: Manually deleting the Menu Pin
Anurag Gandhi2-Aug-07 21:24
professionalAnurag Gandhi2-Aug-07 21:24 
AnswerRe: Manually deleting the Menu Pin
Roger Broomfield2-Aug-07 21:46
Roger Broomfield2-Aug-07 21:46 
GeneralRe: Manually deleting the Menu Pin
Anu_Bala2-Aug-07 22:40
Anu_Bala2-Aug-07 22:40 
AnswerRe: Manually deleting the Menu Pin
KarstenK2-Aug-07 22:59
mveKarstenK2-Aug-07 22:59 
QuestionTo resize mfc's dialog dialog? Pin
Mushtaque Nizamani2-Aug-07 21:04
Mushtaque Nizamani2-Aug-07 21:04 
AnswerRe: To resize mfc's dialog dialog? Pin
Hans Dietrich2-Aug-07 21:12
mentorHans Dietrich2-Aug-07 21:12 
AnswerRe: To resize mfc's dialog dialog? Pin
Hamid_RT2-Aug-07 21:16
Hamid_RT2-Aug-07 21:16 
AnswerRe: To resize mfc's dialog dialog? Pin
Russell'2-Aug-07 22:15
Russell'2-Aug-07 22:15 
QuestionTokenizer ... Pin
devvvy2-Aug-07 20:34
devvvy2-Aug-07 20:34 
AnswerRe: Tokenizer ... Pin
Hans Dietrich2-Aug-07 21:09
mentorHans Dietrich2-Aug-07 21:09 
GeneralRe: Tokenizer ... Pin
devvvy3-Aug-07 18:04
devvvy3-Aug-07 18:04 
AnswerRe: Tokenizer ... Pin
Haroon Sarwar2-Aug-07 21:53
Haroon Sarwar2-Aug-07 21:53 
QuestionHow to Convert Excel sheet file to .cvs format using VC++ Pin
SnaKeBeD2-Aug-07 20:15
SnaKeBeD2-Aug-07 20:15 
AnswerRe: How to Convert Excel sheet file to .cvs format using VC++ Pin
Hamid_RT2-Aug-07 21:02
Hamid_RT2-Aug-07 21:02 

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.