• Welcome to Dark Bit Factory & Gravity.
 

oldschool 2d and opengl

Started by hellsangel, August 06, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

Thanks Jim, seems to be working now but I had to put this at the start of the code:

#include "stdafx.h"


Jim

Project->Properties->C/C++/Precompiled Headers
change to 'Not Using Precompiled Headers'
:)

Basically, that's an compiler speed optimisation that prevents it having to recompile the headers every time you do a build (since they don't change).  Can be useful for big projects that take a long time to build.

Glad it's working.

Jim
Challenge Trophies Won:

Stonemonkey

Ah right, thanks again k++

hellsangel

 :clap:
thank you Jim for the framework and this wonderful RGB copperbars example  :cheers:

work perfectly for me

keep up good examples and tuts  ;D

:cheers:

Jim

No problem  :kewl:
Is this what you were looking for?  Are you interested in any particular old school effect?

Jim
Challenge Trophies Won:

hellsangel

#25
I wanted to test my raster routine, but I didn't write it with ortho mode and nothing appears on the screen

Raster[j].y = (GLfloat)sin(Raster[j].angle * 3.1415f / 180) + (Raster[j].height / 2);
glBegin(GL_QUADS);
for(i=0; i<Raster[j].height; i++)
{
           glColor3f(Raster[j].col1.r, Raster[j].col1.g, Raster[j].col1.b);
glVertex2f(-1.0f, Raster[j].y);
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(-1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col1.r, Raster[j].col1.g, Raster[j].col1.b);
glVertex2f(1.0f, Raster[j].y);

glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(-1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col3.r, Raster[j].col3.g, Raster[j].col3.b);
glVertex2f(-1.0f, Raster[j].y - Raster[j].height);
glColor3f(Raster[j].col3.r, Raster[j].col3.g, Raster[j].col3.b);
glVertex2f(1.0f, Raster[j].y - Raster[j].height);
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(1.0f, Raster[j].y - (Raster[j].height / 2));
}           
glEnd();
...

something wrong with old coord and ortho mode
or is it possible to mix 2D and 3D in a same drawing routine ? for example if I want to add a 3D textured/shaded cube...

about old effects, err...so much !  ;D
texts effects with bitmap fonts : I didn't test it yet with ortho

Jim

Sure, it's relatively easy to switch between Orthographic and Perspective, you just have to set up the GL_PROJECTION matrix properly.  You can do that multiple times during a scene.  Same with texturing.

The coordinates look odd to me, remember -1 is now 1 pixel off the left of the screen!

It looks like it's only drawing from -1 to 1 in X.  You can fix that by

X = X + 1
X = X * SCREEN_WIDTH/2

Jim
Challenge Trophies Won:

taj

Jim,

I tried running your exe here (glsample.exe) sand I get:

"This application failed to start becuase the application configuration is incorrect. Reinstalling the application..." etc

Any idea why? Win XP, SP2, Ati x800, Omega drivers.

Chris
Challenge Trophies Won:

Jim

Challenge Trophies Won:

taj

Quote from: Jim on August 14, 2007
You don't have the VC2005 runtime libraries installed.
http://www.microsoft.com/downloads/details.aspx?familyid=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en

Jim


I have VC++ Express installed (and used daily) which I think means I must have the VC2005 doesnt it?

Chris
Challenge Trophies Won:

Jim

That's definitely what that error means.  Perhaps it's to do with the fact I have VS2005 SP1 installed so my runtime requirements are slightly newer?

Jim
Challenge Trophies Won:

Rbz

Quote from: chris on August 14, 2007
Quote from: Jim on August 14, 2007
You don't have the VC2005 runtime libraries installed.
http://www.microsoft.com/downloads/details.aspx?familyid=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en

Jim


I have VC++ Express installed (and used daily) which I think means I must have the VC2005 doesnt it?

Chris

Works fine here, and the only non standard dll that it import is MSVCR80.dll, maybe you have one corrupted dll or it was deleted ???

Challenge Trophies Won:

taj

Thanks for the help guys, its weird and I'm going to leave this alone as its so much hassle getting VC++ to work in the first place. This is the only application I have ever known to fail :-(.

Challenge Trophies Won:

Jim

#33
Grab the dll from here
http://www.dll-files.com/dllindex/dll-files.shtml?msvcr80
and stick it in the directory with the exe.

It's possible that's not the right version though - there are many versions of msvcr80.dll, because it had security issues originally, so it's been updated.  VC2005 SP1 executables require (via a manifest) a specific minimum revision of the dll to link to at run time.

The only other fix for me is to post an exe linked to a static runtime...(attached)

Jim
Challenge Trophies Won:

taj

That cured the problem Jim - thanks.
So, what does that mean - that I have an old version of that dll?
Challenge Trophies Won:

Jim

I think so.  VS2005 has had a service pack and, as I stated in another thread, I think it now generates exes that require a newer version of msvcr80.dll due to security patches.  Do you have the latest .net framework patches from Mcrosoft Update?

Jim
Challenge Trophies Won:

taj

Actually no (I adopt a policy of upgrade when I must). So that explains it all.
Challenge Trophies Won:

energy

Hi ...
Just started coding in OPenGL and im interrested in the same effects as here written.
So it would be cool if someone has a bit code for scrollers etc...

Cheers and thanks
eNeRGy
coding: jwasm,masm
hobby: www.scd2003.de

Jim

If you'd like to start a new thread with specific questions that would be cool :)

Jim
Challenge Trophies Won:

relsoft

One way to do oldskool type 2d effects in openGL (and this is the way I used) is to code like you always do and never mind the openGL part.
Here's how:

Code ala PTC (which means on a buffer better to use 32 bits since it's easier to upload it later but there's a way to upload 8 bit images to opengl)
Be sure that your software buffer size is a power of 2 (if you want a 640x480 screen), you should use a 1024x1024 buffer)
Then for each frame...
Code your effect on the buffer
upload the buffer to an opengl texture(using glteximage2d or gltexsubimage2d)
blit the texture to screen using glquads

that's it.

I used it on one of my games. Note that the screen is rendered on a buffer whether you use OGL or Software as the render engine.
Code is FB17b though so there are lots of pointer hacks.

http://rel.betterwebber.com/index.php?action=contents&item=marvelous_twilight

I found a better and smaller demo on how to do this, check out effects.bas and display.bas.
Spacebar to skip effect
Challenge Trophies Won: