SDL final help

Pages: 12
Jul 19, 2013 at 10:41pm
closed account (NUj6URfi)
I really can't get sdl to work. Can someone post how to load a jpeg? I am looking for code. No other tutorials give out the code.
Jul 19, 2013 at 10:50pm
You will have to be more specific on what you want to do. Do you want to read a jpeg into a stream? Display it on the screen? Load a jpeg from a website? Im sure if you googled "c++ load jpeg to stream" or "c++ display jpeg" you will find what you need.
Jul 19, 2013 at 10:54pm
Even though you asked specifically for no tutorials you need to check out lazy foo's tutorial, before you dismiss tutorials completely.
http://lazyfoo.net/SDL_tutorials/

Image loading is in the second part...
http://lazyfoo.net/SDL_tutorials/lesson01/index2.php
Last edited on Jul 19, 2013 at 10:55pm
Jul 19, 2013 at 11:17pm
closed account (NUj6URfi)
Dev-c++ can't find ISDLmain.
Jul 19, 2013 at 11:52pm
closed account (NUj6URfi)
bump.
Jul 20, 2013 at 12:00am
Try using a proper main?
int main(int argc, char *argv[])

And try linking to the library?
(make sure these flags are present in the call to the linker)
-lmingw32 -lSDLmain -lSDL -mwindows
Last edited on Jul 20, 2013 at 12:01am
Jul 20, 2013 at 12:03am
closed account (NUj6URfi)
Error:

cannot find -lSDLmain
Everything else was good.
Jul 20, 2013 at 12:53am
closed account (NUj6URfi)
So I got it to work but the SDL window doesn't show up.
Jul 20, 2013 at 1:14am
Are you going to post your code? Right now there isn't really much help anyone can give you, with the small amount of information you have given.

EDIT: Be sure to check out lazy foo's tutorial if you are using Dev C++ http://lazyfoo.net/SDL_tutorials/lesson01/windows/devcpp/index.php
Last edited on Jul 20, 2013 at 1:27am
Jul 20, 2013 at 11:58am
closed account (NUj6URfi)
Has anyone else had the window not appearing glitch before?
Jul 20, 2013 at 1:00pm
closed account (NUj6URfi)
Okay so the window appears, and now on a different piece of code, my file says sdl.dll stray \144 in program.
And it goes on and on with errors like that. Anyone know how to fix the dll?
Jul 20, 2013 at 1:15pm
closed account (NUj6URfi)
Bump.
Jul 20, 2013 at 1:38pm
closed account (NUj6URfi)
Fine here is my code and the errors. I fixed the issues above and now have new ones.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//Basic libraries
#include <iostream>
#include <string>
#include "SDL.h"

using namespace std;
int i;

int main(int argc, char* args[]) {
     cout << "Welcome to my movie.";
     i = 1;
     if (i == 1) {
     SDL_Surface* frame1 = NULL;
    SDL_Surface* screen = NULL;
    if((SDL_Init(SDL_INIT_EVERYTHING)==-1)) { 
    cout << "Error initiating movie."; }
    screen = SDL_SetVideoMode( 640, 480, 64, SDL_HWSURFACE );
    frame1 = SDL_LoadBMP( "C:\\Users\\User\\Desktop\\Frames\\Frame1.bmp" );
     SDL_BlitSurface( frame1, NULL, screen, NULL );
    SDL_Flip( screen );
    SDL_Delay(2000);
    SDL_FreeSurface( frame1 );
    SDL_Quit();
    return 0;
}
}

I get the errors:
warning: `SDL_Init' initialized and declared `extern'
`Uint32' was not declared in this scope
warning: `SDL_InitSubSystem' initialized and declared `extern'
error: `Uint32' was not declared in this scope
warning: `SDL_QuitSubSystem' initialized and declared `extern'
error: variable or field `SDL_QuitSubSystem' declared void
error: `Uint32' was not declared in this scope
error: `Uint32' does not name a type
In function `int main(int, char**)':
error: `SDL_Surface' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
error: `frame1' undeclared (first use this function)
error: `screen' undeclared (first use this function)
error: `SDL_HWSURFACE' undeclared (first use this function)

error: `SDL_SetVideoMode' undeclared (first use this function)
error: `SDL_LoadBMP' undeclared (first use this function)
error: `SDL_BlitSurface' undeclared (first use this function)
error: `SDL_Flip' undeclared (first use this function)
error: `SDL_Delay' undeclared (first use this function)
error: `SDL_FreeSurface' undeclared (first use this function)

Execution terminated
Jul 20, 2013 at 2:10pm
closed account (NUj6URfi)
bump.
Jul 20, 2013 at 2:21pm
Try #include "SDL/SDL.h"

Notice the slight difference used in including SDL. This example is taken straight from lazy foo's tutorial on setting up Dev C++!!!! Please read it and follow the instructions vary carefully and you will have FAR less problems. http://lazyfoo.net/SDL_tutorials/lesson01/windows/devcpp/index.php

On each of lazy foo's lessons there is a link down at the bottom to download the source code.
Last edited on Jul 20, 2013 at 3:21pm
Jul 20, 2013 at 2:38pm
closed account (NUj6URfi)
I set dev-c++ up a different way to make it easier. I got SDl included and not by saying SDL/SDl.h. I got the error Library not found when I typed in that. The include isn't the problems, the header or code is.
Jul 20, 2013 at 2:42pm
Whatever different way you used to make it "easier" is still causing trouble for you. I would highly recommend following the tutorial. One of the benefits of SDL is it is cross platform, so there should be no difference from system to system. As long as each system has the correct SDL libraries installed, the same code should be able to execute. So if your code has an include line that is not matching something tells me you skipped something during the setup of SDL.
Last edited on Jul 20, 2013 at 2:45pm
Jul 20, 2013 at 2:45pm
closed account (NUj6URfi)
I tried that and got the errors and I am working with someone else on this project so I moved it to my dropbox. Again, I tried the tutorial and got the same errors. I am not using the .dll because I followed the instructions and it said that there was a ton of stray stuff in the dll which stopped dev-c++ from compiling.
Jul 20, 2013 at 2:48pm
Alright just for your sake I am going to take a system that has never had Dev-C++ and install SDL and get a window going. I will let you know how it goes.

EDIT: By following directions exactly I was easily able to get a picture on the screen using Dev-C++ for the first time on a machine that had never had it before. (The only reason it took almost an hour is because I am also at work answering phones and talking to customers.)
Last edited on Jul 20, 2013 at 3:44pm
Jul 20, 2013 at 4:48pm
closed account (NUj6URfi)
What version of dev-c++? I tried redownloading it. Can you try using my code?
Pages: 12