我试图简单地在屏幕上写任何东西。绘制矩形很容易。我正在尝试将文本字符串横向叠加在“书”上。这似乎很简单,但...
正如一个注释,我试图从这些论坛中获取建议,因此glDisable(GL_DEPTH_TEST);
可能glDisable(GL_LIGHTING);
没有必要。另外,有没有办法自己启用调试?我通常喜欢添加cout << "i reached this far yay" << endl;
,但当我将它放入时它似乎不喜欢我void Bookshelf()
......它给了我一个 C2381 错误('function' : redefinition; __declspec(noreturn) differs
)
主文件
#include "bookshelf.h"
void Initialize()
{
glClearColor (1.0, 1.0, 1.0, 0.0 );
glMatrixMode( GL_PROJECTION );
glOrtho(0,899,899,0,1,0);
}
void main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize( 900, 900 );
glutInitWindowPosition( 510, 100 );
glutCreateWindow("Bookshelf - Ankit Ahuja");
Initialize();
glutDisplayFunc(Bookshelf);
glutMainLoop();
}
书架.h
#include <GL/glut.h>
void Bookshelf()
{
glClear( GL_COLOR_BUFFER_BIT );
glColor3f( 0.0, 0.0, 0.0 );
glBegin( GL_QUADS );
//Code that draws a bookshelf
//Book1
glColor3f( 1.0, 0.25, 0.25 );
glVertex3i(240,70,0.5);
glVertex3i(260,70,0.5);
glVertex3i(260,180,0.5);
glVertex3i(240,180,0.5);
//BookTitle1
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glRotatef(90f,0.0f,0.0f,0.0f);
glColor3f( 0.0, 1.0, 0.0 );
glDisable(GL_LIGHTING);
glRasterPos3i(100,100,1);
char text[50]="Alphabet Soup is the best guys";
for(int i=0; i<50; i++)
{
glutBitmapCharacter(GLUT_BITMAP_9_BY_15,(int)text[i]);
}
glPopMatrix();
//Book2
glColor3f( 0.8, 0.8, 0.0 );
glVertex2i(270,70);
glVertex2i(290,70);
glVertex2i(290,180);
glVertex2i(270,180);
//More books and shelves
glEnd();
glFlush();
}