• Content count

  • Joined

  • Last visited

Community Reputation

191 Neutral

About MrKaktus

  • Rank
  1. If you could talk with Graphic Drivers Developers about GL_ARB_Debug_Output extension, what type of messages you would ask them to be printed out by driver? What use cases should this extensions consider? What debug messages would be most important for you? Please write concrete use cases, all suggestions will be taken into notice! More info about extension itself: Thanks, Karol
  2. Hi, I was searching and searching and I still cannot find ANY information or specification that would tell me what exactly is returned by AAsset_read(AAsset* asset, void* buf, size_t count); function when I am accesing file that was compressed during creation of APK. I don't want to use hack's/WA's like changing file extension to prevent it from being compressed. I just want to be able to decompress packed file (whatever it's extension is) using AAssetManager in Native Activity. Can anyone give me a clue how it works with compressed files ? Thanks, Kaktus
  3. The idea is to have this functions to behave like normal methods of singleton. So they can operate on protected variables etc. without using getters and setters methods. I want to have interface that will be thesame from the programmer point of view but be implemented by specific functions depending on which version or extension of OpenGL is supported. When you want to use OpenGL greater than 1.1 or any extension under Windows you first need to bind each OpenGL function to it's pointer. When you do this you check if each version or extension is supported before binding functions corresponding to it. I would like to have singleton with abstract interface that would cover all that versions and extensions with one, intermediate and abstract API supported by it's methods. Therefore for each method I want to have set of specified functions that will cover it's behavior in the best way on different OpenGL versions. This is why I am searching for such mechanism to allow external functions to work on protected stuctures and data of Rendering Context singleton (or some alternative to that singleton). I think idea of covering all global data in some source file would be great but I think it will be too much code to hide it in only one cpp.
  4. [quote name='rip-off' timestamp='1305714632' post='4812449'] You must "friend" individual functions, you cannot friend a function pointer. Why not write the function pointer to take a float as an argument, and have the layout pass the value to the function? Or if all possible implementations are going to add "layout::var" to some constant, you could write them to return their "modifier", and then layout::pointSizeMin could add the modifier to the "var" value. Also consider not using singletons, they are widely considered to be a bad idea, a glorified global variable. Your layout::var could be a member variable instead of a static. Also, it could have a much better name. [/quote] This is just code sample, not the actual code implementation. Layout class is inheriting after singleton template which makes it singleton , to make it simpler I just set "var" as static to give a point of singleton. I want to create layout for my rendering context that could choose which functions to use depending on which version and/or extensions of OpenGL are supported. From the programmer way I will always have the same layout though.
  5. Hi there I am trying to create singleton class that will handle interface of my module with the programmer.The trick is that I want it to dynamically bind best posisible functionc to it's methods declarations. Currently I have almost done it but mu function's don't have access to class protected variables. This is my current code example: [code] typedef float(*PFNENRCPOINTSIZEMINPROC)(void); // Func ptr typedef float pointSizeMin_gl20(); float pointSizeMin_gl30(); PFNENRCPOINTSIZEMINPROC enGpuPointSizeMin = NULL; class layout { protected: static float var; public: layout(); float pointSizeMin(void); friend PFNENRCPOINTSIZEMINPROC; }; float layout::var; layout::layout() { var = 1.0f; enGpuPointSizeMin = pointSizeMin_gl30; } float layout::pointSizeMin(void) { return enGpuPointSizeMin(); } float pointSizeMin_gl20(void) { return 2.0f + layout::var; } float pointSizeMin_gl30(void) { return 3.0f + layout::var; } int main(int argc, char* argv[]) { layout renderer; float result = renderer.pointSizeMin(); return 0; } [/code] But during compilation I get this error : [code] 1>src\main.cpp(48): error C2248: 'layout::var' : cannot access protected member declared in class 'layout' 1> src\main.cpp(19) : see declaration of 'layout::var' 1> src\main.cpp(17) : see declaration of 'layout' [/code] It refers to bodies of pointSizeMin_gl20 and pointSizeMin_gl30. So how to allow these functions to work with private/protected data? Is there any way at all? Thanks, MrKaktus
  6. Isn't working means, is not making anything. There is just no new line in dumped file. Everything is glued together. RESOLVED: I was searching error in wrong place. endl templating wasn't a problem, it was ios::binary operator during file opening :/. So your code also wouldn't work edd2.
  7. Ok, but won't it be slower to use additional buffer streambuf and performing rdbuf ? I really would like to close it into log interface to be invisible from programmer side. [quote name='edd²' timestamp='1297597220' post='4773593'] The 'proper' way to do this is with a stream buffer, not a wrapper class. [code] #include <fstream> // ... std::filebuf fb;"log.txt", std::ios::out | std::ios::app | std::ios::binary); std::streambuf *old_clog_buf = 0; if (fb.is_open()) old_clog_buf = std::clog.rdbuf(&fb); std::clog << "This should appear in log.txt" << std::endl; if (old_clog_buf) std::clog.rdbuf(old_clog_buf); [/code] [/quote] Also changing m_output type from ofstream to fstream that is opened like this: [code] m_output = new fstream(path.c_str(), ios::out | ios::binary | ios::ate);[/code] Resolved problem with line: [code]*m_output << "<!>";[/code] Which now works properly, but calling this: [code] *m_output << endl;[/code] or [code] m_output->put( m_output->widen('\n') ); m_output->flush();[/code] or [code] *m_output << '\n'; m_output->flush()[/code] Still isn't working. Does somebody knows why?
  8. Hi, I'm rewriting my logging class and I want to be able to do such a thing: enLog << "costam" << endl; So that internall class method that overloads operator << would be able to dynamically switch incoming stream to cout or output file. I managed to do this for standard strings and variables but it isn't working for templated functions like std::endl. Where lays my problem? std::endl is a template function which means that the solution below will not work (template from template): log.h: [code] .... private: .... bool m_initialized; // Is output file stream initialized bool m_loging; // Turns logging on or off bool m_tofile; // true - Logging to file // false - Logging to console ofstream* m_output; // Output file stream public: ... template <typename T> NLogContext& operator << ( T& (*function)(T&) ); ... [/code] log.inl: [code] template <typename T> NLogContext& NLogContext::operator << ( T& (*function)(T&) ) { if (m_loging) if (m_tofile && m_initialized) function(*m_output); else function(std::cout); return *this; } [/code] So I have created such implementation which works fine for templated functions when they are directed to cout, but does't work when directed to ofstream. log.h: [code] .... private: // Declaration of standard stream output function pointers typedef std::basic_ostream<char, std::char_traits<char> > StreamOutType; typedef StreamOutType& (*StreamFuncPtr)(StreamOutType&); ... public: .... NLogContext& operator << (StreamFuncPtr function); // Accepts stream functions to log [/code] log.cpp: [code] NLogContext& NLogContext::operator << (StreamFuncPtr function) { *m_output << "<!>"; // <- THIS ALSO DOESN'T WORK WHICH IS UBER WEIRD ???? if (m_loging) if (m_tofile && m_initialized) function(*m_output); // <- DOESN'T WORK ???? else function(std::cout); return *this; } [/code] I understand that even when ofstream inhertis from ostream, std::endl is resolved to ostream at input so it cannot work inside overloading method with my output file. Therefore I decided to drop support for other templated functions like stream formatiing and in case of logging to file, insert end of line character "by hand". But there is a weird thing, even when I'm inserting anything to the ofstream stream "by hand" it isn't going to be processed :/. So I don't know why this line isn't working: [code] *m_output << "<!>"; // <- THIS ALSO DOESN'T WORK WHICH IS UBER WEIRD ???? [/code] So my final question is how to support templated functions that formats streams in the way that my overloaded operator << could direct them and execute on proper output ( cout or file ) ? Thanks, MrKaktus
  9. Hi everyone, I have problem with creating R16UI texture in OpenGL 3.2. As input I have: - 16bpp greyscale heightmap - saved in RAW file - with a power of two width & height I want to load it to OpenGL 3.2 to use it in my terrain engine. I was searching forum for such a problem and found only this topic: But guy there was trying to set it as Luminance16 and I want to have it as R16UI and sample it in my VS as UINT. How should my texture creation routine looks like? uint32 loadTextureRAW_R16UI(string& name) { ifstream *sfile; uint32 size; uint8 *buffer; // Open file sfile = new ifstream(name.c_str(),ios::in | ios::binary | ios::ate); if (sfile->fail()) { delete sfile; return 0; } // Read file size sfile->seekg(0,ios::end); size = sfile->tellg(); sfile->seekg(0,ios::beg); // Create temporary buffer for data buffer = new uint8[size]; sfile->read((char*)buffer,size); sfile->close(); delete sfile; // Calculate texture dimmensions uint32 height = (uint32)sqrt(double(size/4)); uint32 width = height * 2; // Send data to OpenGL GLuint id = 0; glGenTextures(1,&id); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,id); glGetError(); glTexImage2D(GL_TEXTURE_2D,0,GL_R16UI,width,height,0,GL_RED,GL_UNSIGNED_SHORT,buffer); uint32 err = glGetError(); if (err != GL_NO_ERROR) { if (err == GL_INVALID_ENUM) flog << "OpenGL error: Invalid enum!" << endl; if (err == GL_INVALID_VALUE) flog << "OpenGL error: Invalid value!" << endl; if (err == GL_INVALID_OPERATION) flog << "OpenGL error: Invalid operation!" << endl; if (err == GL_STACK_OVERFLOW) flog << "OpenGL error: Stack overflow!" << endl; if (err == GL_STACK_UNDERFLOW) flog << "OpenGL error: Stack underflow!" << endl; if (err == GL_OUT_OF_MEMORY) flog << "OpenGL error: Not enough memory!" << endl; } glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); //GL_REPEAT glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); //GL_REPEAT // Finalizing operation delete [] buffer; return id; } It returns now: OpenGL error: Invalid operation! What I am doing wrong? Thanks.