Drawing in C++

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
So I managed to "draw" a square with some basic C++ code.Question is how do i make it into a Cube? Also how do i make a circle into a sphere,a Triangle into a pyramid,etc? How does one code in C++ to make 3D objects?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Wouldn't it simply be determining where the camera is facing, to determine where vertices are, and then filling in the visible triangles?

I'm still new to this whole thing too, but that would seem like a logical way to do it. A library would, of course, be something you'd want if you didn't want to do a whole bunch of math calculation yourself.
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
Here's what i have so far.

Code:
#include<stdio.h>

 

#include<glut.h>

 

void Scene();

 

float fSphRadius = 0.08f;

 

float fSphX = -0.8f;

 

bool RightHit = false; 

 

void main(int argc,char **argv){ glutInit(&argc,argv);

 

glutInitDisplayMode(GLUT_DEPTH |GLUT_DOUBLE |     GLUT_RGBA);

 

glutInitWindowPosition(0,0);

 

glutInitWindowSize(800,800);

 

glutCreateWindow("First OpenGL Window");

 

glutDisplayFunc(Scene);

 

glutIdleFunc(Scene);

 

glutMainLoop();}void Scene(){  glClear(GL_COLOR_BUFFER_BIT);   

 

glPushMatrix();

 

 

 glTranslatef(1.0f,0.0f,0.0f);   

 

glScalef(0.3f,1.0f,0.1f);    

 

glutSolidCube(0.8);

 

glPopMatrix();

 
 

 

glPushMatrix();     

 

if ((fSphX >= 0.75f) && (fSphX <= 0.85))    RightHit=true;

 

if (RightHit)  fSphX -= 0.004f;

 

else  fSphX += 0.004f;

 

glTranslatef(fSphX,0,0);     

 

glutSolidSphere (fSphRadius, 100.0f, 100.0f);

 

glPopMatrix();    glutSwapBuffers();}
 

Xienoph

You can change this now in User CP.
Reaction score
43
Ah, you're using OpenGL. You already have a cube and sphere there. My guess is, you don't have lighting enabled, so all the faces have the same shade. Try enabling lighting and add some light sources.
 

Xienoph

You can change this now in User CP.
Reaction score
43
I don't remember how (or rather, don't want to remember the nightmarish graphics course I took). But here's a tutorial on how to do lighting.

Also check out other tutorials on that site. They're awesome.
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
Quick question:If i draw a square with GLUT_LINES or whatever instead of CUBE is it always 2D?
 

saw792

Is known to say things. That is all.
Reaction score
280
Well it's more like a square in 3D space. Which means that if you rotate around 90 degrees to the side of it it won't be visible. Instead of using glut functions to draw your shapes you're better off doing it with proper GL calls anyway, they are much more flexible for things like normals (how light bounces off the surface of an object), texture coordinates (for mapping images onto the sides of a 3D shape) and obviously allow you to make shapes not available in the GLUT library.

As Xienoph said, check out Nehe's OpenGL tutorials, they are an excellent starting point (although they don't use the latest features of OpenGL 2.0, 3.0, 4.0 etc). I've had to use OpenGL in Java for a university project and it was quite a learning curve.
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
I did and this error continues to bug me to no end.

"gl\glaux.h: No such file or directory."

Any advice besides telling me to code in something else?

Something completely random:Apparently you can draw a 3D Teapot with GLUT....
 

saw792

Is known to say things. That is all.
Reaction score
280
Well you have to import all the OpenGL required libraries and headers... which means that you must have a folder named gl with the libraries in it, assuming you are following the tutorial. You shouldn't need glaux anyway, it's outdated and you can do all the things you need without it.

Check wikipedia for the history of the teapot in computer graphics :p
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
So how do i import those? I tried Removing glaux from the code but now i get the ff errors.

Code:
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(24) : error C2143: syntax error : missing ';' before '*'
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(37) : error C3861: 'auxDIBImageLoad': identifier not found
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(45) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(47) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(50) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2227: left of '->sizeX' must point to class/struct/union/generic type
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2227: left of '->sizeY' must point to class/struct/union/generic type
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(60) : error C2227: left of '->data' must point to class/struct/union/generic type
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(65) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(67) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(67) : error C2227: left of '->data' must point to class/struct/union/generic type
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(69) : error C2065: 'TextureImage' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(69) : error C2227: left of '->data' must point to class/struct/union/generic type
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(72) : error C2065: 'TextureImage' : undeclared identifier

Here's the code.

Code:
#include	<windows.h>							// Header File For Windows
#include	<stdio.h>							// Header File For Standard Input/Output ( NEW )
#include	<gl\gl.h>							// Header File For The OpenGL32 Library
#include	<gl\glu.h>							// Header File For The GLu32 Library
//#include	<gl\glaux.h>							// Header File For The GLaux Library

HDC		hDC=NULL;							// Private GDI Device Context
HGLRC		hRC=NULL;							// Permanent Rendering Context
HWND		hWnd=NULL;							// Holds Our Window Handle
HINSTANCE	hInstance;							// Holds The Instance Of The Application

bool		keys[256];							// Array Used For The Keyboard Routine
bool		active=TRUE;							// Window Active Flag
bool		fullscreen=TRUE;						// Fullscreen Flag

GLfloat		xrot;								// X Rotation ( NEW )
GLfloat		yrot;								// Y Rotation ( NEW )
GLfloat		zrot;								// Z Rotation ( NEW )

GLuint		texture[1];							// Storage For One Texture ( NEW )

LRESULT	CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);				// Declaration For WndProc

AUX_RGBImageRec *LoadBMP(char *Filename)					// Loads A Bitmap Image
{
	FILE *File=NULL;							// File Handle
if (!Filename)								// Make Sure A Filename Was Given
	{
		return NULL;							// If Not Return NULL
	}

File=fopen(Filename,"r");						// Check To See If The File Exists

if (File)								// Does The File Exist?
	{
		fclose(File);							// Close The Handle
		return auxDIBImageLoad(Filename);				// Load The Bitmap And Return A Pointer
	}
	return NULL;								// If Load Failed Return NULL
}
int LoadGLTextures()								// Load Bitmaps And Convert To Textures
{
int Status=FALSE;							// Status Indicator

AUX_RGBImageRec *TextureImage[1];					// Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1);				// Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
	if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
	{
		Status=TRUE;							// Set The Status To TRUE

		glGenTextures(1, &texture[0]);					// Create The Texture

		// Typical Texture Generation Using Data From The Bitmap
		glBindTexture(GL_TEXTURE_2D, texture[0]);

// Generate The Texture
		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	// Linear Filtering
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	// Linear Filtering
	}
if (TextureImage[0])							// If Texture Exists
	{
		if (TextureImage[0]->data)					// If Texture Image Exists
		{
			free(TextureImage[0]->data);				// Free The Texture Image Memory
		}

		free(TextureImage[0]);						// Free The Image Structure
	}
	return Status;								// Return The Status
}

int InitGL(GLvoid)								// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())							// Jump To Texture Loading Routine ( NEW )
	{
		return FALSE;							// If Texture Didn't Load Return FALSE ( NEW )
	}

	glEnable(GL_TEXTURE_2D);						// Enable Texture Mapping ( NEW )
	glShadeModel(GL_SMOOTH);						// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);					// Black Background
	glClearDepth(1.0f);							// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);						// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);							// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Really Nice Perspective Calculations
	return TRUE;								// Initialization Went OK
}

int DrawGLScene(GLvoid)								// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			// Clear Screen And Depth Buffer
	glLoadIdentity();							// Reset The Current Matrix
	glTranslatef(0.0f,0.0f,-5.0f);						// Move Into The Screen 5 Units

	glRotatef(xrot,1.0f,0.0f,0.0f);						// Rotate On The X Axis
	glRotatef(yrot,0.0f,1.0f,0.0f);						// Rotate On The Y Axis
	glRotatef(zrot,0.0f,0.0f,1.0f);						// Rotate On The Z Axis

	glBindTexture(GL_TEXTURE_2D, texture[0]);				// Select Our Texture

	glBegin(GL_QUADS);
		// Front Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		// Back Face
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		// Top Face
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		// Bottom Face
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		// Right face
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		// Left Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
	glEnd();

	xrot+=0.3f;								// X Axis Rotation
	yrot+=0.2f;								// Y Axis Rotation
	zrot+=0.4f;								// Z Axis Rotation
	return true;								// Keep Going
}

any alternate suggestion on how to achieve the same effect without using glaux?

Ok so I copy pasted it all. But I only edit the code when it works so i have basis to fall back on when it goes wrong after i edited it. :p

Edit:I found an alternative to glaux Now i have the ff errors saying some variables are "undeclared" How do i fix this? I mean i know how to declare variables but the ff variables are new to me.

Code:
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(47) : error C2065: 'GL_Window' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(47) : error C2065: 'window' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(47) : error C2065: 'Keys' : undeclared identifier
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(48) : error C2448: 'Initialize' : function-style initializer appears to be a function definition
1>c:\users\toshiba\documents\stuff\c++ codes and stuff\bitmap tutorial code\lesson06\lesson6.cpp(185) : fatal error C1004: unexpected end-of-file found
1>Build log was saved at "file://c:\Users\toshiba\Documents\stuff\C++ Codes and stuff\Bitmap Tutorial Code\Lesson06\Debug\BuildLog.htm"

Here's the new code.

Code:
#include	<windows.h>							// Header File For Windows
#include	<stdio.h>							// Header File For Standard Input/Output ( NEW )
#include	<gl\gl.h>							// Header File For The OpenGL32 Library
#include	<gl\glu.h>							// Header File For The GLu32 Library


HDC		hDC=NULL;							// Private GDI Device Context
HGLRC		hRC=NULL;							// Permanent Rendering Context
HWND		hWnd=NULL;							// Holds Our Window Handle
HINSTANCE	hInstance;							// Holds The Instance Of The Application

bool		keys[256];							// Array Used For The Keyboard Routine
bool		active=TRUE;							// Window Active Flag
bool		fullscreen=TRUE;						// Fullscreen Flag

void Window();

bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid)					// Creates Texture From A Bitmap File
{
	HBITMAP hBMP;														// Handle Of The Bitmap
	BITMAP	BMP;														// Bitmap Structure

	glGenTextures(1, &texid);											// Create The Texture
	hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );

	if (!hBMP)															// Does The Bitmap Exist?
		return FALSE;													// If Not Return False

	GetObject(hBMP, sizeof(BMP), &BMP);									// Get The Object
																		// hBMP:        Handle To Graphics Object
																		// sizeof(BMP): Size Of Buffer For Object Information
																		// &BMP:        Buffer For Object Information

	glPixelStorei(GL_UNPACK_ALIGNMENT, 4);								// Pixel Storage Mode (Word Alignment / 4 Bytes)

	// Typical Texture Generation Using Data From The Bitmap
	glBindTexture(GL_TEXTURE_2D, texid);								// Bind To The Texture ID
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);	// Linear Min Filter
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);	// Linear Mag Filter
	glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);

	DeleteObject(hBMP);													// Delete The Object

	return TRUE;														// Loading Was Successful
}

BOOL Initialize ((GL_Window),window,(Keys),keys)							// Any GL Init Code & User Initialiazation Goes Here
{
	g_window	= window;
	g_keys		= keys;

	// Start Of User Initialization
	if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0]))					// Load The Bitmap
		return FALSE;													// Return False If Loading Failed
    

GLfloat		xrot;								// X Rotation ( NEW )
GLfloat		yrot;								// Y Rotation ( NEW )
GLfloat		zrot;								// Z Rotation ( NEW )

GLuint		texture[1];							// Storage For One Texture ( NEW )

LRESULT	CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);				// Declaration For WndProc

AUX_RGBImageRec *LoadBMP(char *Filename)					// Loads A Bitmap Image
{
	FILE *File=NULL;							// File Handle
if (!Filename)								// Make Sure A Filename Was Given
	{
		return NULL;							// If Not Return NULL
	}

File=fopen(Filename,"r");						// Check To See If The File Exists

if (File)								// Does The File Exist?
	{
		fclose(File);							// Close The Handle
		return auxDIBImageLoad(Filename);				// Load The Bitmap And Return A Pointer
	}
	return NULL;								// If Load Failed Return NULL
}
int LoadGLTextures()								// Load Bitmaps And Convert To Textures
{
int Status=FALSE;							// Status Indicator

AUX_RGBImageRec *TextureImage[1];					// Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1);				// Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
	if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
	{
		Status=TRUE;							// Set The Status To TRUE

		glGenTextures(1, &texture[0]);					// Create The Texture

		// Typical Texture Generation Using Data From The Bitmap
		glBindTexture(GL_TEXTURE_2D, texture[0]);

// Generate The Texture
		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	// Linear Filtering
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	// Linear Filtering
	}
if (TextureImage[0])							// If Texture Exists
	{
		if (TextureImage[0]->data)					// If Texture Image Exists
		{
			free(TextureImage[0]->data);				// Free The Texture Image Memory
		}

		free(TextureImage[0]);						// Free The Image Structure
	}
	return Status;								// Return The Status
}

int InitGL(GLvoid)								// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())							// Jump To Texture Loading Routine ( NEW )
	{
		return FALSE;							// If Texture Didn't Load Return FALSE ( NEW )
	}

	glEnable(GL_TEXTURE_2D);						// Enable Texture Mapping ( NEW )
	glShadeModel(GL_SMOOTH);						// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);					// Black Background
	glClearDepth(1.0f);							// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);						// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);							// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Really Nice Perspective Calculations
	return TRUE;								// Initialization Went OK
}

int DrawGLScene(GLvoid)								// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			// Clear Screen And Depth Buffer
	glLoadIdentity();							// Reset The Current Matrix
	glTranslatef(0.0f,0.0f,-5.0f);						// Move Into The Screen 5 Units

	glRotatef(xrot,1.0f,0.0f,0.0f);						// Rotate On The X Axis
	glRotatef(yrot,0.0f,1.0f,0.0f);						// Rotate On The Y Axis
	glRotatef(zrot,0.0f,0.0f,1.0f);						// Rotate On The Z Axis

	glBindTexture(GL_TEXTURE_2D, texture[0]);				// Select Our Texture

	glBegin(GL_QUADS);
		// Front Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		// Back Face
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		// Top Face
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		// Bottom Face
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		// Right face
		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Top Left Of The Texture and Quad
		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad
		// Left Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Bottom Left Of The Texture and Quad
		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Top Right Of The Texture and Quad
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);	// Top Left Of The Texture and Quad
	glEnd();

	xrot+=0.3f;								// X Axis Rotation
	yrot+=0.2f;								// Y Axis Rotation
	zrot+=0.4f;								// Z Axis Rotation
	return true;								// Keep Going
}
 

D4RK_G4ND4LF

New Member
Reaction score
1
the NeHe tutorials are rather old and so is glaux.h and Dev-Cpp (CodeBlocks is pretty good but I prefer devcpp since I got a portable version of it)
I found glaux.h somewhere on my pc but I don't know if it works (maybe it requires a library or something)

I'd recommend to continue with learning opengl on another site than nehe or to download one of the other sample codes at the bottom of the page (sometimes one of them has working code)

ghostwolf from hiveworkshop made a collection of useful c++ links
you should have a look at it
http://www.hiveworkshop.com/forums/pastebin.php?id=f4hm61

edit:
http://www.gamedev.net/community/forums/topic.asp?topic_id=510241
http://www.gamedev.net/community/forums/topic.asp?topic_id=275238
attached working lesson 6 code
 

Attachments

  • glaux.h and links.zip
    12.8 KB · Views: 268
  • lesson06fixed.zip
    53.1 KB · Views: 261
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top