May 10, 2013 at 4:36pm UTC
This is my first time every trying to write code in C++ and I do not know what I am doing wrong
[code]
#include "SDL.h"
#include "SDL_opengl.h"
#include <iostream>
int main( int argc, char* args[] )
{
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 );
SDL_WM_SetCaption( "My First Try", NULL );
SDL_SetVideoMode(600,400,32, SDL_OPENGL );
glClearColor(1,1,1,1); //Red, Green, Blue Alpha
glViewport(0,0,600,400);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
std::cout << "OpenGL is running\n";
std::cout << "Main loop has started\n";
bool isRunning = true;
while ( isRunning )
{
while ( SDL_PollEvent( &event ) )
{
if (event.type == SDL_QUIT)
{
isRunning = false;
}
}
}
std::cin.get();
SDL_Quit();
return 0;
}
_____________________________________________________________________________
this is the error I get
Line 39 error:'event' was not declared in this scope
=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===
______________________________________________________________________________
Any help is greatly appreciated, thank you
May 10, 2013 at 4:40pm UTC
You are using a variable 'event' in line 39, which was never before declared or defined. The compiler complains about not knowing what this 'event' is.
Last edited on May 10, 2013 at 5:59pm UTC