Browse Source

renderer global

master
Odilitime 5 years ago
parent
commit
c1c23bf273
  1. 97
      src/main.cpp

97
src/main.cpp

@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
#include "CFGFileParser.h"
#include "browser.h"
#include "interfaces/graphical/renderers/glfw/opengl.h"
#include "parsers/images/netpbm/pnm.h"
#include <ctime>
#include <iostream>
#include <sys/stat.h>
@ -33,6 +36,7 @@ extern "C"{ @@ -33,6 +36,7 @@ extern "C"{
// AElement uses it to getActiveDocumentComponent and navTo on that
//
std::unique_ptr<Browser> browser = nullptr;
std::unique_ptr<BaseRenderer> renderer = nullptr;
// forward declaration
bool isAbsolutePath(const std::string s);
@ -47,6 +51,8 @@ bool fileExists(const std::string s) { @@ -47,6 +51,8 @@ bool fileExists(const std::string s) {
return stat(s.c_str(), &buf) != -1;
}
extern TextRasterizerCache *rasterizerCache;
int main(int argc, char *argv[]) {
// show help msg when "--help" appears
if (argc > 1) {
@ -60,9 +66,8 @@ int main(int argc, char *argv[]) { @@ -60,9 +66,8 @@ int main(int argc, char *argv[]) {
#ifdef _WIN32
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
#endif
#if defined(VERSION) && defined(PLATFORM)
std::cout \
std::cout \
<< "# # ######" << std::endl \
<< "## # ###### ##### # # # # # # # # ###### #####" << std::endl \
<< "# # # # # # # # # ## # ## # # # #" << std::endl \
@ -70,20 +75,16 @@ std::cout \ @@ -70,20 +75,16 @@ std::cout \
<< "# # # # # # # # # # # # # # # # #####" << std::endl \
<< "# ## # # # # # # # ## # ## # # #" << std::endl \
<< "# # ###### # # # #### # # # # ###### # #" << std::endl;
#if defined(VERSION) && defined(PLATFORM)
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
#else
std::cout \
<< "# # ######" << std::endl \
<< "## # ###### ##### # # # # # # # # ###### #####" << std::endl \
<< "# # # # # # # # # ## # ## # # # #" << std::endl \
<< "# # # ##### # ###### # # # # # # # # ##### # #" << std::endl \
<< "# # # # # # # # # # # # # # # # #####" << std::endl \
<< "# ## # # # # # # # ## # ## # # #" << std::endl \
<< "# # ###### # # # #### # # # # ###### # #" << std::endl;
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": internal-dev non-Makefile build" << std::endl;
#endif
Environment::init();
CFGFileParser *parser = new CFGFileParser("./res/netrunner.cfg");
CFGFileParser *parser = new CFGFileParser("res/netrunner.cfg");
BrowserConfiguration *config = new BrowserConfiguration();
if (parser->ParseText()){
parser->WriteConfig(*config);
@ -96,6 +97,78 @@ std::cout \ @@ -96,6 +97,78 @@ std::cout \
}
std::cout << std::endl;
#endif
renderer = std::make_unique<OpenGL>();
//Environment::init();
renderer->initialize();
/*
Rect pos;
pos.x=0;
pos.y=0;
pos.w=1024;
pos.h=640;
OpenGLWindowHandle *win = renderer.createWindow("NTR", &pos, 0);
if (!win) {
std::cout << "Couldn't create window" << std::endl;
return 0;
}
OpenGLTexture *blue = win->createSpriteFromColor(0x0000FFFF);
if (!blue) {
std::cout << "Couldn't create blue" << std::endl;
return 0;
}
Rect dPos = { 0, 0, 512, 320 };
*/
/*
const std::shared_ptr<TextRasterizer> textRasterizer = rasterizerCache->loadFont(12, false);
rasterizationRequest request;
request.text = "Hello World";
request.startX = 512;
request.availableWidth = 1024;
request.maxTextureSize = 16384;
request.noWrap = true;
//std::cout << "rasterizing [" << text << "] @" << rawX << " availableWidth: " << availableWidth << " sourceStartX: " << rasterStartX << " noWrap: " << noWrap << std::endl;
std::shared_ptr<rasterizationResponse> response = textRasterizer->rasterize(request);
textureMap textureMap;
textureMap.map[0] = response->s0;
textureMap.map[1] = response->t0;
textureMap.map[2] = response->s1;
textureMap.map[3] = response->t1;
OpenGLTexture *text = win->createTextSprite(response->textureData.get(), response->textureWidth, response->textureHeight, textureMap);
Rect dPos3 = { 512, 320, 512, 320};
*/
/*
RGBAPNMObject *anime = readPPM("kon32_661.pam");
if (!anime) {
std::cout << "Couldn't load image" << std::endl;
return 0;
}
opengl_texture_handle *red = win->createSprite(anime->m_Ptr, anime->width, anime->height);
Rect dPos2 = { 512, 320, 512, 320};
*/
/*
win->clear();
win->drawSpriteBox(blue, &dPos);
win->drawSpriteText(text, 0x000000FF, &dPos3);
//win->drawSpriteBox(red, &dPos2);
win->swapBuffers();
while(1) {
glfwWaitEvents(); // block until something changes
}
return 0;
*/
// we need to set up OGL before we can setDOM (because component can't be constructed (currently) without OGL)
// but should be after CommandLineParams incase we need to change some type of window config
browser = std::make_unique<Browser>();

Loading…
Cancel
Save