本文整理汇总了C++中SDL_GL_SwapBuffers函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GL_SwapBuffers函数的具体用法?C++ SDL_GL_SwapBuffers怎么用?C++ SDL_GL_SwapBuffers使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_GL_SwapBuffers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sdlgl_update
void sdlgl_update(hwrbitmap d,s16 x,s16 y,s16 w,s16 h) {
SDL_GL_SwapBuffers();
}
示例2: SDL_GL_SwapBuffers
void Graphics::FlipBuffers()
{
SDL_GL_SwapBuffers();
}
示例3: RunGLTest
//.........这里部分代码省略.........
glColor3f(0.0, 1.0, 0.0);
glVertex3fv(cube[3]);
glVertex3fv(cube[4]);
glVertex3fv(cube[7]);
glVertex3fv(cube[2]);
glColor3f(0.0, 0.0, 1.0);
glVertex3fv(cube[0]);
glVertex3fv(cube[5]);
glVertex3fv(cube[6]);
glVertex3fv(cube[1]);
glColor3f(0.0, 1.0, 1.0);
glVertex3fv(cube[5]);
glVertex3fv(cube[4]);
glVertex3fv(cube[7]);
glVertex3fv(cube[6]);
glColor3f(1.0, 1.0, 0.0);
glVertex3fv(cube[5]);
glVertex3fv(cube[0]);
glVertex3fv(cube[3]);
glVertex3fv(cube[4]);
glColor3f(1.0, 0.0, 1.0);
glVertex3fv(cube[6]);
glVertex3fv(cube[1]);
glVertex3fv(cube[2]);
glVertex3fv(cube[7]);
#endif /* SHADED_CUBE */
glEnd( );
glMatrixMode(GL_MODELVIEW);
glRotatef(5.0, 1.0, 1.0, 1.0);
/* Draw 2D logo onto the 3D display */
if ( logo ) {
if ( USE_DEPRECATED_OPENGLBLIT ) {
DrawLogoBlit();
} else {
DrawLogoTexture();
}
}
if ( logocursor ) {
DrawLogoCursor();
}
SDL_GL_SwapBuffers( );
/* Check for error conditions. */
gl_error = glGetError( );
if( gl_error != GL_NO_ERROR ) {
fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
}
sdl_error = SDL_GetError( );
if( sdl_error[0] != '\0' ) {
fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
SDL_ClearError();
}
/* Allow the user to see what's happening */
if ( slowly ) {
SDL_Delay( 20 );
}
/* Check if there's a pending event. */
while( SDL_PollEvent( &event ) ) {
done = HandleEvent(&event);
}
++frames;
}
/* Print out the frames per second */
this_time = SDL_GetTicks();
if ( this_time != start_time ) {
printf("%2.2f FPS\n",
((float)frames/(this_time-start_time))*1000.0);
}
if ( global_image ) {
SDL_FreeSurface(global_image);
global_image = NULL;
}
if ( global_texture ) {
glDeleteTextures( 1, &global_texture );
global_texture = 0;
}
if ( cursor_texture ) {
glDeleteTextures( 1, &cursor_texture );
cursor_texture = 0;
}
/* Destroy our GL context, etc. */
SDL_Quit( );
return(0);
}
示例4: menu_run
//.........这里部分代码省略.........
settings->ball_speed = BALL_MAX_SPEED;
}
break;
default:
action = false;
break;
}
if(action) {
audio_play(SOUND_TICK);
}
}
if(events[EVENT_KEY_RIGHT]) {
bool action = true;
switch(s_focus) {
case LABEL_SECOND_PLAYER:
settings->play_with_computer = !settings->play_with_computer;
break;
case LABEL_SOUND_VOLUME:
settings->volume += 10;
if(settings->volume > 100) {
settings->volume = 100;
action = false;
} else {
vol_updated = true;
}
break;
case LABEL_LEVEL_SET:
s_level_set_index++;
if(s_level_set_index >= s_sets_names_length) {
s_level_set_index = 0;
}
settings->level = 1;
break;
case LABEL_LEVEL:
(settings->level)++;
if(settings->level > s_sets_levels[s_level_set_index]) {
settings->level = 1;
}
break;
case LABEL_THEME:
s_theme_index++;
if(s_theme_index >= s_themes_names_length) {
s_theme_index = 0;
}
break;
case LABEL_BALL_SPEED:
(settings->ball_speed)++;
if(settings->ball_speed > BALL_MAX_SPEED) {
settings->ball_speed = BALL_MIN_SPEED;
}
break;
default:
action = false;
break;
}
if(action) {
audio_play(SOUND_TICK);
}
}
if(events[EVENT_KEY_ENTER]) {
if(s_focus == LABEL_QUIT) {
return false;
} else {
leave = true;
}
}
if(vol_updated) {
audio_set_volume(settings->volume);
vol_updated = false;
}
glClear(GL_COLOR_BUFFER_BIT);
menu_display(settings);
SDL_GL_SwapBuffers();
timer_sleep(&timer);
}
strncpy(settings->level_set, s_sets_names[s_level_set_index], LIM_STR_LEN);
strncpy(settings->theme, s_themes_names[s_theme_index], LIM_STR_LEN);
settings->first_run = false;
return true;
}
示例5: main
//.........这里部分代码省略.........
GLushort elementData[] = { 1, 2, 0, 2, 3, 0, 5, 6, 4, 6, 7, 4, 9, 10, 8, 10, 11, 8, 13, 14, 12, 14, 15, 12 };
assert(sizeof(elementData) == 48);
glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer);
// sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B
glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound
glTexCoordPointer(2, GL_FLOAT, 32, (void*)16);
glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build
glTexCoordPointer(2, GL_SHORT, 32, (void*)24);
glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup
glNormalPointer(GL_BYTE, 32, (void*)12);
glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28);
glBindTexture(GL_TEXTURE_2D, texture); // diffuse?
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture2); // lightmap?
glActiveTexture(GL_TEXTURE0);
GLint ok;
const char *vertexShader = "uniform vec4 texgenscroll;\n"
"void main(void)\n"
"{\n"
" gl_Position = ftransform();\n"
" gl_TexCoord[0].xy = gl_MultiTexCoord0.xy/10000.0 + (0.001*texgenscroll.xy) + gl_Normal.xy;\n" // added /100 here
" gl_TexCoord[1].xy = gl_MultiTexCoord1.xy/100.0 * 3.051851e-05;\n"
"}\n";
const char *fragmentShader = "uniform vec4 colorparams;\n"
"uniform sampler2D diffusemap, lightmap;\n"
"void main(void)\n"
"{\n"
" vec4 diffuse = texture2D(diffusemap, gl_TexCoord[0].xy);\n"
" vec4 lm = texture2D(lightmap, gl_TexCoord[1].xy);\n"
" diffuse *= colorparams;\n"
" gl_FragColor = diffuse * lm;\n"
"}\n";
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vs, 1, &vertexShader, NULL);
glCompileShader(vs);
glGetShaderiv(vs, GL_COMPILE_STATUS, &ok);
assert(ok);
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, 1, &fragmentShader, NULL);
glCompileShader(fs);
glGetShaderiv(fs, GL_COMPILE_STATUS, &ok);
assert(ok);
GLuint program = glCreateProgram();
glAttachShader(program, vs);
glAttachShader(program, fs);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &ok);
assert(ok);
glUseProgram(program);
GLint lightmapLocation = glGetUniformLocation(program, "lightmap");
assert(lightmapLocation >= 0);
glUniform1i(lightmapLocation, 1); // sampler2D? Is it the texture unit?
GLint diffusemapLocation = glGetUniformLocation(program, "diffusemap");
assert(diffusemapLocation >= 0);
glUniform1i(diffusemapLocation, 0);
GLint texgenscrollLocation = glGetUniformLocation(program, "texgenscroll");
assert(texgenscrollLocation >= 0);
GLint colorparamsLocation = glGetUniformLocation(program, "colorparams");
assert(colorparamsLocation >= 0);
GLfloat texgenscrollData[] = { 0, 0, 0, 0 };
glUniform4fv(texgenscrollLocation, 1, texgenscrollData);
GLfloat colorparamsData[] = { 2, 2, 2, 1 };
glUniform4fv(colorparamsLocation, 1, colorparamsData);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)&elementData[12/sizeof(GLushort)]);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)&elementData[ 0/sizeof(GLushort)]);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)&elementData[24/sizeof(GLushort)]);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)&elementData[36/sizeof(GLushort)]);
// END
SDL_GL_SwapBuffers();
#ifndef __EMSCRIPTEN__
SDL_Delay(1500);
#endif
SDL_Quit();
return 0;
}
示例6: main
//.........这里部分代码省略.........
if (geom || sample)
{
const float* bmin = 0;
const float* bmax = 0;
if (sample)
{
bmin = sample->getBoundsMin();
bmax = sample->getBoundsMax();
}
else if (geom)
{
bmin = geom->getMeshBoundsMin();
bmax = geom->getMeshBoundsMax();
}
// Reset camera and fog to match the mesh bounds.
if (bmin && bmax)
{
camr = sqrtf(rcSqr(bmax[0]-bmin[0]) +
rcSqr(bmax[1]-bmin[1]) +
rcSqr(bmax[2]-bmin[2])) / 2;
camx = (bmax[0] + bmin[0]) / 2 + camr;
camy = (bmax[1] + bmin[1]) / 2 + camr;
camz = (bmax[2] + bmin[2]) / 2 + camr;
camr *= 3;
}
rx = 45;
ry = -45;
glFogf(GL_FOG_START, camr*0.2f);
glFogf(GL_FOG_END, camr*1.25f);
}
// Do the tests.
if (sample)
test->doTests(sample->getNavMesh(), sample->getNavMeshQuery());
}
}
imguiEndScrollArea();
}
// Log
if (showLog && showMenu)
{
if (imguiBeginScrollArea("Log", 10, 10, width - 300, 200, &logScroll))
mouseOverMenu = true;
for (int i = 0; i < ctx.getLogCount(); ++i)
imguiLabel(ctx.getLogText(i));
imguiEndScrollArea();
}
// Tools
if (!showTestCases && showTools && showMenu && geom && sample)
{
if (imguiBeginScrollArea("Tools", 10, height - 10 - 350, 250, 350, &toolsScroll))
mouseOverMenu = true;
sample->handleTools();
imguiEndScrollArea();
}
slideShow.updateAndDraw(dt, (float)width, (float)height);
// Marker
if (mposSet && gluProject((GLdouble)mpos[0], (GLdouble)mpos[1], (GLdouble)mpos[2],
model, proj, view, &x, &y, &z))
{
// Draw marker circle
glLineWidth(5.0f);
glColor4ub(240,220,0,196);
glBegin(GL_LINE_LOOP);
const float r = 25.0f;
for (int i = 0; i < 20; ++i)
{
const float a = (float)i / 20.0f * RC_PI*2;
const float fx = (float)x + cosf(a)*r;
const float fy = (float)y + sinf(a)*r;
glVertex2f(fx,fy);
}
glEnd();
glLineWidth(1.0f);
}
imguiEndFrame();
imguiRenderGLDraw();
glEnable(GL_DEPTH_TEST);
SDL_GL_SwapBuffers();
}
imguiRenderGLDestroy();
SDL_Quit();
delete sample;
delete geom;
return 0;
}
示例7: ditto_render
void ditto_render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -20.0f);
GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glRotatef(-angle, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
//Top face
glColor3f(1.0f, 1.0f, 0.0f);
glNormal3f(0.0, 1.0f, 0.0f);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
//Bottom face
glColor3f(1.0f, 0.0f, 1.0f);
glNormal3f(0.0, -1.0f, 0.0f);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
//Left face
glNormal3f(-1.0, 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
//Right face
glNormal3f(1.0, 0.0f, 0.0f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
glEnd();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
//Front face
glNormal3f(0.0, 0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, BOX_SIZE / 2);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, BOX_SIZE / 2);
//Back face
glNormal3f(0.0, 0.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(-BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(BOX_SIZE / 2, BOX_SIZE / 2, -BOX_SIZE / 2);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(BOX_SIZE / 2, -BOX_SIZE / 2, -BOX_SIZE / 2);
glEnd();
glDisable(GL_TEXTURE_2D);
SDL_GL_SwapBuffers();
}
示例8: swapBuffers
void gemsdlwindow :: swapBuffers(void) {
if(makeCurrent()) // FIXME: is this needed?
SDL_GL_SwapBuffers();
}
示例9: glEnable
void LoadingBar::Draw(float val)
{
// percent complete bar only draws in 2d mode
prj->set_orthographic_projection();
// Draw the splash screen if available
if (splash) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glColor3f(1, 1, 1);
glDisable(GL_CULL_FACE);
glBindTexture(GL_TEXTURE_2D, splash->getID());
glBegin(GL_QUADS);
glTexCoord2i(0, 0); // Bottom Left
glVertex3f(splashx, splashy, 0.0f);
glTexCoord2i(1, 0); // Bottom Right
glVertex3f(splashx + width, splashy, 0.0f);
glTexCoord2i(1, 1); // Top Right
glVertex3f(splashx + width, splashy + height, 0.0f);
glTexCoord2i(0, 1); // Top Left
glVertex3f(splashx, splashy + height, 0.0f);
glEnd();
}
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
// black out background of text for redraws (so can keep sky unaltered)
glColor3f(0, 0, 0);
glBegin(GL_QUAD_STRIP);
glTexCoord2i(1, 0); // Bottom Right
glVertex3f(splashx + width, bary-70, 0.0f);
glTexCoord2i(0, 0); // Bottom Left
glVertex3f(splashx, bary-70, 0.0f);
glTexCoord2i(1, 1); // Top Right
glVertex3f(splashx + width, bary-5, 0.0f);
glTexCoord2i(0, 1); // Top Left
glVertex3f(splashx, bary-5, 0.0f);
glEnd();
glColor3f(0.8, 0.8, 1);
glBegin(GL_QUAD_STRIP);
glTexCoord2i(1, 0); // Bottom Right
glVertex3f(barx + barwidth, bary + barheight, 0.0f);
glTexCoord2i(0, 0); // Bottom Left
glVertex3f(barx, bary + barheight, 0.0f);
glTexCoord2i(1, 1); // Top Right
glVertex3f(barx + barwidth, bary, 0.0f);
glTexCoord2i(0, 1); // Top Left
glVertex3f(barx, bary, 0.0f);
glEnd();
glColor3f(0.4f, 0.4f, 0.6f);
glBegin(GL_QUAD_STRIP);
glTexCoord2i(1, 0); // Bottom Right
glVertex3f(-1 + barx + barwidth * val, bary + barheight - 1, 0.0f);
glTexCoord2i(0, 0); // Bottom Left
glVertex3f(1 + barx, bary + barheight - 1, 0.0f);
glTexCoord2i(1, 1); // Top Right
glVertex3f(-1 + barx + barwidth * val, bary + 1, 0.0f);
glTexCoord2i(0, 1); // Top Left
glVertex3f(1 + barx, bary + 1, 0.0f);
glEnd();
glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
if(barfont) {
barfont->print(barx, bary-15, message);
// LEGAL NOTICES -- THE DISPLAY OF THESE AT STARTUP MAY NOT BE REMOVED as per GPL section 5
barfont->print(barx-20, bary-40, "<span color='#666699'>Nightshade is free, open source software with a GPLv3 license.</span>");
barfont->print(barx-20, bary-55, "<span color='#666699'>Nightshade is a registered trademark of Digitalis Education Solutions, Inc.</span>");
}
if(extraTextFont) {
extraTextFont->print(splashx + extraTextPos[0], splashy + extraTextPos[1], extraText);
extraTextFont->print(splashx + extraTextPos[0], splashy + extraTextPos[1] - 20, EDITION);
extraTextFont->print(splashx + extraTextPos[0], splashy + extraTextPos[1] - 40, "Edition");
}
SDL_GL_SwapBuffers(); // And swap the buffers
prj->reset_perspective_projection();
}
示例10: main
//.........这里部分代码省略.........
// second texture
GLuint texture2;
{
const int DDS_SIZE = 32896;
FILE *dds = fopen("bloom.dds", "rb");
assert(dds);
char *ddsdata = (char*)malloc(DDS_SIZE);
assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE);
fclose(dds);
glGenTextures( 1, &texture2 );
glBindTexture( GL_TEXTURE_2D, texture2 );
assert(!glGetError());
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 256, 256, 0, DDS_SIZE-128, ddsdata+128);
assert(!glGetError());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
// third, a non-square texture with mipmaps
GLuint texture3;
{
const int DDS_SIZE = 43920;
FILE *dds = fopen("water.dds", "rb");
assert(dds);
char *ddsdata = (char*)malloc(DDS_SIZE);
assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE);
fclose(dds);
glGenTextures( 1, &texture3 );
glBindTexture( GL_TEXTURE_2D, texture3 );
assert(!glGetError());
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 512, 64, 0, 512*64, ddsdata+128);
assert(!glGetError());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
// Prepare and Render
// Clear the screen before drawing
glClear( GL_COLOR_BUFFER_BIT );
// Bind the texture to which subsequent calls refer to
glBindTexture( GL_TEXTURE_2D, texture );
// Use clientside vertex pointers to render two items
GLfloat vertexData[] = { 0, 0, 10, 10, // texture2, position2
1, 0, 300, 10,
1, 1, 300, 128,
0, 1, 10, 128,
0, 0.5, 410, 10,
1, 0.5, 600, 10,
1, 1, 630, 200,
0.5, 1, 310, 250 };
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 4*4, &vertexData[0]);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 4*4, &vertexData[2]);
glDrawArrays(GL_QUADS, 0, 4);
glBindTexture( GL_TEXTURE_2D, texture3 );
glDrawArrays(GL_QUADS, 4, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
// Render the last item using oldschool glBegin etc
glBindTexture( GL_TEXTURE_2D, texture2 );
glBegin( GL_TRIANGLE_STRIP );
glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 );
glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 );
glTexCoord2i( 1, 1 ); glVertex3f( 300, 400, 0 );
glTexCoord2i( 0, 1 ); glVertex3f( 500, 410, 0 );
glEnd();
SDL_GL_SwapBuffers();
#if !EMSCRIPTEN
// Wait for 3 seconds to give us a chance to see the image
SDL_Delay(1500);
#endif
// Now we can delete the OpenGL texture and close down SDL
glDeleteTextures( 1, &texture );
SDL_Quit();
return 0;
}
示例11: display
void display() {
int i, wm;
float size = 5;
if (!can_render()) {
return;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if (render_mode == IR) {
/* draw the IR stuff */
glDisable(GL_LIGHTING);
glBegin(GL_TRIANGLES);
/* green center */
glColor3f(0.0, 1.0, 0.0);
DRAW_TRIANGLE(width / 2, height / 2, 0, size);
glEnd();
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
glBegin(GL_TRIANGLES);
/* red ir */
glColor3f(1.0, 0.0, 0.0);
for (i = 0; i < 4; ++i) {
if (wiimotes[wm]->ir.dot[i].visible) {
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].rx, wiimotes[wm]->ir.dot[i].ry, 0, size);
}
}
/* yellow corrected ir */
glColor3f(1.0, 1.0, 0.0);
for (i = 0; i < 4; ++i) {
if (wiimotes[wm]->ir.dot[i].visible) {
DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].x, wiimotes[wm]->ir.dot[i].y, 0, size);
}
}
/* blue cursor */
glColor3f(0.0, 0.0, 1.0);
DRAW_TRIANGLE(wiimotes[wm]->ir.x, wiimotes[wm]->ir.y - size, 0, size);
glEnd();
}
} else {
/* draw the teapot */
gluLookAt(0.0, 0.0, -5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
update_light(GL_LIGHT0, &light);
set_material(&red_plastic);
glRotatef(wiimotes[0]->orient.roll, 0.0f, 0.0f, 1.0f);
glRotatef(wiimotes[0]->orient.pitch, 1.0f, 0.0f, 0.0f);
glutSolidTeapot(1);
}
SDL_GL_SwapBuffers();
}
示例12: r_drawFrame
//.........这里部分代码省略.........
renderer_model_drawASE(0);
glPopMatrix();
glClear(GL_DEPTH_BUFFER_BIT);
//Draw fighter. Needs to stay with the camera.
//Doesn't rotate. Only stays in the same position relative to camera.
glPushMatrix();
glLoadIdentity();
renderer_model_drawASE(1);
glPopMatrix();
//Texture stuff past this point.
glColor3f(1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, face1);
glBegin(GL_QUADS);
//Set up appropriate texture for the forward face.
//I've been visualizing this the wrong way. Each four is considered a square.
//Face 1
glTexCoord2f(0.0, 0.0);
glVertex3f(-0.5, -0.5, -8.0);
glTexCoord2f(1.0, 0.0);
glVertex3f( 0.5, -0.5, -8.0);
glTexCoord2f(1.0, 1.0);
glVertex3f( 0.5, 0.5, -8.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-0.5, 0.5, -8.0);
glEnd();
//Face 2
glBindTexture(GL_TEXTURE_2D, face4);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-0.5, -0.5, -9.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(-0.5, -0.5, -8.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-0.5, 0.5, -8.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-0.5, 0.5, -9.0);
glEnd();
//Face 3
glBindTexture(GL_TEXTURE_2D, face3);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(0.5, -0.5, -8.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(0.5, -0.5, -9.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(0.5, 0.5, -9.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(0.5, 0.5, -8.0);
glEnd();
//Face 4
glBindTexture(GL_TEXTURE_2D, face6);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(0.5, -0.5, -9.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(-0.5, -0.5, -9.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-0.5, 0.5, -9.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(0.5, 0.5, -9.0);
glEnd();
//Face 5
glBindTexture(GL_TEXTURE_2D, face5);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-0.5, 0.5, -8.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(0.5, 0.5, -8.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(0.5, 0.5, -9.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-0.5, 0.5, -9.0);
glEnd();
//Face 6
glBindTexture(GL_TEXTURE_2D, face2);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(0.5, -0.5, -8.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(-0.5, -0.5, -8.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(-0.5, -0.5, -9.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(0.5, -0.5, -9.0);
glEnd();
SDL_GL_SwapBuffers();
}
示例13: SDL_GL_SwapBuffers
void Graphics::SwapFrameBuffer()
{
// Swap OpenGL framebuffer
SDL_GL_SwapBuffers();
}
示例14: gl_drawwin
//.........这里部分代码省略.........
glvidbuffer + 512 * 224);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, (224.0 / 256.0));
glVertex3f(0.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, (224.0 / 256.0));
glVertex3f(-1.0f, -1.0f, -1.0f);
glEnd();
/* Lower right quad */
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
glvidbuffer + 512 * 224 + 256);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, (224.0 / 256.0));
glVertex3f(1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, (224.0 / 256.0));
glVertex3f(0.0f, -1.0f, -1.0f);
glEnd();
}
else
{
/*
* This code splits the hires/lores portions up, and draws
* them with gl_drawspan
*/
int lasthires, lasthires_line = 0;
gltexture256 = gltexture512 = 0;
lasthires = SpecialLine[1];
for (i = 1; i < 222; i++)
{
if (SpecialLine[i + 1])
{
if (lasthires)
continue;
gl_drawspan(lasthires, lasthires_line, i);
lasthires = SpecialLine[i + 1];
lasthires_line = i;
}
else
{
if (!lasthires)
continue;
gl_drawspan(lasthires, lasthires_line, i);
lasthires = SpecialLine[i + 1];
lasthires_line = i;
}
}
gl_drawspan(lasthires, lasthires_line, i);
/*
* This is here rather than right outside this if because the
* GUI doesn't allow scanlines to be selected while filters are
* on.. There is no technical reason they can't be on while
* filters are on, however. Feel free to change the GUI, and
* move this outside the if (En2xSaI) {}, if you do.
*/
if (scanlines)
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_1D, gltextures[3]);
glColor4f(1.0f, 1.0f, 1.0f,
scanlines == 1 ? 1.0f : (scanlines ==
2 ? 0.25f : 0.50f));
for (i = 0; i < SurfaceY; i += 256)
{
glBegin(GL_QUADS);
glTexCoord1f(0.0f);
glVertex3f(-1.0f, (SurfaceY - i * 2.0) / SurfaceY, -1.0f);
glTexCoord1f(0.0f);
glVertex3f(1.0f, (SurfaceY - i * 2.0) / SurfaceY, -1.0f);
glTexCoord1f(1.0f);
glVertex3f(1.0f, (SurfaceY - (i + 256) * 2.0) / SurfaceY, -1.0f);
glTexCoord1f(1.0f);
glVertex3f(-1.0f, (SurfaceY - (i + 256) * 2.0) / SurfaceY, -1.0f);
glEnd();
}
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
}
}
SDL_GL_SwapBuffers();
}
示例15: while
bool MenuScreen::display_menu(SDL_Surface *screen,SELECTION &selection) {
Uint32 ticks=SDL_GetTicks();
Uint32 frame_count=0;
//logo sprites
const Sprite *logo_free=spr_coll->get_sprite("logo_free");
const Sprite *logo_siege=spr_coll->get_sprite("logo_siege");
//~ const Sprite *logo_sword=spr_coll->get_sprite("logo_sword");
//background sprites
const Sprite *back_hill=spr_coll->get_sprite("title_foreground");
const Sprite *back_castle=spr_coll->get_sprite("title_castle");
const Sprite *back_sky=spr_coll->get_sprite("title_sky");
SDL_Event event;
float shift=1.0;
while (true) {
Menu *current_menu=menus.top();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//fill_rect_opengl(0,0,SCREEN_W,SCREEN_H,1,1,0,1);
back_sky->draw(0,0);
back_castle->draw(0,CASTLE_BIAS+CASTLE_SHIFT*shift);
back_hill->draw(0,HILL_BIAS+HILL_SHIFT*shift);
shift-=D_SHIFT;
if (shift<0) shift=0;
//draw_fadein(logo_sword,(SCREEN_W-logo_sword->w)/2,MENUSCREEN_BASE_Y-logo_sword->h/2-4,frame_count,MENUSCREEN_SWORD_FRAME_COUNT,30,4);
draw_fadein(logo_free,MENUSCREEN_BASE_X,MENUSCREEN_BASE_Y,frame_count,MENUSCREEN_FREE_FRAME_COUNT,MENUSCREEN_DELAY);
draw_fadein(logo_siege,SCREEN_W-logo_siege->w-MENUSCREEN_BASE_X,MENUSCREEN_BASE_Y,frame_count,MENUSCREEN_SIEGE_FRAME_COUNT,MENUSCREEN_DELAY);
current_menu->draw();
SDL_GL_SwapBuffers();
SDL_Flip(screen);
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
if (!menus.empty()) menus.pop();
if (menus.empty()) {
selection=QUIT;
return true;
}
break;
case SDLK_RETURN:
case SDLK_SPACE:
if (current_menu==main_menu) {
switch (current_menu->get_selected()->n) {
case 0://2 players versus
selection=TWO_PLAYERS;
return false;
break;
case 1://training mode
selection=TRAINING;
return false;
break;
case 2://combinaisons
selection=COMBINAISONS;
return false;
break;
case 3://options
menus.push(option_menu);
break;
case 4://quit
selection=QUIT;
return true;
break;
default:
break;
}
} else if (current_menu==option_menu) {
switch (current_menu->get_selected()->n) {
case 0://ai level
switch (ai_level) {
case EASY:
ai_level=NORMAL;
current_menu->get_selected()->title="AI Level: Knight";
break;
case NORMAL:
ai_level=HARD;
current_menu->get_selected()->title="AI Level: Galaad the Righteous";
break;
case HARD:
ai_level=EXTREME;
current_menu->get_selected()->title="AI Level: Morgoth the Cruel";
break;
case EXTREME:
ai_level=EASY;
current_menu->get_selected()->title="AI Level: Farmer";
break; }
break;
case 1://keys
menus.push(key_menu);
break;
case 2://Sound
if (!Options::soundOn())
{
Mix_ResumeMusic();
Options::setSound(true);
//.........这里部分代码省略.........