📄 opengl_functions.c
字号:
#include <GL/glut.h> // Header File For The GLUT Library #include <GL/gl.h> // Header File For The OpenGL32 Library#include <GL/glu.h> // Header File For The GLu32 Library#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include "../include/port.h"#include "../include/ogr_defines.h"#include "../include/ogr_structs.h"#include "defines.h"#include "globals.h"#include "opengl_functions.h"//------------------------------------------------------------------------------// DrawText12() // // Draws text on an OpenGL window//voidDrawText12(GLint x, GLint y, char* s, GLfloat r, GLfloat g, GLfloat b){ int lines; char* p; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0.0, glutGet(GLUT_WINDOW_WIDTH), 0.0, glutGet(GLUT_WINDOW_HEIGHT), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glColor3f(r,g,b); glRasterPos2i(x, y); for(p = s, lines = 0; *p; p++) { if (*p == '\n') { lines++; glRasterPos2i(x, y-(lines*12)); } glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *p); } glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW);}//------------------------------------------------------------------------------// DrawText10() // // Draws text on an OpenGL window//voidDrawTextScale(GLfloat x, GLfloat y, char* s, GLfloat r, GLfloat g, GLfloat b){ int lines; char* p; glColor3f(r,g,b); glRasterPos2f(x, y); for(p = s, lines = 0; *p; p++) { if (*p == '\n') { lines++; glRasterPos2i(x, y-(lines*0.2f)); } glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *p); }}//------------------------------------------------------------------------------// readCharList//// Given a list (buf) of comma separated integers, this// function will extract the individual list items// and return a list (listItems) of (numItems).//// RETURNS: 0 if no items in list, otherwise 1 if items found//int readCharList(char *buf, char *listItems[], int *numItems) { char *pch; /* Character pointer */ int count=0; pch=strtok(buf,",\n "); while(pch!=NULL) { strcpy(listItems[count],pch); count++; pch=strtok(NULL,",\n "); } *numItems=count; if (count==0) return 0; else return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -