資源簡介
詳細信息你們都知道了,我這里也不多廢話了,對你們有用的就拿走

代碼片段和文件信息
/*
????glfont:??An?example?of?using?the?SDL_ttf?library?with?OpenGL.
????Copyright?(C)?1997-2009?Sam?Lantinga
????This?library?is?free?software;?you?can?redistribute?it?and/or
????modify?it?under?the?terms?of?the?GNU?Library?General?Public
????License?as?published?by?the?Free?Software?Foundation;?either
????version?2?of?the?License?or?(at?your?option)?any?later?version.
????This?library?is?distributed?in?the?hope?that?it?will?be?useful
????but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
????MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
????Library?General?Public?License?for?more?details.
????You?should?have?received?a?copy?of?the?GNU?Library?General?Public
????License?along?with?this?library;?if?not?write?to?the?Free
????Foundation?Inc.?59?Temple?Place?Suite?330?Boston?MA??02111-1307??USA
????The?SDL_GL_*?functions?in?this?file?are?available?in?the?public?domain.
????Sam?Lantinga
????slouken@libsdl.org
*/
/*?$Id:?glfont.c?4463?2009-03-22?06:54:13Z?slouken?$?*/
/*?A?simple?program?to?test?the?text?rendering?feature?of?the?TTF?library?*/
#include?
#include?
#include?
#include?“SDL.h“
#include?“SDL_ttf.h“
#ifdef?HAVE_OPENGL
#include?“SDL_opengl.h“
#define?DEFAULT_PTSIZE 18
#define?DEFAULT_TEXT “The?quick?brown?fox?jumped?over?the?lazy?dog“
#define?NUM_COLORS??????256
static?char?*Usage?=
“Usage:?%s?[-utf8|-unicode]?[-b]?[-i]?[-u]?[-fgcol?rgb]?[-bgcol?rgb]?\
.ttf?[ptsize]?[text]\n“;
void?SDL_GL_Enter2DMode()
{
SDL_Surface?*screen?=?SDL_GetVideoSurface();
/*?Note?there?may?be?other?things?you?need?to?change
???depending?on?how?you?have?your?OpenGL?state?set?up.
*/
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
/*?This?allows?alpha?blending?of?2D?textures?with?the?scene?*/
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA?GL_ONE_MINUS_SRC_ALPHA);
glViewport(0?0?screen->w?screen->h);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0?(GLdouble)screen->w?(GLdouble)screen->h?0.0?0.0?1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTexEnvf(GL_TEXTURE_ENV?GL_TEXTURE_ENV_MODE?GL_MODULATE);
}
void?SDL_GL_Leave2DMode()
{
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopAttrib();
}
/*?Quick?utility?function?for?texture?creation?*/
static?int?power_of_two(int?input)
{
int?value?=?1;
while?(?value? value?<<=?1;
}
return?value;
}
GLuint?SDL_GL_LoadTexture(SDL_Surface?*surface?GLfloat?*texcoord)
{
GLuint?texture;
int?w?h;
SDL_Surface?*image;
SDL_Rect?area;
Uint32?saved_flags;
Uint8??saved_alpha;
/*?Use?the?surface?width?and?height?expanded?to?powers?of?2?*/
w?=?power_of_two(surface->w);
h?=?power_of_two(surface->h);
texcoord[0]?=?0.0f; /*?Min?X?*/
texcoord[1]?=?0.0f; /*?Min?Y?*/
texcoord[2]?=?(GLfloat)surface->w?/?w; /*?Max?X?*/
texcoord[3]?=?(GL
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4393??2013-11-07?18:10??SDL_ttf-2.0.10\.deps\glfont.Po
?????文件???????7160??2013-11-07?18:10??SDL_ttf-2.0.10\.deps\SDL_ttf.Plo
?????文件???????4191??2013-11-07?18:10??SDL_ttf-2.0.10\.deps\showfont.Po
?????文件??????30932??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\glfont
?????文件??????62176??2013-12-10?13:02??SDL_ttf-2.0.10\.libs\libSDL_ttf-2.0.so.0
?????文件??????62176??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\libSDL_ttf-2.0.so.0.10.0
?????文件??????66786??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\libSDL_ttf.a
?????文件???????1032??2013-12-10?13:02??SDL_ttf-2.0.10\.libs\libSDL_ttf.la
?????文件???????1033??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\libSDL_ttf.lai
?????文件??????62176??2013-12-10?13:02??SDL_ttf-2.0.10\.libs\libSDL_ttf.so
?????文件??????67492??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\SDL_ttf.o
?????文件??????28386??2013-11-07?18:10??SDL_ttf-2.0.10\.libs\showfont
?????文件?????260205??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\libtool.m4
?????文件??????12018??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\ltoptions.m4
?????文件???????4452??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\ltsugar.m4
?????文件????????781??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\ltversion.m4
?????文件???????5786??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\lt~obsolete.m4
?????文件???????5221??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\pkg.m4
?????文件???????6996??2009-10-13?07:06??SDL_ttf-2.0.10\acinclude\sdl.m4
?????文件??????34850??2009-10-19?16:18??SDL_ttf-2.0.10\aclocal.m4
?????文件????????167??2009-10-13?07:06??SDL_ttf-2.0.10\autogen.sh
?????文件???????5748??2009-10-19?16:18??SDL_ttf-2.0.10\CHANGES
?????文件??????44702??2009-10-13?07:06??SDL_ttf-2.0.10\config.guess
?????文件??????25503??2013-11-07?18:09??SDL_ttf-2.0.10\config.log
?????文件??????56160??2013-11-07?18:09??SDL_ttf-2.0.10\config.status
?????文件??????34334??2009-10-13?07:06??SDL_ttf-2.0.10\config.sub
?????文件?????488882??2009-10-19?16:18??SDL_ttf-2.0.10\configure
?????文件???????4802??2009-10-13?07:06??SDL_ttf-2.0.10\configure.in
?????文件??????24390??2009-10-13?07:06??SDL_ttf-2.0.10\COPYING
?????文件??????18615??2009-10-19?16:18??SDL_ttf-2.0.10\depcomp
............此處省略36個文件信息
評論
共有 條評論