need help with SDL

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 17949 Views - Last Post: 21 January 2012 - 03:45 PM Rate Topic: -----

#1 Frankma5   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 07-January 12

need help with SDL

Posted 18 January 2012 - 05:15 PM

hey i need help to install SDL in to code::Blocks i have tried to do this and i know about this tutorial http://lazyfoo.net/S...son01/index.php but it just does not work !!!!

on the SDL website you can only download SDL-devel-1.2.14-mingw32.tar.gz but on the tutorial it say to download SDL-devel-1.2.8-mingw32.tar.gz i don't know if there is much differences

Please help :)

Is This A Good Question/Topic? 0
  • +

Replies To: need help with SDL

#2 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,326
  • Joined: 14-February 08

Re: need help with SDL

Posted 19 January 2012 - 03:51 AM

If you are on windows then don't bother with code blocks, it doesn't offer anything that Visual Studio doesn't offer.

What are the errors or issues you are having?
Was This Post Helpful? 1
  • +
  • -

#3 Frankma5   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 07-January 12

Re: need help with SDL

Posted 19 January 2012 - 05:42 AM

here are the error

C:\Users\maus\c++\hello\main.cpp: In function `int SDL_main(int, char**)':
C:\Users\maus\c++\hello\main.cpp:7: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:7: error: `span' was not declared in this scope
C:\Users\maus\c++\hello\main.cpp:7: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:9: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:9: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:11: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:11: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:14: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:14: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:21: error: `screen' was not declared in this scope
C:\Users\maus\c++\hello\main.cpp:21: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:21: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:24: error: `bmp' was not declared in this scope
C:\Users\maus\c++\hello\main.cpp:24: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:24: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:24: error: expected primary-expression before '/' token
C:\Users\maus\c++\hello\main.cpp:26: error: `targetarea' was not declared in this scope
C:\Users\maus\c++\hello\main.cpp:32: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:32: error: expected `;' before "class"
C:\Users\maus\c++\hello\main.cpp:35: error: expected primary-expression before '<' token
C:\Users\maus\c++\hello\main.cpp:35: error: expected `;' before "class"

And this is the code

#include "SDL/SDL.h" // include <span class="searchlite">SDL</span>

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

	  // the screen we will draw to.
	 <span class="searchlite">SDL</span>_Surface *screen;
	 //  the surface to draw the bitmap on.
	 <span class="searchlite">SDL</span>_Surface *bmp;
	 // area to draw the bitmap to.
	 <span class="searchlite">SDL</span>_Rect  targetarea;

	 // initialize <span class="searchlite">SDL</span>. // I use everything as it will load video as well.
	 <span class="searchlite">SDL</span>_Init(<span class="searchlite">SDL</span>_INIT_EVERYTHING);

	 /*
	  set up the screen  pass in screen
	  width,height,bpp and set <span class="searchlite">SDL</span> to software
	   rendering
	 */
	 screen = <span class="searchlite">SDL</span>_SetVideoMode(640,480,32, <span class="searchlite">SDL</span>_SWSURFACE);

	 // load a bitmap.
	 bmp = <span class="searchlite">SDL</span>_LoadBMP("test.bmp"); /

	 targetarea.x = 10; // target x
	 targetarea.y = 20; // target y
	 targetarea.w = bmp->w; // target width
	 targetarea.h = bmp->h; // target height

	 // Draw the bitmap to the target area
	 <span class="searchlite">SDL</span>_BlitSurface(bmp, NULL, screen, &targetarea);

	 // show the bitmap // double buffering
	 <span class="searchlite">SDL</span>_Flip(screen);
	 while(1);
}




Thank you so much for the help :)
Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,326
  • Joined: 14-February 08

Re: need help with SDL

Posted 19 January 2012 - 05:59 AM

You left in all the CSS code from where you copy and pasted. How much C++ do you know?

Try this:

#include "SDL/SDL.h" // include SDL

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

	  // the screen we will draw to.
	 SDL_Surface *screen;
	 //  the surface to draw the bitmap on.
	 SDL_Surface *bmp;
	 // area to draw the bitmap to.
	 SDL_Rect  targetarea;

	 // initialize SDL. 
         // I use everything as it will load video as well.
	 SDL_Init(SDL_INIT_EVERYTHING);

	 /*
	  set up the screen  pass in screen
	  width,height,bpp and set SDL to software
	   rendering
	 */
	 screen = SDL_SetVideoMode(640,480,32, SDL_SWSURFACE);

	 // load a bitmap.
	 bmp = SDL_LoadBMP("test.bmp"); /

	 targetarea.x = 10; // target x
	 targetarea.y = 20; // target y
	 targetarea.w = bmp->w; // target width
	 targetarea.h = bmp->h; // target height

	 // Draw the bitmap to the target area
	 SDL_BlitSurface(bmp, NULL, screen, &targetarea);

	 // show the bitmap // double buffering
	 SDL_Flip(screen);
	 while(1);
}




In fact just try this to make sure it's linking properly

#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    
    //Quit SDL
    SDL_Quit();
    
    return 0;    
}


Was This Post Helpful? 0
  • +
  • -

#5 Frankma5   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 07-January 12

Re: need help with SDL

Posted 19 January 2012 - 06:19 AM

i got this message mingw32-g++.exe: C:\Users\maus\c++\SDL-1.2.14\-lmingw32 -lSDLmain -lSDL.a: No such file or directory

tbh i am new to c++ and just want to learn as much as i can . i can only program console app . so i wanted to learn how to use SDL :)

i have tried to link -lmingw32 -lSDLmain -lSDL but i can not find the files . but i did what the tutorial said and paste -lmingw32 -lSDLmain -lSDL into the link lib
Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,326
  • Joined: 14-February 08

Re: need help with SDL

Posted 19 January 2012 - 02:17 PM

Do you really not want to use Visual Studio? SDL is a piece of cake to set up using that IDE.
Was This Post Helpful? 0
  • +
  • -

#7 Frankma5   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 07-January 12

Re: need help with SDL

Posted 19 January 2012 - 02:53 PM

i don't really like Visual Studio but i have it working now thanks alot for your help :D
Was This Post Helpful? 0
  • +
  • -

#8 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: need help with SDL

Posted 19 January 2012 - 03:42 PM

Out of curiosity, what don't you like about Visual Studio?
Was This Post Helpful? 0
  • +
  • -

#9 Frankma5   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 07-January 12

Re: need help with SDL

Posted 19 January 2012 - 04:29 PM

there is a lot of little things the look of it the fact that it is microsoft and the way it show you that you have errors in your program. i don't understand a lot of the time what it is trying to tell me
Was This Post Helpful? -1
  • +
  • -

#10 anonymouscodder   User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: need help with SDL

Posted 19 January 2012 - 05:20 PM

Code::Blocks is clean, plain and simple IDE, really nice. If you are not already 'VS addicted' I wouldn't bother getting into VS if you are already fine with C::B.
Was This Post Helpful? 0
  • +
  • -

#11 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: need help with SDL

Posted 19 January 2012 - 06:02 PM

One day you guys will learn that a simple, clean IDE just doesn't cut it. I tried Code::Blocks a while back, and it's debugging capabilities are appalling. Then again, I stick with professional versions of VS for this very reason.
Was This Post Helpful? 0
  • +
  • -

#12 anonymouscodder   User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: need help with SDL

Posted 19 January 2012 - 06:45 PM

Yes, I must agree with you that debugging in VS is simply amazing.
But that's it. Rarely, but sometimes VS is a pain in the ass.

Maybe you got a perfect clean VS installation, lucky you. I've seen lots of PCs out there with VS installed simply crashing for no reason or just freezing the god damn explorer. And what about the most basic things on a code editor like current line highlight or column guidelines? Seriously, I have to install a plugin or something to get this? SERIOUSLY? God, even gedit got current line highlight and right margin out of the box.

I have literally hundreds of hours of 'VS usage' experience. When you are fixing freakin huge spaghetti code with a deadline all the debugging features that VS offers really saves the day. But if I gonna do something like game programming as a hobby in my spare time I would definitely go with something else (actually I prefer no IDE at all :), but that's just me).
Was This Post Helpful? 0
  • +
  • -

#13 anonymouscodder   User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: need help with SDL

Posted 19 January 2012 - 06:52 PM

View PostFrankma5, on 19 January 2012 - 10:19 AM, said:

i got this message mingw32-g++.exe: C:\Users\maus\c++\SDL-1.2.14\-lmingw32 -lSDLmain -lSDL.a: No such file or directory

tbh i am new to c++ and just want to learn as much as i can . i can only program console app . so i wanted to learn how to use SDL :)

i have tried to link -lmingw32 -lSDLmain -lSDL but i can not find the files . but i did what the tutorial said and paste -lmingw32 -lSDLmain -lSDL into the link lib


Right click on the on the project then go to the build options. On the Linker settings you got the path of the libraries to link and the linker options.

If your linker options are -lmingw32 -lSDLmain -lSDL looks like it's fine. Make sure that the path is to the libraries is ok.
Was This Post Helpful? 0
  • +
  • -

#14 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,326
  • Joined: 14-February 08

Re: need help with SDL

Posted 20 January 2012 - 02:27 AM

You would really put off using Visual Studio with its wealth of debugging options and other pros because of the fact that you have to install a plugin for current line highlighting? Really!?

I think most people are pretty used to just installing a plugin, it's not like it takes much effort. Visual Assist X and Visual Studio C++ are an amazing combo and I would be loath to use anything else when developing games. Debugging is such an important part of programming that the IDE with the greatest feature set for it should be top of anyones list.
Was This Post Helpful? 2
  • +
  • -

#15 anonymouscodder   User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: need help with SDL

Posted 20 January 2012 - 04:19 AM

No, I would give up visual studio because I've seen a lot of VS installs magically crashing or showing up misterious error messages (netbeans style) or 'eating up' tons of memory (being an
IDE is no excuse to allocate what I've seen).

And I really enjoy being cross-platform, but that's just me.
Today a new kid decides to get into programming, he choose a set of tools and go. Experimenting around, one day he decides to try out this 'linux'. He's IDE choice will be a frustation or not when migrating to this new world?

I'm not trying to start a discussion about VS, I'm just saying that other IDEs are perfectly fine. I believe that a simple IDE for programming as a hobby it's pretty sweet. Unless such tool X becomes necessary, KISS.

Anyway the most important thing it's try it out.
Don't use our opnion as yours, use it as a start to build your own.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2