473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Erros of Porting to OpenGL 1.2 for Managed C++ in VC++.NET (2002)

Hi all,
I tried to use Managed C++ coding of VC++.NET (2002)and
OpenGL version 1.2 to draw a hexagon shape of benzene.
My OpenGLdrawBenzene.cpp is the following:
// This is the main project file for VC++ application
project
// generated using an Application Wizard.

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h> // OpenGL Graphics Utility
Library
#using <mscorlib.dll>
#include <tchar.h>

using namespace System;

// These variables set the dimensions of the
rectanglar region we wish to view.
const double Xmin = 0.0, Xmax = 3.0;
const double Ymin = 0.0, Ymax = 3.0;

// Clear the rendering window
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);

// Set drawing color to white
glColor3f( 1.0, 1.0, 1.0 );
// Draw six points on xy plane with z=0.0
glBegin(GL_POINTS);
glVertex3f( 0.0, 0.0, 0.0 );
glVertex3f( 0.9, 1.0, 0.0 );
glVertex3f( 1.9, 1.0, 0.0 );
glVertex3f( 2.8, 0.0, 0.0 );
glVertex3f( 1.9,-1.0, 0.0 );
glVertex3f( 0.9,-1.0, 0.0 );
glEnd();
// Flush the pipeline. (Not usually necessary.)
glFlush();
}
// Initialize OpenGL's rendering modes
void initRendering()
{
// Called when the window is resized
// w, h - width and height of the window in
pixels.
void resizeWindow(int w, int h)
{
double scale, center;
double windowXmin, windowXmax, windowYmin,
windowYmax;

// Define the portion of the window used for OpenGL
rendering.
glViewport( 0, 0, w, h ); // View port uses
whole
window

// Set up the projection view matrix: orthographic
projection
// Determine the min and max values for x and y
that
should appear in the window.
// The complication is that the aspect ratio of the
window may not match the
// aspect ratio of the scene we want
to view.
w = (w==0) ? 1 : w;
h = (h==0) ? 1 : h;
if ( (Xmax-Xmin)/w < (Ymax-Ymin)/h ) {
scale = ((Ymax-Ymin)/h)/((Xmax-Xmin)/w);
center = (Xmax+Xmin)/2;
windowXmin = center - (center-Xmin)*scale;
windowXmax = center + (Xmax-center)*scale;
windowYmin = Ymin;
windowYmax = Ymax;
}
else {
scale = ((Xmax-Xmin)/w)/((Ymax-Ymin)/h);
center = (Ymax+Ymin)/2;
windowYmin = center - (center-Ymin)*scale;
windowYmax = center + (Ymax-center)*scale;
windowXmin = Xmin;
windowXmax = Xmax;
}

// Now that we know the max & min values for x & y
that should be visible in the window,
// we set up the orthographic
projection.
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( windowXmin, windowXmax, windowYmin,
windowYmax, -1, 1 );

}
// This is the entry point for this application
int _tmain(int argc, char** argv)
{
// TODO: Please replace the sample code below with
your own.
Console::WriteLine(S"OpenGLdrawBenzene");

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

glutInit(&argc,argv);

// The image is not animated so single buffering is
OK.
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB |
GLUT_DEPTH );

// Window position (from top corner), and size
(width
and hieght)
glutInitWindowPosition( 20, 60 );
glutInitWindowSize( 360, 360 );
glutCreateWindow( "SimpleDraw - Press space bar to
toggle images" );

// Initialize OpenGL as we like it..
initRendering();

// Set up callback functions for key presses
glutKeyboardFunc( myKeyboardFunc );
// Handles
"normal" ascii symbols
// glutSpecialFunc( mySpecialKeyFunc ); //
Handles
"special" keyboard keys

// Set up the callback function for resizing
windows
glutReshapeFunc( resizeWindow );

// Call this for background processing
// glutIdleFunc( myIdleFunction );

// call this whenever window needs redrawing
glutDisplayFunc( drawScene );

fprintf(stdout, "Press space bar to toggle images;
escape button to quit.\n");

// Start the main loop. glutMainLoop never
returns.
glutMainLoop( );
return 0;
}
///////////////////////////////////////
When I built it, I got many errors:
------ Build started: Project: OpenGLdrawBenzene,
Configuration: Debug Win32 ------

Compiling...
OpenGLdrawBenzene.cpp
OpenGLdrawBenzene.cpp(18) : error C2501: 'glClear' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(18) : error C2365: 'glClear' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1162) : see
declaration of 'glClear'
OpenGLdrawBenzene.cpp(21) : error C2501: 'glColor3f' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(21) : error C2365: 'glColor3f' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1173) : see
declaration of 'glColor3f'
OpenGLdrawBenzene.cpp(21) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(23) : error C2501: 'glBegin' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(23) : error C2365: 'glBegin' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1156) : see
declaration of 'glBegin'
OpenGLdrawBenzene.cpp(24) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(24) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(24) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(25) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(25) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(25) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(26) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(26) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(26) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(27) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(27) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(27) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(28) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(28) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(28) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(29) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(29) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(29) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(30) : error C2556: 'int
glEnd(void)' : overloaded function differs only by
return type from 'void glEnd(void)'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1226) : see
declaration of 'glEnd'
OpenGLdrawBenzene.cpp(30) : error C2373: 'glEnd' :
redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1226) : see
declaration of 'glEnd'
OpenGLdrawBenzene.cpp(32) : error C2556: 'int
glFlush(void)' : overloaded function differs only by
return type from 'void glFlush(void)'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1242) : see
declaration of 'glFlush'
OpenGLdrawBenzene.cpp(32) : error C2373: 'glFlush' :
redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1242) : see
declaration of 'glFlush'
OpenGLdrawBenzene.cpp(33) : error C2059: syntax error
: '}'
OpenGLdrawBenzene.cpp(33) : error C2143: syntax error
: missing ';' before '}'
OpenGLdrawBenzene.cpp(33) : error C2059: syntax error
: '}'
OpenGLdrawBenzene.cpp(36) : error C2143: syntax error
: missing ';' before '{'
OpenGLdrawBenzene.cpp(36) : error C2447: '{' : missing
function header (old-style formal list?)
OpenGLdrawBenzene.cpp(119) : fatal error C1004:
unexpected end of file found

Build log was saved at "file://c:\Documents and
Settings\default\My
Documents\Programming\OpenGLdrawBenzene\Debug\Buil dLog.htm"
OpenGLdrawBenzene - 35 error(s), 0 warning(s)

---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped
///////////////////////////////////////////////
Please kindly tell me what caused the first error in
Line 18 of this .cpp

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

and how to cure it. If you can help me more in
solving the rest of the errors, I will be greatly
appreciated.

Thanks in advance,
Scott Chang
Nov 16 '05 #1
0 3616

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Sgier | last post by:
Hello i'm trying to port a windows program to linux with Kdevelop 1.question: unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader); ...
1
by: Robin Charisse | last post by:
Hi, I have a VC++6 project that uses msxml to parse XML documents. I have been asked to port this to a .NET project but from the research I've done so far it looks as though the only way to do...
10
by: Bad_Kid | last post by:
which is better for what?
0
by: Scott Chang | last post by:
Hi all, Is any article or document for porting to OpenGL for Microsoft Visual C++.NET (2002)? Please advise. Thanks in advance, Scott Chang
1
by: Scott Chang | last post by:
Hi All I tried to use the attached OpenGL code to draw a Star-shaped figure on my Microsoft Visual C++ .NET 2002-Windows XP Pro PC. When I did 'Build' in Debug Mode, I got an error C2065:...
3
by: John Vannoy | last post by:
I have created a small OpenGL app in VC.NET and so far so good. But when I try to create a GLUquadric object with gluNewQuadric, I get a runtime error: An unhandled exception of type...
11
by: Peter Oliphant | last post by:
Is there any plan to support templates with managed code in the (near) future? For instance, VS.NET 2005... : )
14
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
6
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= | last post by:
Hi all, I am porting an code written in VC++ to VC.Net to make it manage. But in Managed VC we dont use "const" keyboard at all. but my code is using it very frequently, so is their any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.