OpenGL Programming

Ok, so I've been getting tired of programming in the console, since I can't seem to find anything worth programming in the console. So I decided I'd try to move onto some sort of graphics library. I chose OpenGL. This is probably the 3rd or so time I've attempted to start some sort of graphics programming and it always just ends in a failure. I look for a good tutorial, and I can't ever find one that's up to date. But I choose the best looking one. This time I went with NeHe. From the get go, I had problems because he uses Glaux in his tutorials but I just went with it anyways. Well now I have finished part one of setting up a window in OpenGl. I followed everything perfectly, and now I'm getting errors that I see no fix too. I'm beyond frustrated at the difficulty of trying to get into graphics programming in C++. I'm not sure how to get into it anymore. I even bought myself a 60 dollar book awhile ago and that was no good. Anyone have any advice for me before I throw my computer through a window? Or point me at the OpenGL documentation and I'll figure this all out myself. Gah! I just had to vent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*This is my first OpenGl project. Let's hope it goes well.
I'm following NeHe's tutorial at http://nehe.gamedev.net/
Started on 12/23/2011
*/

#include <windows.h>                                        // Header File For Windows
#include <gl\gl.h>                                          // Header File For The OpenGL32 Library
#include <gl\glu.h>                                         // Header File For The GLu32 Library

//Sets up variables used in this application
HGLRC           hRC=NULL;                                   // Permanent Rendering Context
HDC             hDC=NULL;                                   // Private GDI Device 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 Set To TRUE By Default
BOOL fullscreen=TRUE;                                       // Fullscreen Flag Set To Fullscreen Mode By Default

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

GLvoid ReSizeGLScene(GLsizei width, GLSizei height)         //Resize and initialize the GL Window
{
    if(height == 0)     //Prevents a divide by zero by
    {
        height = 1;     //making height equal to 1
    }

    glViewport(0,0,width,height);           //resets the current viewport
    glMatrixMode(GL_PROJECTION);            //select the project matrix
    glLoadIdentity();                       //Reset the project matrix

    //Calculate the aspect ration of the window
    gluPerspective(45.0f, (GLfloat)width/(GLfloat)height,0.1f,100.0f);

    glMatrixMode(GL_MODELVIEW);             //Select the modelview matrix
    glLoadIdentity();                       //Reset the modelview matrix
}

int InitGL(GLvoid)                          //All setup for OpenGL goes here
{
    glShadeMode1(GL_SMOOTH);                //Enables smooth shading
    glClearColor(0.0f,0.0f,0.0f,0.0f);      //Sets black background. Param (R,G,B,Alpha value)

    glClearDepth(1.0f);                   //Depth buffer setup
    glEnable(GL_DEPTH_TEST);                //Enables depth testing
    glDepthFunc(GL_EQUAL);                  //The type of depth test to do

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      //Really nice perspective calculations

    return TRUE;            //Initialization went OK
}

int DrawGLScene(GLvoid)                 //Here's where all the drawing goes
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     //Clears screen and depth buffer
    glLoadIdentity();                   //Reset current modelview matrix
    return TRUE;
}


Here's the behemoth of a code just to make a window, and im not even done. I'm using GCC compiler through C::B. I really want to get this to work, but I'm gonna have an aneurysm if I try to figure this out anymore
The general concept of programming a game or other visual software - you create a game shell/game engine, then you use it to create and actual game. Well, if you smart enough, then sure, go with 3D straight away, but other then that, go with 2D and start, so you could get the concept of game architecture. I mean, your communication with 2D opengl will be easier rathen than 3D.
Well, anyway, what I am talking...i never working with openGL. Only directdraw.
try GLUT. It is way easier. If you are not a professional programmer. it provides us predefined funtion.
Topic archived. No new replies allowed.