Zdravím,chcel by som stiahnuť knižnicu SDL pre C++,v minulosti som to už párkrát skúšal,no neúspešne,pretože vždy mi to vyhadzovalo chyby a celé to prostredie už bolo zle nastavené.Teraz by som to však chcel spraviť hneď na prvýkrát,skúšal som už x návodov aj na YT aj na Googli,avšak väčšina už je starých,taktiež by som chcel vedieť ktorá verzia Visual Studia je "vhodná" (ak na tom vôbec záleží) a či stačí Express alebo plná verzia.Ďakujem :-)
Fórum › C / C++
C++ SDL - Pomoc pri inštalácii
1. úplně postačí i verze Express, ale pokud nemáš nainstalováno, tak můžu doporučit i Community (na verzi nazáleží).
2. stáhneš toto: https://www.libsdl.org/release/SDL2-devel-2.0.4-VC.zip
3. rozbalíš a nakopíruješ soubory ze složky:
include do C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
lib do C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib
4. hotovo. (do složky k programu pak vždy přidáš "SDL2.dll", je obsažen ve staženém *.zipu)
Dakujem za radu,rozhodol som sa vyskusat ten VS Community 2015,akurat mam jednu otazku ,pretoze pri instalacii sa ma pyta ,"Aky typ instalacie chcem" ,ci Default alebo Custom,akurat nie som si isty ci Default obsahuje aj C++ .Obrazok s moznostami je po rozliknuti Custom
#5 Sigma
klidně zvol custom a můžeš pozaškrtávat něco navíc (jestli se ti bude něco hodit). Pokud nic navíc nezaškrtneš, tak se ti nainstaluje vlastně default. Pokud nevíš co zaškrtnout, tak zaškrtni vše co v názvu neobsahuje [3rd Party] (někdy se může hodit mít i po ruce jiné programovací jazyky a nástroje), sice to zabere trochu víc místa na disku a nějaký čas instalace, ale určitě ti nebude nic chybět (pokud ano, můžeš dodatečně něco doinstalovat).
Pro tebe bude asi dobré zaškrknout vše co obsahuje v názvu C++ (kromě 3rd party)
ps, Já vždy pokud něco instaluju tak volím custom, člověk vidí jaké jsou vlastně možnosti.
Nejako som to poskladal,teraz skusam pustit nejake kody,ze ci to vobec funguje,okno mi v pohode vytvorilo,skusam ale uz stlacanie klaves a hadze mi tu nejake chyby ..najskor kod
#include "stdafx.h"
#include <iostream>
#include <SDL.h>
/* Function Prototypes */
void PrintKeyInfo(SDL_KeyboardEvent *key);
void PrintModifiers(SDLMod mod);
/* main */
int main(int argc, char *argv[]) {
SDL_Event event;
int quit = 0;
/* Initialise SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Could not initialise SDL: %s\n", SDL_GetError());
exit(-1);
}
/* Set a video mode */
if (!SDL_SetVideoMode(320, 200, 0, 0)) {
fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError());
SDL_Quit();
exit(-1);
}
/* Enable Unicode translation */
SDL_EnableUNICODE(1);
/* Loop until an SDL_QUIT event is found */
while (!quit) {
/* Poll for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
/* Keyboard event */
/* Pass the event data onto PrintKeyInfo() */
case SDL_KEYDOWN:
case SDL_KEYUP:
PrintKeyInfo(&event.key);
break;
/* SDL_QUIT event (window close) */
case SDL_QUIT:
quit = 1;
break;
default:
break;
}
}
}
/* Clean up */
SDL_Quit();
exit(0);
}
/* Print all information about a key event */
void PrintKeyInfo(SDL_KeyboardEvent *key) {
/* Is it a release or a press? */
if (key->type == SDL_KEYUP)
printf("Release:- ");
else
printf("Press:- ");
/* Print the hardware scancode first */
printf("Scancode: 0x%02X", key->keysym.scancode);
/* Print the name of the key */
printf(", Name: %s", SDL_GetKeyName(key->keysym.sym));
/* We want to print the unicode info, but we need to make */
/* sure its a press event first (remember, release events */
/* don't have unicode info */
if (key->type == SDL_KEYDOWN) {
/* If the Unicode value is less than 0x80 then the */
/* unicode value can be used to get a printable */
/* representation of the key, using (char)unicode. */
printf(", Unicode: ");
if (key->keysym.unicode < 0x80 && key->keysym.unicode > 0) {
printf("%c (0x%04X)", (char)key->keysym.unicode,
key->keysym.unicode);
}
else {
printf("? (0x%04X)", key->keysym.unicode);
}
}
printf("\n");
/* Print modifier info */
PrintModifiers(key->keysym.mod);
}
/* Print modifier info */
void PrintModifiers(SDLMod mod) {
printf("Modifers: ");
/* If there are none then say so and return */
if (mod == KMOD_NONE) {
printf("None\n");
return;
}
/* Check for the presence of each SDLMod value */
/* This looks messy, but there really isn't */
/* a clearer way. */
if (mod & KMOD_NUM) printf("NUMLOCK ");
if (mod & KMOD_CAPS) printf("CAPSLOCK ");
if (mod & KMOD_LCTRL) printf("LCTRL ");
if (mod & KMOD_RCTRL) printf("RCTRL ");
if (mod & KMOD_RSHIFT) printf("RSHIFT ");
if (mod & KMOD_LSHIFT) printf("LSHIFT ");
if (mod & KMOD_RALT) printf("RALT ");
if (mod & KMOD_LALT) printf("LALT ");
if (mod & KMOD_CTRL) printf("CTRL ");
if (mod & KMOD_SHIFT) printf("SHIFT ");
if (mod & KMOD_ALT) printf("ALT ");
printf("\n");
}
vypis z Buildu
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1> ConsoleApplication1.cpp
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2065: 'SDLMod': undeclared identifier
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2146: syntax error: missing ')' before identifier 'mod'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(25): error C3861: 'SDL_SetVideoMode': identifier not found
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(32): error C3861: 'SDL_EnableUNICODE': identifier not found
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(86): error C2039: 'unicode': is not a member of 'SDL_Keysym'
1> c:\users\pet\downloads\sdl2-2.0.4\include\sdl_keyboard.h(48): note: see declaration of 'SDL_Keysym'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(87): error C2039: 'unicode': is not a member of 'SDL_Keysym'
1> c:\users\pet\downloads\sdl2-2.0.4\include\sdl_keyboard.h(48): note: see declaration of 'SDL_Keysym'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(88): error C2039: 'unicode': is not a member of 'SDL_Keysym'
1> c:\users\pet\downloads\sdl2-2.0.4\include\sdl_keyboard.h(48): note: see declaration of 'SDL_Keysym'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(91): error C2039: 'unicode': is not a member of 'SDL_Keysym'
1> c:\users\pet\downloads\sdl2-2.0.4\include\sdl_keyboard.h(48): note: see declaration of 'SDL_Keysym'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(96): error C3861: 'PrintModifiers': identifier not found
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(100): error C2065: 'SDLMod': undeclared identifier
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(100): error C2146: syntax error: missing ')' before identifier 'mod'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(100): error C2143: syntax error: missing ';' before '{'
1>c:\users\pet\documents\visual studio 2015\sdl\consoleapplication1\consoleapplication1\consoleapplication1.cpp(100): error C2447: '{': missing function header (old-style formal list?)
Este jeden pripad,k tomuto kodu
#include "stdafx.h"
#include <iostream>
#include <SDL.h>
int main(int argc, char* args[])
{
//The window we'll be rendering to
SDL_Window* window = NULL;
//The surface contained by the window
SDL_Surface* screenSurface = NULL;
//Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
}
else
{
//Create window
window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640,480, SDL_WINDOW_SHOWN);
if (window == NULL)
{
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
}
else
{
//Get window surface
screenSurface = SDL_GetWindowSurface(window);
//Fill the surface white
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
//Update the surface
SDL_UpdateWindowSurface(window);
//Wait two seconds
SDL_Delay(2000);
}
}
//Destroy window
SDL_DestroyWindow(window);
//Quit SDL subsystems
SDL_Quit();
return 0;
}
vypis:
Sorry,vypis:
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\Pet\Documents\Visual Studio 2015\SDL\ConsoleApplication1\Debug\ConsoleApplication1.exe'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\Pet\Documents\Visual Studio 2015\SDL\ConsoleApplication1\ConsoleApplication1\SDL2.dll'. Module was built without symbols.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\lpk.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\usp10.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\oleaut32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-timezone-l1-1-0.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-file-l2-1-0.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-localization-l1-2-0.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-synch-l1-2-0.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-processthreads-l1-1-1.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-file-l1-2-0.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\clbcatq.dll'. Cannot find or open the PDB file.
The program '[3156] ConsoleApplication1.exe' has exited with code 0 (0x0).
#7 Sigma
To vypadá, že to máš projekt starší verze 1.2
Obě verze můžeš používat současně, jen SDL dej do jiných složek, ale musíš nastavit cesty. Návod máš v tomto odkazu:
http://www.willusher.io/sdl2%20tutorials/2013/08/15/lesson-0-visual-studio/
Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Uživatelé prohlížející si toto vlákno
Podobná vlákna
Problem pri praci s SDL grafikou — založil jeremy2001
SDL/OpenGL - změna barev při texturování — založil frantta
Pomoc se sprovznenim SDL ve VS8 — založil yaqwsx
Pomoc pri pascale — založil liska11
Pomoc při vkládání dat — založil TenglerDaniel
Moderátoři diskuze