mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-13 09:02:10 +00:00
Started working on rendering
This commit is contained in:
parent
7f2717cd5e
commit
036470a14e
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
#include "olcPixelGameEngine.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -7,6 +6,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <sstream>
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
string expression = trim(ex);
|
string expression = trim(ex);
|
||||||
bool inQuotes = false;
|
bool inQuotes = false;
|
||||||
|
|
||||||
CompilerLog("OLDEXPRESSION: |" + expression + "|");
|
//CompilerLog("OLDEXPRESSION: |" + expression + "|");
|
||||||
|
|
||||||
// If no operations are applied, then return self
|
// If no operations are applied, then return self
|
||||||
if ((count(expression, '+') == 0 && count(expression, '-') == 0 && count(expression, '*') == 0 && count(expression, '/') == 0 && count(expression, '(') == 0 && count(expression, '^') == 0) || split(expression, '.')[0] == "CPP")
|
if ((count(expression, '+') == 0 && count(expression, '-') == 0 && count(expression, '*') == 0 && count(expression, '/') == 0 && count(expression, '(') == 0 && count(expression, '^') == 0) || split(expression, '.')[0] == "CPP")
|
||||||
@ -115,7 +115,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
|
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
CompilerLog(split(expression, '(')[0] + " " + AnyAsString(GetVariableValue(split(argContents, ',')[0], variableValues)));
|
//CompilerLog(split(expression, '(')[0] + " " + AnyAsString(GetVariableValue(split(argContents, ',')[0], variableValues)));
|
||||||
return ExecuteFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
|
return ExecuteFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
|
||||||
}
|
}
|
||||||
else if (split(expression, '.')[0] == "CPP" && !inQuotes)
|
else if (split(expression, '.')[0] == "CPP" && !inQuotes)
|
||||||
@ -128,7 +128,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
|
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
CompilerLog(split(expression, '(')[0] + " " + argContents);
|
//CompilerLog(split(expression, '(')[0] + " " + argContents);
|
||||||
return CPPFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
|
return CPPFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -165,7 +165,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
CompilerLog(split(expression, '(')[0] + " " + AnyAsString(GetVariableValue(split(argContents, ',')[0], variableValues)));
|
//CompilerLog(split(expression, '(')[0] + " " + AnyAsString(GetVariableValue(split(argContents, ',')[0], variableValues)));
|
||||||
string returnVal = AnyAsString(ExecuteFunction(name, VarValues(split(argContents, ','), variableValues)));
|
string returnVal = AnyAsString(ExecuteFunction(name, VarValues(split(argContents, ','), variableValues)));
|
||||||
newExpression += returnVal;
|
newExpression += returnVal;
|
||||||
//cout << newExpression << endl;
|
//cout << newExpression << endl;
|
||||||
@ -199,7 +199,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
newExpression += expression[i];
|
newExpression += expression[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompilerLog("NEW EXPRESSION: |" + newExpression + "|");
|
//CompilerLog("NEW EXPRESSION: |" + newExpression + "|");
|
||||||
|
|
||||||
bool addStrings = false;
|
bool addStrings = false;
|
||||||
for (int i = 0; i < (int)newExpression.size(); i++)
|
for (int i = 0; i < (int)newExpression.size(); i++)
|
||||||
@ -297,8 +297,8 @@ int varOperation(const vector<string>& str, unordered_map<string, boost::any>& v
|
|||||||
|
|
||||||
boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unordered_map<string, boost::any>& variableValues)
|
boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unordered_map<string, boost::any>& variableValues)
|
||||||
{
|
{
|
||||||
CompilerLog(unWrapVec(words[lineNum]));
|
//CompilerLog(unWrapVec(words[lineNum]));
|
||||||
CompilerLog(AnyAsString(GetVariableValue("out", variableValues)));
|
//CompilerLog(AnyAsString(GetVariableValue("out", variableValues)));
|
||||||
|
|
||||||
if (words[lineNum][0][0] == '/' && words[lineNum][0][1] == '/')
|
if (words[lineNum][0][0] == '/' && words[lineNum][0][1] == '/')
|
||||||
return nullType;
|
return nullType;
|
||||||
@ -330,7 +330,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
|
|||||||
else if (countInVector(types, trim(words[lineNum][0])) > 0)
|
else if (countInVector(types, trim(words[lineNum][0])) > 0)
|
||||||
{
|
{
|
||||||
variableValues[words[lineNum][1]] = EvalExpression(unWrapVec(slice(words[lineNum], 3, -1)), variableValues);
|
variableValues[words[lineNum][1]] = EvalExpression(unWrapVec(slice(words[lineNum], 3, -1)), variableValues);
|
||||||
CompilerLog("new var :: " + words[lineNum][1] + " = " + AnyAsString(variableValues[words[lineNum][1]]));
|
//CompilerLog("new var :: " + words[lineNum][1] + " = " + AnyAsString(variableValues[words[lineNum][1]]));
|
||||||
return nullType;
|
return nullType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ int parseSlang(string script)
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = replace(args, functName + " ", "");
|
args = replace(args, functName + " ", "");
|
||||||
CompilerLog(args);
|
//CompilerLog(args);
|
||||||
functionContents.push_back(split(args, ','));
|
functionContents.push_back(split(args, ','));
|
||||||
|
|
||||||
int numOfBrackets = 1;
|
int numOfBrackets = 1;
|
||||||
|
|||||||
@ -80,6 +80,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IncludePath>D:\Code\SDL2-2.0.18\include;D:\Code\SDL2_image-2.0.5\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>D:\Code\SDL2-2.0.18\lib\x64;D:\Code\SDL2_image-2.0.5\lib\x64;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
@ -121,10 +123,13 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<AdditionalIncludeDirectories>D:\Code\boost;D:\Code\SDL2-2.0.18;D:\Code\SDL2_image-2.0.5;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>D:\Code\SDL2-2.0.18\lib\x64;D:\Code\boost\libs;D:\Code\SDL2_image-2.0.5\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@ -147,6 +152,7 @@
|
|||||||
<ClCompile Include="eval.cpp" />
|
<ClCompile Include="eval.cpp" />
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
<ClCompile Include="strops.cpp" />
|
<ClCompile Include="strops.cpp" />
|
||||||
|
<ClCompile Include="tut\02_getting_an_image_on_the_screen.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="builtin.h" />
|
<ClInclude Include="builtin.h" />
|
||||||
@ -163,6 +169,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="CMakeLists.txt" />
|
<Text Include="CMakeLists.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="tut\hello_world.bmp" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|||||||
@ -24,6 +24,9 @@
|
|||||||
<ClCompile Include="strops.cpp">
|
<ClCompile Include="strops.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="tut\02_getting_an_image_on_the_screen.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="olcPixelGameEngine.h">
|
<ClInclude Include="olcPixelGameEngine.h">
|
||||||
@ -52,4 +55,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="CMakeLists.txt" />
|
<Text Include="CMakeLists.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="tut\hello_world.bmp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -12,11 +12,12 @@
|
|||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "anyops.h"
|
#include "anyops.h"
|
||||||
#include <boost/any.hpp>
|
#include <boost/any.hpp>
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
vector<string> types = { "int", "float", "string", "bool", "void", "null" };
|
vector<string> types = { "int", "float", "string", "bool", "void", "null", "Circle"};
|
||||||
|
|
||||||
unordered_map<string, vector<vector<string>>> builtinFunctionValues;
|
unordered_map<string, vector<vector<string>>> builtinFunctionValues;
|
||||||
unordered_map<string, boost::any> builtinVarVals;
|
unordered_map<string, boost::any> builtinVarVals;
|
||||||
@ -28,6 +29,31 @@ public:
|
|||||||
string type = "NULL";
|
string type = "NULL";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Circle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
float r;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Image
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
float r;
|
||||||
|
SDL_Surface* surface;
|
||||||
|
SDL_Texture* texture;
|
||||||
|
|
||||||
|
/*int LoadImage(string PATH)
|
||||||
|
{
|
||||||
|
surface = IMG_Load("Path/To/Your/Image.png");
|
||||||
|
texture = SDL_CreateTextureFromSurface(renderer, surface);
|
||||||
|
SDL_FreeSurface(surface);
|
||||||
|
}*/
|
||||||
|
};
|
||||||
|
|
||||||
boost::any nullType;
|
boost::any nullType;
|
||||||
|
|
||||||
int LogWarning(const string& warningText)
|
int LogWarning(const string& warningText)
|
||||||
@ -125,11 +151,18 @@ boost::any CPPFunction(const string& name, const vector<boost::any>& args)
|
|||||||
else if (name == "CPP.Graphics.Init")
|
else if (name == "CPP.Graphics.Init")
|
||||||
{
|
{
|
||||||
cout << "\x1B[32mInit graphics\033[0m\t\t" << endl;
|
cout << "\x1B[32mInit graphics\033[0m\t\t" << endl;
|
||||||
if (mainWindow.Construct(AnyAsInt(args[0]), AnyAsInt(args[1]), AnyAsInt(args[2]), AnyAsInt(args[2])))
|
mainWindow.Start(AnyAsInt(args[0]), AnyAsInt(args[1]));
|
||||||
mainWindow.Start();
|
}
|
||||||
|
else if (name == "CPP.Graphics.Circle")
|
||||||
|
{
|
||||||
|
Circle c;
|
||||||
|
c.x = AnyAsInt(args[0]);
|
||||||
|
c.y = AnyAsInt(args[1]);
|
||||||
|
c.r = AnyAsInt(args[2]);
|
||||||
|
boost::any a = c;
|
||||||
|
Circle d = any_cast<Circle>(a);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
else if (name == "CPP.Graphics.SetPixel")
|
|
||||||
mainWindow.Draw(AnyAsInt(args[0]), AnyAsInt(args[1]), olc::Pixel(AnyAsInt(args[2]), AnyAsInt(args[3]), AnyAsInt(args[4])));
|
|
||||||
else if (name == "CPP.System.Print")
|
else if (name == "CPP.System.Print")
|
||||||
cout << AnyAsString(args[0]);
|
cout << AnyAsString(args[0]);
|
||||||
else if (name == "CPP.System.PrintLine")
|
else if (name == "CPP.System.PrintLine")
|
||||||
|
|||||||
@ -77,3 +77,10 @@ func Printl(in)
|
|||||||
{
|
{
|
||||||
CPP.System.PrintLine(in)
|
CPP.System.PrintLine(in)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates new circle class
|
||||||
|
func NewCircle(x, y, r)
|
||||||
|
{
|
||||||
|
Circle c = CPP.Graphics.Circle(x, y, r)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|||||||
@ -2,9 +2,6 @@
|
|||||||
#ifndef GRAPHICS_H
|
#ifndef GRAPHICS_H
|
||||||
#define GRAPHICS_H
|
#define GRAPHICS_H
|
||||||
|
|
||||||
#define OLC_PGE_APPLICATION
|
|
||||||
|
|
||||||
#include "olcPixelGameEngine.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -15,33 +12,62 @@
|
|||||||
#include "strops.h"
|
#include "strops.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_image.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Parser : public olc::PixelGameEngine
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Parser()
|
int Start(int SCREEN_W, int SCREEN_H)
|
||||||
{
|
{
|
||||||
sAppName = "Parser";
|
|
||||||
|
|
||||||
|
////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, w, h, 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);
|
||||||
|
|
||||||
|
// while (OnUpdate() == 0)
|
||||||
|
// {
|
||||||
|
// //Fill the surface white
|
||||||
|
// SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0x00, 0x00));
|
||||||
|
//
|
||||||
|
// //Update the surface
|
||||||
|
// SDL_UpdateWindowSurface(window);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
////Destroy window
|
||||||
|
//SDL_DestroyWindow(window);
|
||||||
|
|
||||||
|
//Quit SDL subsystems
|
||||||
|
//SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
int OnUpdate()
|
||||||
bool OnUserCreate() override
|
|
||||||
{
|
{
|
||||||
// Called once at the start
|
ExecuteFunction("Update", vector<boost::any>());
|
||||||
return true;
|
//cout << "update" << endl;
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
|
||||||
{
|
|
||||||
ExecuteFunction("Update", vector<boost::any> {});
|
|
||||||
|
|
||||||
// Called once per frame
|
|
||||||
//for (int x = 0; x < ScreenWidth(); x++)
|
|
||||||
// for (int y = 0; y < ScreenHeight(); y++)
|
|
||||||
// Draw(x, y, olc::Pixel(rand() % 128, rand() % 128, rand() % 128));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,23 +19,23 @@ func Main(input, in)
|
|||||||
x += 1
|
x += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
//CPP.Graphics.Init(64, 64, 4)
|
NewCircle(0, 0, 5)
|
||||||
return 0
|
CPP.Graphics.Init(64, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Update(input)
|
func Update(input)
|
||||||
{
|
{
|
||||||
int x = 0
|
//int x = 0
|
||||||
int y = 0
|
//int y = 0
|
||||||
while x < 64
|
//while x < 16
|
||||||
{
|
//{
|
||||||
while y < 64
|
// while y < 16
|
||||||
{
|
// {
|
||||||
SetPixel(x, y, 255, 0, 0)
|
// SetPixel(x, y, 255, 0, 0)
|
||||||
y += 1
|
// y += 1
|
||||||
}
|
// }
|
||||||
y = 0
|
// y = 0
|
||||||
x += 1
|
// x += 1
|
||||||
}
|
//}
|
||||||
print "updating"
|
print "updating"
|
||||||
}
|
}
|
||||||
|
|||||||
121
Slang/tut/02_getting_an_image_on_the_screen.cpp
Normal file
121
Slang/tut/02_getting_an_image_on_the_screen.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
///*This source code copyrighted by Lazy Foo' Productions (2004-2020)
|
||||||
|
//and may not be redistributed without written permission.*/
|
||||||
|
//
|
||||||
|
////Using SDL and standard IO
|
||||||
|
//#include <SDL.h>
|
||||||
|
//#include <stdio.h>
|
||||||
|
//
|
||||||
|
////Screen dimension constants
|
||||||
|
//const int SCREEN_WIDTH = 640;
|
||||||
|
//const int SCREEN_HEIGHT = 480;
|
||||||
|
//
|
||||||
|
////Starts up SDL and creates window
|
||||||
|
//bool init();
|
||||||
|
//
|
||||||
|
////Loads media
|
||||||
|
//bool loadMedia();
|
||||||
|
//
|
||||||
|
////Frees media and shuts down SDL
|
||||||
|
//void close();
|
||||||
|
//
|
||||||
|
////The window we'll be rendering to
|
||||||
|
//SDL_Window* gWindow = NULL;
|
||||||
|
//
|
||||||
|
////The surface contained by the window
|
||||||
|
//SDL_Surface* gScreenSurface = NULL;
|
||||||
|
//
|
||||||
|
////The image we will load and show on the screen
|
||||||
|
//SDL_Surface* gHelloWorld = NULL;
|
||||||
|
//
|
||||||
|
//bool init()
|
||||||
|
//{
|
||||||
|
// //Initialization flag
|
||||||
|
// bool success = true;
|
||||||
|
//
|
||||||
|
// //Initialize SDL
|
||||||
|
// if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
|
||||||
|
// {
|
||||||
|
// printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
|
||||||
|
// success = false;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //Create window
|
||||||
|
// gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
||||||
|
// if( gWindow == NULL )
|
||||||
|
// {
|
||||||
|
// printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
|
||||||
|
// success = false;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //Get window surface
|
||||||
|
// gScreenSurface = SDL_GetWindowSurface( gWindow );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return success;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//bool loadMedia()
|
||||||
|
//{
|
||||||
|
// //Loading success flag
|
||||||
|
// bool success = true;
|
||||||
|
//
|
||||||
|
// //Load splash image
|
||||||
|
// gHelloWorld = SDL_LoadBMP( "./tut/hello_world.bmp" );
|
||||||
|
// if( gHelloWorld == NULL )
|
||||||
|
// {
|
||||||
|
// printf( "Unable to load image %s! SDL Error: %s\n", "./tut/hello_world.bmp", SDL_GetError() );
|
||||||
|
// success = false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return success;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void close()
|
||||||
|
//{
|
||||||
|
// //Deallocate surface
|
||||||
|
// SDL_FreeSurface( gHelloWorld );
|
||||||
|
// gHelloWorld = NULL;
|
||||||
|
//
|
||||||
|
// //Destroy window
|
||||||
|
// SDL_DestroyWindow( gWindow );
|
||||||
|
// gWindow = NULL;
|
||||||
|
//
|
||||||
|
// //Quit SDL subsystems
|
||||||
|
// SDL_Quit();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//int main( int argc, char* args[] )
|
||||||
|
//{
|
||||||
|
// //Start up SDL and create window
|
||||||
|
// if( !init() )
|
||||||
|
// {
|
||||||
|
// printf( "Failed to initialize!\n" );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //Load media
|
||||||
|
// if( !loadMedia() )
|
||||||
|
// {
|
||||||
|
// printf( "Failed to load media!\n" );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //Apply the image
|
||||||
|
// SDL_BlitSurface( gHelloWorld, NULL, gScreenSurface, NULL );
|
||||||
|
//
|
||||||
|
// //Update the surface
|
||||||
|
// SDL_UpdateWindowSurface( gWindow );
|
||||||
|
//
|
||||||
|
// //Wait two seconds
|
||||||
|
// SDL_Delay( 2000 );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Free resources and close SDL
|
||||||
|
// close();
|
||||||
|
//
|
||||||
|
// return 0;
|
||||||
|
//}
|
||||||
BIN
Slang/tut/hello_world.bmp
Normal file
BIN
Slang/tut/hello_world.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 900 KiB |
Loading…
x
Reference in New Issue
Block a user