OpenGL Installation

Started by
15 comments, last by inungh 20 years, 10 months ago
Hi All: I am new in the OpenGL. I just follow the tutorial to write my first OpenGL program. I got compile error. I do not know where I missed. I appreciate any information. I added opengl32.lib, glu32.lib and Glaux.lib to my lnik. There are 4 line son top of my source code like following #include <windows.h> #include <gl\gl.h> #include <gl\glu.h> #incldue After I add code like the tutorial, I got compile error. Did I miss anything are there any place to check my OpenGL is correctly installed. Thanks in advance Inung Huang
Advertisement
what error message did you get?
I am a signature virus. Please add me to your signature so that I may multiply.
Hi Inung,

Did you type all the code correctly? If you did then its to do with that 4th include - at a guess (but don''t quote me on it )it should probably be #include <gl/glaux.h>.

I have never actually ever had to set OpenGL up on a Windows box, and some of the compilers have the header files included with them anyway.

If you ever need help on forums/mailing lists, and have a compiler error it can be helpful to give us the error itself so that we can diagnose your problem quickly

Phil.
Thanks for reply.

I use VC++ and get a lot of message from compile.
The first one is
c:\Documents and Settings\Inung Huang\My Documents\My ICCSI\OpenGL\POpenGL1\OpenGL2\OpenGL2\OpenGL2.cpp(152): error C2146: syntax error : missing '';'' before identifier ''ReSizeGLScene''


The second one is
c:\Documents and Settings\Inung Huang\My Documents\My ICCSI\OpenGL\POpenGL1\OpenGL2\OpenGL2\OpenGL2.cpp(152): error C2501: ''GLvoid'' : missing storage-class or type specifiers


I checked the incldue files exist in the \include\gl folder and GLvoid is declared in gthe header file.

I also checked the dll and lib files. They exsit.

I do not have clue what I should check.

According to the tutorial, it should work. Thanks for helping.

Inung

You forgot a semicolon ( ; ) in your program.
EDIT: Smileys...

[edited by - cowsarenotevil on June 5, 2003 1:06:41 AM]
-~-The Cow of Darkness-~-
That is probably not a header problem but a typo when you copied the program over. For future reference, it''s best to include the error message and the applicable source code if you can''t find a bug. Also, always spend a lot of time looking for a bug before posting. I know you''re a newbie so it''s no big deal, but some people aren''t very patient.
I spend a few days on it.
Thanks for helping.
Here is the source code for my OpenGL2.cpp

Actually, there is none my code.
The code afre generate by VC++ and copy from the tutorial.

I do not know should I take out the code generated by VC++ compile.

I have the header and the last function from tutorial.
The rest are VC++ code. If I take out the last function then the VC++ compile. I really appreciate your help.


// OpenGL2.cpp : Defines the class behaviors for the application.
//

#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
#include "gl\GLAux.h" // Header File For The GLaux Library

#include "stdafx.h"
#include "OpenGL2.h"
#include "MainFrm.h"

#include "ChildFrm.h"
#include "OpenGL2Doc.h"
#include "OpenGL2View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

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



// COpenGL2App

BEGIN_MESSAGE_MAP(COpenGL2App, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()


// COpenGL2App construction

COpenGL2App::COpenGL2App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}


// The one and only COpenGL2App object

COpenGL2App theApp;

// COpenGL2App initialization

BOOL COpenGL2App::InitInstance()
{
// InitCommonControls() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
InitCommonControls();

CWinApp::InitInstance();

// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application''s document templates. Document templates
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_OpenGL2TYPE,
RUNTIME_CLASS(COpenGL2Doc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(COpenGL2View));
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there''s a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}



// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
enum { IDD = IDD_ABOUTBOX };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation
protected:
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// App command to run the dialog
void COpenGL2App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}

GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}

glViewport(0, 0, width, height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix

// Calculate The Aspect Ratio 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
}


// COpenGL2App message handlers

Usually, and i don''t know how your system is setup, the openGL header files are in the include directory of your compiler. Then, you would write

#include <GL/gl.h>

instead of

#include "gl/GL.h"

Also, the gl.h file is usually lowercase and the directory uppercase, or at least that''s how it is on my computer.
Thanks for response.

My machine is gl\GL.h, but I tried both way.
I noticed VC++ is case sensitive.

It looks that VC++ does not reconize my GL code.
I check the inclde directory exist in the configuration.

Any thing else I am missing?

Thanks again.

Inung Huang
May I copy those gl.h file to my include directory instead of gl directory?

Will it help?

Any suggestions are appreciated.

Inung Huang

This topic is closed to new replies.

Advertisement