Click here to Skip to main content
13,627,931 members

ATL / WTL / STL

 
GeneralRe: To take input for n number of arrays and print it. Pin
Richard MacCutchan10-Dec-17 6:18
protectorRichard MacCutchan10-Dec-17 6:18 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 6:48
memberTarun Jha10-Dec-17 6:48 
GeneralRe: To take input for n number of arrays and print it. Pin
Richard MacCutchan10-Dec-17 6:52
protectorRichard MacCutchan10-Dec-17 6:52 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 7:19
memberTarun Jha10-Dec-17 7:19 
AnswerRe: To take input for n number of arrays and print it. Pin
Member 1332249811-Dec-17 8:55
memberMember 1332249811-Dec-17 8:55 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha11-Dec-17 10:56
memberTarun Jha11-Dec-17 10:56 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha16-Dec-17 5:41
memberTarun Jha16-Dec-17 5:41 
QuestionHow do I keyboard input in OpenGL Pin
Mr. Anup Roy1-Dec-17 3:57
professionalMr. Anup Roy1-Dec-17 3:57 
Hello,

I am trying to solve my OpenGL pyramid project. If anyone can please help me with a code as soon as possible.

I have to do when I build the code it will come black window After that perform the following task:

01. F1+r = 60' rotation(static)
02. F2+r =45' rotation(continuous x-axis)
03. CTRL+w = White
04. B = Black

Thanks for your concern and help.


#include <stdlib.h>

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

// all variables initialized to 1.0, meaning
// the triangle will initially be white
float red=1.0f, blue=1.0f, white=1.0f;

// angle for rotating triangle
float angle = 0.0f;

void changeSize(int w, int h) {

	// Prevent a divide by zero, when window is too short
	// (you cant make a window of zero width).
	if (h == 0)
		h = 1;
	float ratio =  w * 1.0 / h;

        // Use the Projection Matrix
	glMatrixMode(GL_PROJECTION);

        // Reset Matrix
	glLoadIdentity();

	// Set the viewport to be the entire window
	glViewport(0, 0, w, h);

	// Set the correct perspective.
	gluPerspective(45.0f, ratio, 0.1f, 100.0f);

	// Get Back to the Modelview
	glMatrixMode(GL_MODELVIEW);
}

void renderScene(void) {

	// Clear Color and Depth Buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Reset transformations
	glLoadIdentity();

	// Set the camera
	gluLookAt(	0.0f, 0.0f, 10.0f, 0.0f, 0.0f,  0.0f, 0.0f, 1.0f,  0.0f);

	glRotatef(angle, 1.0f, 1.0f, 0.0f);

	glColor3f(red,white,blue);
	glBegin(GL_TRIANGLES);
	  //glColor3f(1.0, 1.0, 1.0);     // Red
      glVertex3f( 0.0f, 1.0f, 0.0f);
     // glColor3f(1.0, 1.0, 1.0);    // Green
      glVertex3f(-1.0f, -1.0f, 1.0f);
      //glColor3f(1.0, 1.0, 1.0);     // Blue
      glVertex3f(1.0f, -1.0f, 1.0f);
 
      // Right
     // glColor3f(0.0, 1.0, 1.0);     // Red
      glVertex3f(0.0f, 1.0f, 0.0f);
      //glColor3f(0.0, 1.0, 1.0);   // Blue
      glVertex3f(1.0f, -1.0f, 1.0f);
      //glColor3f(0.0, 1.0, 1.0);    // Green
      glVertex3f(1.0f, -1.0f, -1.0f);
 
      // Back
      //glColor3f(0.0, 0.5, 0.0);    // Red
      glVertex3f(0.0f, 1.0f, 0.0f);
    // glColor3f(0.0, 0.5, 0.0);    // Green
      glVertex3f(1.0f, -1.0f, -1.0f);
    // glColor3f(0.0, 0.5, 0.0);     // Blue
      glVertex3f(-1.0f, -1.0f, -1.0f);
 
      // Left
    // glColor3f(0.6, 0.6, 0.6);       // Red
      glVertex3f( 0.0f, 1.0f, 0.0f);
     // glColor3f(0.663, 0.663, 0.663);      // Blue
      glVertex3f(-1.0f,-1.0f,-1.0f);
    // glColor3f(0.663, 0.663, 0.663);      // Green
      glVertex3f(-1.0f,-1.0f, 1.0f);

	glEnd();

	angle+=0.1f;

	glutSwapBuffers();
}

void processNormalKeys(unsigned char key, int x, int y) {

	if (key == 27)
		exit(0);
}

void processSpecialKeys(int key, int x, int y) {

	switch(key) {

			if(key=='1')
	{
		angle+=10;
	}
	if(key=='0')
	{
		angle+=1;
	}

		case GLUT_KEY_F1 :
				red = 1.0;
				white = 0.0;
				blue = 0.0;
				; break;
		case GLUT_KEY_F2 :
				red = 0.0;
				white = 1.0;
				blue = 0.0; break;
		case GLUT_KEY_F3 :
				red = 0.0;
				white = 0.0;
				blue = 1.0; break;
	}
}

int main(int argc, char **argv) {

	// init GLUT and create window
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(100,100);
	glutInitWindowSize(640,480);
	glutCreateWindow("Lighthouse3D- GLUT Tutorial");

	// register callbacks
	glutDisplayFunc(renderScene);
	glutReshapeFunc(changeSize);
	glutIdleFunc(renderScene);

	// here are the new entries
	glutKeyboardFunc(processNormalKeys);
	glutSpecialFunc(processSpecialKeys);

	// enter GLUT event processing cycle
	glutMainLoop();

	return 1;
}

QuestionHow to get cpu speed and ram manufaturer C Languae? Pin
Uzair Ahmad12-Nov-17 4:56
memberUzair Ahmad12-Nov-17 4:56 
AnswerRe: How to get cpu speed and ram manufaturer C Languae? Pin
Afzaal Ahmad Zeeshan1-Dec-17 4:32
mvpAfzaal Ahmad Zeeshan1-Dec-17 4:32 
QuestionHow to Disable open drop down Pin
yaswanthdasari24-Oct-17 21:36
memberyaswanthdasari24-Oct-17 21:36 
SuggestionRe: How to Disable open drop down Pin
Richard MacCutchan24-Oct-17 22:44
protectorRichard MacCutchan24-Oct-17 22:44 
GeneralRe: How to Disable open drop down Pin
yaswanthdasari25-Oct-17 0:38
memberyaswanthdasari25-Oct-17 0:38 
AnswerRe: How to Disable open drop down Pin
Daniel Pfeffer25-Oct-17 1:11
professionalDaniel Pfeffer25-Oct-17 1:11 
GeneralRe: How to Disable open drop down Pin
yaswanthdasari25-Oct-17 23:50
memberyaswanthdasari25-Oct-17 23:50 
QuestionHow To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 21:50
memberMember 1347149317-Oct-17 21:50 
QuestionRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 21:58
protectorRichard MacCutchan17-Oct-17 21:58 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 22:09
memberMember 1347149317-Oct-17 22:09 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 22:12
protectorRichard MacCutchan17-Oct-17 22:12 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 22:29
memberMember 1347149317-Oct-17 22:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 22:45
protectorRichard MacCutchan17-Oct-17 22:45 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 22:44
mvpJochen Arndt17-Oct-17 22:44 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 23:13
memberMember 1347149317-Oct-17 23:13 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 23:29
mvpJochen Arndt17-Oct-17 23:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 0:16
protectorRichard MacCutchan18-Oct-17 0:16 

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.


Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.180712.1 | Last Updated 16 Jul 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid