Visual Studio Express 2017输出未显示中风文本功能
我一直在尝试在Visual Studio Express 2017中运行此程序。使用OpenGL。 我在PDF中找到了渲染代码和中风代码,并正在尝试,但首先显示出许多错误,一旦照顾我,我都编制了该程序。尽管运行没有任何错误,但输出屏幕仍然空白。
#include "stdafx.h"
#include <windows.h>
#include <gl/GL.h>
#include <glut.h>
#include <gl/GLU.h>
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLineWidth(6.0);
glLoadIdentity();
gluOrtho2D(0.0, 700, 0.0, 700);
}
void drawStrokeText(const char *string, int x, int y, int z)
{
const char *c;
glPushMatrix();
glTranslatef(x, y + 8, z);
glScalef(0.09f, -0.08f, z);
for (c = string; *c != '\0'; c++)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN, *c);
}
glPopMatrix();
}
void render()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3ub(255, 50, 255);
drawStrokeText("Hello", 300, 400, 0);
glutSwapBuffers();
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
render();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(700, 700);
glutInitWindowPosition(100, 150);
glutCreateWindow("My First Program");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
}
I've been trying to run this program in visual studio express 2017. Using opengl.
I found the rendering code and stroke code in a pdf and was trying it out but first it showed many errors, once taken care of I compiled the program. Although the run was without any errors the output screen remains blank.
#include "stdafx.h"
#include <windows.h>
#include <gl/GL.h>
#include <glut.h>
#include <gl/GLU.h>
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLineWidth(6.0);
glLoadIdentity();
gluOrtho2D(0.0, 700, 0.0, 700);
}
void drawStrokeText(const char *string, int x, int y, int z)
{
const char *c;
glPushMatrix();
glTranslatef(x, y + 8, z);
glScalef(0.09f, -0.08f, z);
for (c = string; *c != '\0'; c++)
{
glutStrokeCharacter(GLUT_STROKE_ROMAN, *c);
}
glPopMatrix();
}
void render()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glColor3ub(255, 50, 255);
drawStrokeText("Hello", 300, 400, 0);
glutSwapBuffers();
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
render();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(700, 700);
glutInitWindowPosition(100, 150);
glutCreateWindow("My First Program");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
矩阵模式在
myinit
中切换到gl_proctive
,但从未切换。因此,glloadIdentity()
中的指令
将覆盖投影矩阵。您必须将矩阵模式切换到gl_modelview
glloadIdentity()
:Matrix mode is switched to
GL_PROJECTION
inmyInit
but never switched back. Therefore theglLoadIdentity()
instruction inrender
will override the projection matrix. You have to switch the matrix mode toGL_MODELVIEW
beforeglLoadIdentity()
: