Jump to content

  • Log In with Google      Sign In   
  • Create Account


ArgusMaker

Member Since 11 May 2011
Offline Last Active Feb 11 2013 07:37 AM
-----

Topics I've Started

double buffering GDI+

10 February 2013 - 08:27 AM

Hi there.

I would like to optimize the double buffer rendering system I made in win32 c++ programming with gdi+.

So far I created an offscreen static bitmap surface and a global Graphics object to draw onto it.
The problem is, every time I want to update the HDC of my window i need to create a new Graphic object and destroy it at the end of the event, like this:

...
case WM_PAINT:
    hdc = BeginPaint(hWnd,&ps);
    graphics = Graphics(hdc);
    graphics.DrawImage(backbuffer,0,0,width,height);
    EndPaint(hWnd,&ps);
    break;
...
//graphics gets destroyed at the end of WndProc

 

Since this operation is repeated almost 40 times per second, i was wondering wether creating and destroying every time that object would somehow slow down my program.
Maybe this solution would be better:

- using a new compatible HDC as the backbuffer instead of the BMP
- inside WM_PAINT, copy that with BitBlt instead of creating a Graphics object

What do you think?


[C++] Including DLLS

21 April 2012 - 09:16 AM

Hi there!
I'm programming in C++ - Win32 exe application environment.
My exe makes use of OpenGL and glew, so it needs glew32.dll to be in System folder or in the same directory of my exe.
What if i want to publish my exe without that additional DLL?
Is there a way to include the DLL inside the EXE?

Vertex Colors?

21 April 2012 - 09:06 AM

Hi!
I'm pretty new to OpenGL.
I'd like to draw a line with a color gradient ranging from red to blue, but i can't give a color to my always-white vertices!
I'm using a Vertex Buffer Object to render the line.
This is my code.
This is executed once at the beginning




GLuint VBuffer;
GLuint CBuffer;
GLfloat Vertices[] = {
0.0f,0.0f, //0,0
100.0f,100.0f, //100,100
2.0f,2.0f,
3.0f,3.0f
};
// the line will be rendered using the first two vertices
GLfloat Colors[] = {
1.0f,0.0f,0.0f,1.0f, //red
0.0f,0.0f,1.0f,1.0f, //blue
1.0f,0.0f,0.0f,1.0f,
1.0f,0.0f,0.0f,1.0f
};
//the line will be rendered using the first two colors


glGenBuffers(1,&VBuffer);
glBindBuffer(GL_ARRAY_BUFFER,VBuffer);
glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*8,Vertices,GL_DYNAMIC_DRAW);


glGenBuffers(1,&CBuffer);
glBindBuffer(GL_COLOR_BUFFER_BIT,CBuffer);
glBufferData(GL_COLOR_BUFFER_BIT,sizeof(GLfloat)*16,Colors,GL_DYNAMIC_DRAW);




When i render the line i use this code:
glBindBuffer(GL_ARRAY_BUFFER,VBuffer);
glVertexPointer(2,GL_FLOAT,0,BUFFER_OFFSET(0));

glBindBuffer(GL_COLOR_BUFFER_BIT,CBuffer);
glColorPointer(4,GL_FLOAT,0,BUFFER_OFFSET(0));

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_LINES,0,2);
glDisableClientState(GL_COLOR_BUFFER_BIT);
glDisableClientState(GL_VERTEX_ARRAY);

Yet the line is completely white.
What is wrong?

OpenGL Buffer Problem - RESOLVED

15 April 2012 - 02:39 AM

Spoiler

edit: Never mind! I had to place glewInit() after the activation of OpenGL.

[DX9]DeviceCheck

15 January 2012 - 06:00 AM

Hi there.
I have a variable with a pointer to my Direct3DDevice9
(IDirect3DDevice9* pd3dDevice)
and i know my code may modify its value.
How can i quickly test if pd3dDevice actually points to a valid device?

PARTNERS