Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

maxd gaming

Dev-C++ and SDL

This topic is 5400 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


#include <cstdio>
#include <cstdlib>
#include <iostream>


#include <SDL/SDL.h>

// The functions are not shown to save space

void DrawPixel(SDL_Surface *screen, int x, int y,Uint8 R, Uint8 G, Uint8 B);
void Slock(SDL_Surface *screen);
void Sulock(SDL_Surface *screen);

SDL_Surface *screen;
int main(int argc, char *argv[])
{

  if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
  {
    std::cout << "Unable to init SDL: " << SDL_GetError() << std::endl;
    exit(1);
  }
  atexit(SDL_Quit);


  screen=SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
  if ( screen == NULL )
  {
    std::cout << "Unable to set 640x480 video: " << SDL_GetError() << std::endl;
    exit(1);
  }
 
 /////////////////////////

 ///////////////////////// This is the erroring section...

 //BEGIN DRAWING//////////

 /////////////////////////

 /////////////////////////

  
 Slock(screen);
for(int x=0;x<640;x++)
{
  for(int y=0;y<480;y++)
  {
  DrawPixel(screen, x,y,256,0,0);
  }
}
Sulock(screen);
SDL_Flip(screen);


//////////////////////

//////////////////////

//END DRAWING/////////

//////////////////////

//////////////////////

  return 0;
  
  
  
}


Dev-CPP and Cone3D examples I get:
g++.exe ../../../Templates/main.o SDL_Test_private.res -o "SDL Test.exe" -L"C:/DEV-CPP/lib" -L"C:/Dev-Cpp/lib" -mwindows -lmingw32 -lSDLmain -lSDL -liberty 

../../../Templates/main.o(.text+0x11c):main.cpp: undefined reference to `Slock(SDL_Surface*)'
../../../Templates/main.o(.text+0x15d):main.cpp: undefined reference to `DrawPixel(SDL_Surface*, int, int, unsigned char, unsigned char, unsigned char)'
../../../Templates/main.o(.text+0x17c):main.cpp: undefined reference to `Sulock(SDL_Surface*)'

Execution terminated
 
When I try to compile... Yes I am including the SDL libs and all... it was working until I added my drawing routine... help. [edited by - Maxd Gaming on February 7, 2004 11:41:39 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by VertexNormal
It doesn''t look like an SDL problem. Where are your DrawPixel, Slock and Sulock functions defined? They are apparently not being linked with the project.

Golem



Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller


Umm... I thought they were defined in a SDL file... arent they?






It''s Maxd Gaming, put in an underscore and I will beat you with a rubber ducky!
{ My Site! - Banner } { My Site! - One time popup }{ My .Net Information }{ A upcoming space RTS codenamed Gruntacktica . }{ . }

Not following the new trend:
Looky here mommy! No cow pic!


Phoe''s Forums
quote:
Umm... I thought they were defined in a SDL file... arent they?


No. A quick check of the SDL documentation would have told you that.

Another clue that those functions were not part of SDL was that they have prototypes. Libraries normally place function prototypes in .h files: they would not need to appear in the client application.

Anyways, you can find the definitions to those files at http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1

PS. The Cone3D guy lifted those examples directly from examples in the documentation.

Share this post


Link to post
Share on other sites
BTW.. SDL uses a nameing convention of

return type SDL_function_name(argument list)

all SDL functions are proceeded with SDL_...so if you don''t see it, then it wasn''t originally issued with SDL...

Share this post


Link to post
Share on other sites
Also, not to be too picky, but...

DrawPixel() as specified takes three Uint8 (unsigned char) color components. In your code, you call with DrawPixel(screen, x,y,256,0,0);. That 256 is probably going to give you wierdness; it should be 255 (MAX(unsigned char)). Just thought you might like to know...

Golem



Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites

  • 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!