Sign in to follow this  
ajm113

I want to do more then a simple wireframe cube now.

Recommended Posts

Well I made my first 3d app here www.bf2editor.org/ajm113/index.html#render using glut on Dev C++. I want to do more now with it. Like how to give it a texture on the cube. How to do a full screen command with alt+enter and etc. Where can I learn more of glut on Dev C++ for game rendering use? The tutorials I find on google aren't that good or the codes don't work.

Share this post


Link to post
Share on other sites
if you just want to draw boxes GLUT will be ok, anyway if you have set up a window with glut most of the tutrials should work, by just adopt the interesting stuff

Share this post


Link to post
Share on other sites
Well I tried the first tutorial on making the models but I can't get my model to show!

#ifdef _WIN32 #define WIN32_EXTRALEAN // Only include the basics
#include <windows.h> // exit, virtual key codes
#endif
#include <GL\GL.h>
#include <GL\Glut.h>
#include <gl\glu.h>

void Keyboard( unsigned char uKey, int x, int y )
{
switch ( uKey )
{
// If the escape key was pressed, we need to exit
// the program:
case VK_ESCAPE:
exit( 0 );
break;
}

}

int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View

glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();

glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad
return TRUE; // Keep Going
}


void Resize( int iWidth, int iHeight )
{
// Set the dimensions of the viewport:
glViewport( 0, 0, (GLsizei)iWidth, (GLsizei)iHeight );

// Switch to the projection matrix:
glMatrixMode( GL_PROJECTION );
glLoadIdentity();


// Define the projection transformation matrix. Notice that this is using
// glFrustum instead of gluPerspective:
glFrustum( -1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 20.0f );

// Switch back to the modelview matrix:
glMatrixMode( GL_MODELVIEW );
}

void Redraw()
{
// Clear the screen and depth buffer:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

// Swap buffers:
glutSwapBuffers();
}

void Timer( int iValue )
{
// Tell glut to redisplay the scene:
glutPostRedisplay();

// Need to call this method again after the desired amount of time has passed:
glutTimerFunc( 1, Timer, iValue );

}


int main( int argc, char **argv )
{
// Initialize the display mode:
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );

// Set the window size and position:
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 556, 556 );

// Perform command-line initialization:
glutInit( &argc, argv );

// Create the window:
glutCreateWindow( "My First Render!" );

// Set the GLUT callbacks:
glutKeyboardFunc( Keyboard );
glutReshapeFunc( Resize );
glutDisplayFunc( Redraw );

// Setup the timer:
glutTimerFunc( 1, Timer, 1 );

// Enter the program loop:
glutMainLoop();

return 0;
}

Share this post


Link to post
Share on other sites
Hmm, it's very easy to do windowing/userIO things via SDL. I learned the basic functions of SDL within one hour. In addition, you can compile SDL-programs for Windows and Linux without changing them, because you wont use system specific headers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this