Jump to content

  • Log In with Google      Sign In   
  • Create Account


MrKaktus

Member Since 23 Jan 2010
Offline Last Active Oct 16 2012 09:57 AM

Topics I've Started

GL_ARB_Debug_Output - what do you need ?

20 September 2012 - 02:15 AM

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:
http://www.opengl.org/registry/specs/ARB/debug_output.txt

Thanks,
Karol

[Android][NativeActivity] AssetManager and compressed files?

01 June 2012 - 12:15 PM

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

Singleton with dynamicalli linked methods ?

18 May 2011 - 03:45 AM

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:


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;
}



But during compilation I get this error :


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'



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


Problem with overloaded <<, endl, cout and ofstream

13 February 2011 - 05:13 AM

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:
....
      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&) );
...


log.inl:
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;
}

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:
....
      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

log.cpp:
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;
}
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:


*m_output << "<!>";   // <- THIS ALSO DOESN'T WORK WHICH IS UBER WEIRD ????

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

GL_R16UI loading to GPU

23 January 2010 - 12:19 AM

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:

http://www.gamedev.net/community/forums/topic.asp?topic_id=550243&forum_id=31&gforum_id=0

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.

PARTNERS