
Converting a C++ project to OpenTK, can't find certain calls
Posted Wednesday, 14 September, 2011 - 18:48 by Fidchells_eye inHi, I am new here
I am converting a C++ project to a C# Class Library that is using OpenTK 1.0
I am using VS2010 and have all the frameworks load into the system.
I am converting the code, but have trouble finding the OpenTK equivalant for some parts which are marked with arrows:
bool Base_OpenGL::SetupProjection(int width, int height)
{
if (height == 0) // don't want a divide by zero
{
height = 1;
}
m_Zdelta = (height/2)/(tan(FovY/2));
// \/ zoom factor
//m_Zdelta = m_Zdelta * 2.45;
glViewport(0, 0, width, height); // reset the viewport to new dimensions
glMatrixMode(GL_PROJECTION); // set projection matrix current matrix
glLoadIdentity(); // reset projection matrix
// calculate aspect ratio of window
gluPerspective(FovY,(GLfloat)width/(GLfloat)height,200.0f, 2000.0f); <-------------What is the OpenTK equivalant here.
glMatrixMode(GL_MODELVIEW); // set modelview matrix
glLoadIdentity(); // reset modelview matrix
//load window dimensions into class memory
m_windowWidth = (float)width;
m_windowHeight = (float)height;
return true;
}
unsigned int Base_OpenGL::CreateBitmapFont(wchar_t *fontName, int fontSize) <--------I'll need help on this whole function
{
HFONT hFont; // the windows font
unsigned int base;
//char *cfontname;
base = glGenLists(96);
//WideCharToMultiByte(CP_UTF8, WC_DEFAULTCHAR, fontName, -1, *cfontname, sizeof(*cfontname), NULL, NULL);
//wcstombs();
if (!_wcsicmp (fontName , L"symbol"))
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH,
fontName);
}
else
{
hFont = CreateFont(fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH,
fontName);
}
if (!hFont)
return 0;
SelectObject(hDC, hFont);
wglUseFontBitmaps(hDC, 32, 96, base);
return base;
}
I got DeleteFont made and converted, but not sure if I got Render font right.
protected void RenderFont(int xPos, int yPos, uint basef, string str) //create font for openGL
{
if ((basef == 0) /*|| (!str)*/)
return;
GL.RasterPos2(xPos, yPos);
GL.PushAttrib(AttribMask.ListBit);
GL.ListBase(basef - 32);
GL.CallLists( (int)(str.Length * 2), ListNameType.UnsignedByte,IntPtr.Zero);
GL.PopAttrib();
}
Signed Fidchells_eye


Comments
Re: Converting a C++ project to OpenTK, can't find certain ...
gluPerspective(FovY,(GLfloat)width/(GLfloat)height,200.0f, 2000.0f); <-------------What is the OpenTK equivalant here.is
Matrix4.CreatePerspectiveFieldOfViewNo idea about the bitmap font, though. I made my own out of mapped PNGs.
Re: Converting a C++ project to OpenTK, can't find certain ...
instead of having your project reference OpenTK, have it reference to OpenTK.Compatibility. gluPerspective only works with the older fixed-function pipeline. I believe there's also some text rendering capabilities in there as well.
Re: Converting a C++ project to OpenTK, can't find certain ...
Thanks
noting Matrix4.CreatePerspectiveFieldOfView and the OpenTK.Compatibility. gluPerspective.
The OpenTK.Compatibility project also has OpenTK.Font, So I'll be looking in there for some functions for the CreateBitmapFont function.