Jump to content
  • Advertisement
Sign in to follow this  
helpmenow

OpenGL need help compiling sdl

This topic is 3406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello again I just bought a new book "Beginning OpenGL with Luck Benstead Dave Astle and Kevin Hawkins" now the book itself seems pretty good but I cant seem to get any of the examples to compile which is HIGHLY aggravating. I really want to learn opengl but how can I learn it if I can’t compile? Anyways all examples come with a VC++ version which is good for me because I have VC++ Express. The problem is it just doesn’t seem to want to compile. The Error: 1>Project : error PRJ0019: A tool returned an error code from "Checking Build System"

Share this post


Link to post
Share on other sites
Advertisement
sorry forgot to show the code

#ifdef _WIN32
#include <windows.h>
#endif
#include <iostream>
#include <vector>
#include <string>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

using std::vector;

void error(const std::string& s) {
#ifdef _WIN32
MessageBox(NULL, s.c_str(), "An error occurred", MB_ICONINFORMATION | MB_OK);
#else
std::cerr << s << std::endl;
#endif
}

class SimpleApp
{
public:
static const int WINDOW_WIDTH = 1024;
static const int WINDOW_HEIGHT = 768;

SimpleApp();
bool initialize();
void resize(int x, int y);
void prepare();
void render();
};

SimpleApp::SimpleApp()
{

}

bool SimpleApp::initialize()
{
//Enable depth testing
glEnable(GL_DEPTH_TEST);
//Set up the projection matrix
resize(WINDOW_WIDTH, WINDOW_HEIGHT);
return true;
}

void SimpleApp::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

gluLookAt(0.0, 1.0, 6.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);

glBegin(GL_TRIANGLES);
//Send the vertices and colors for the triangle
glColor4f(1.0, 0.0, 0.0, 1.0);
glVertex3f(2.0, 2.5, -1.0);
glColor4f(0.0, 1.0, 0.0, 1.0);
glVertex3f(-3.5, -2.5, -1.0);
glColor4f(0.0, 0.0, 1.0, 1.0);
glVertex3f(2.0, -4.0, -1.0);
glEnd();

glBegin(GL_TRIANGLE_FAN);
//Send the vertices and colors for the pentagon
glColor4f(1.0, 1.0, 1.0, 1.0);
glVertex3f(-1.0, 2.0, 0.0);
glColor4f(1.0, 1.0, 0.0, 1.0);
glVertex3f(-3.0, -0.5, 0.0);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertex3f(-1.5, -3.0, 0.0);
glColor4f(0.0, 0.0, 0.0, 1.0);
glVertex3f(1.0, -2.0, 0.0);
glColor4f(1.0, 0.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 0.0);
glEnd();
}

void SimpleApp::resize(int w, int h)
{
//Prevent a divide by zero error
if (h <= 0)
{
h = 1;
}

//When we resize the window, we tell OpenGL about the new viewport size
glViewport(0, 0, (GLsizei)w, (GLsizei)h);

glMatrixMode(GL_PROJECTION); //deprecated
glLoadIdentity();
//Then we set up our projection matrix with the correct aspect ratio
gluPerspective(60.0f, float(w) / float(h), 1.0f, 100.0f); //deprecated

glMatrixMode(GL_MODELVIEW); //deprecated
glLoadIdentity(); //deprecated
}

int main(int argc, char** argv)
{
SimpleApp myApp;

if ( SDL_Init( SDL_INIT_VIDEO ) != 0 )
{
std::cerr << "Could not initialize SDL" << std::endl;
return false;
}

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

std::string title = "BOGLGP Chapter 1";
SDL_WM_SetCaption(title.c_str(), title.c_str());

// Create the window
if (!SDL_SetVideoMode(SimpleApp::WINDOW_WIDTH, SimpleApp::WINDOW_HEIGHT, 0, SDL_OPENGL | SDL_RESIZABLE))
{
std::cerr << "Could not create the window" << std::endl;
return false;
}

if (!myApp.initialize())
{
SDL_Quit();
return 1;
}

bool done = false;

while (!done)
{
SDL_Event event;

while (SDL_PollEvent(&event))
{

switch(event.type) {
case SDL_QUIT:
done = true;
break;
case SDL_VIDEORESIZE:
myApp.resize(event.resize.w, event.resize.h);
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_ESCAPE) {
done = true;
}
break;
default:
break;
}
}

myApp.render();
SDL_GL_SwapBuffers();
}

SDL_Quit();

return 0;
}

Share this post


Link to post
Share on other sites
Quote:
The Error:
1>Project : error PRJ0019: A tool returned an error code from "Checking Build System"


From the main file menu, first click on Project -> (Project Name) Properties.

Expand Configuration Properties then Build Events.

Click on each of the three entries, Pre-Build Event, Pre-Link Event, and Post-Build Event and paste the contents of each box in a new reply so we can see what the project is trying to do.

Most of the time, they will simply be copying output into a common folder, a step you can do yourself, but we need to see it to be sure.

Share this post


Link to post
Share on other sites
This is all it says

Pre-Build Event

Excluded From Build || no

Pre-Link Event

Excluded From Build || no

Post-Build Event

Excluded From Build || no

Share this post


Link to post
Share on other sites
Quote:
Original post by helpmenow
There are some weird project files like ALL_BUILD and ZERO_CHECK I have never seen these type of files before.


Hmm, that's really weird then. As MSDN states about this problem:
Quote:
Visual C++ Concepts: Building a C/C++ Program
Project Build Error PRJ0019

Error Message
A tool returned an error code from

An error level was nonzero for a custom build step or build event.

You will also see PRJ0019 when a tool returned an error code but no error message. This can happen, for example, if you redirect the output of MIDL to NUL.

See Troubleshooting Custom Build Steps and Build Events for more information.

This error can also occur when you are running as a member of the Users group and Administrative access is needed. For more information, see Running as a Member of the Users Group.


Are you running as Administrator? If you are on XP chances are you should be, but if you are on Vista, then that might be the problem.

If non of the above is applicable, then I think the project files that are given are simply not compatible with your version of VC++ Express. Perhaps they were written for an older version?

You will just have to make your own project files in that event. Don't worry though, it's not too hard. There are a lot of tutorials, but here is Lazy Foo's version that might be of use.

Share this post


Link to post
Share on other sites
Sorry for the late reply. I figured out how to get it working I just started a brand new project put the code in it link all the opengl and sdl files to it and now it works just fine. Thanks for all the help anyways everyone.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!