anybody help me.
I am still the new in opengl.
I want to use 2d fonts, number and text.
I have already read from the book “opengl superbible”
// testopengl.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "Wingdi.h"
#include "glut.h"
//////////////////////////////////////////////////////////////
// Window has changed size. Reset to match window coordinates
void ChangeSize(GLsizei w, GLsizei h)
{
GLfloat nRange = 100.0f;
GLfloat fAspect;
// Prevent a divide by zero
if(h == 0) h = 1;
fAspect = (GLfloat)w/(GLfloat)h;
// Set Viewport to window dimensions
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,400, 400, 0);
// Viewing transformation
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
///////////////////////////////////////////////////
// Set up. Use a Windows font to create the bitmaps
void SetupRC(HDC hDC)
{
// Set up the Font characteristics
HFONT hFont;
LOGFONT logfont;
logfont.lfHeight = -20;
logfont.lfWidth = 0;
logfont.lfEscapement = 0;
logfont.lfOrientation = 0;
logfont.lfWeight = FW_BOLD;
logfont.lfItalic = FALSE;
logfont.lfUnderline = FALSE;
logfont.lfStrikeOut = FALSE;
logfont.lfCharSet = ANSI_CHARSET;
logfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily = DEFAULT_PITCH;
strcpy(logfont.lfFaceName,"Arial");
// Create the font and display list
hFont = CreateFontIndirect(&logfont);
SelectObject (hDC, hFont);
// Create display lists for glyphs 0 through 128
nFontList = glGenLists(128);
wglUseFontBitmaps(hDC, 0, 128, nFontList);
DeleteObject(hFont); // Don’t need original font anymore
// Black Background
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
}
//////////////////////////////////////////////////
// Draw everything (just the text)
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
// Blue 3D Text - Note color is set before the raster position
glColor3f(1.0f, 1.0f, 1.0f);
glRasterPos2i(0, 200);
glListBase(nFontList);
glCallLists (13, GL_UNSIGNED_BYTE, "OpenGL Rocks!");
}
//void main(void)
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutCreateWindow("Simple");
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
SetupRC();
glutMainLoop();
return 0;
}
but when i complie there still error? there is 275 error from wingdi.h
Error 1 error C2146: syntax error : missing ';' before identifier 'ptPosition' c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h 268
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h 268
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h 268
Error 4 error C2146: syntax error : missing ';' before identifier 'ptSize' c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h 269
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h 269
How i fix the error?
there another way to make number and text?
the image example what i want to make it:
photobucket
thank u …