私は本の例から持っています、私は色の黒いものGL_QUADS
を投げました、そして私はまだそれを手に入れません、私が得るのは私の澄んだ白い画面だけです何が間違っているのでしょうか?
#include "SDL.h"
#include "SDL_opengl.h"
#include <iostream>
int main(int argc, char* args[])
{
// Memory usage specifics
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
// name on the window
SDL_WM_SetCaption( "our first game", NULL );
//set screen
SDL_SetVideoMode(600,400,32, SDL_OPENGL);
// when screen is clear
glClearColor(1,1,1,1); //red, green, blue, alpha
//portion to display
glViewport(0,0,600,400);
//shade
glShadeModel(GL_SMOOTH);
// 3D or 2D
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); //saves
//if only 2D?
glDisable(GL_DEPTH_TEST);
//this handles the main loop
bool isRunning = true;
//this is for the events
SDL_Event event;
//main rectangle
float myX = 300;
float myY = 350;
float width = 50;
float height = 30;
//main loop
while ( isRunning )
{
//EVENTS
while ( SDL_PollEvent(&event) )
{
//logic that should happen for certain events
//quiting the window
if ( event.type == SDL_QUIT )
{
isRunning = false;
}
// if ESC pressed
if ( event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_ESCAPE )
{
isRunning = false;
}
}
//LOGIC
//RENDERING TO THE SCREEN
glClear(GL_COLOR_BUFFER_BIT);
//start rendering phase
glPushMatrix();
//set the matix
glOrtho(0,600,400,0,-1,1);
//black color
glColor4ub(0,0,0,255);
//drawing
//GL_QUADS, GL_POINTS, GL_LINES, GL_LINE_STRIP,
//GL_LINE_LOOP, GL_QUADS, GL_TRIANGLES, GL_POLIGON
glBegin(GL_QUADS);
glVertex2f(myX,myY);
glVertex2f(myX+width,myY);
glVertex2f(myX+width,myY+height);
glVertex2f(myX,myY+height);
glEnd();
//render
SDL_GL_SwapBuffers();
}
//house keeping
SDL_Quit();
return 0;
}