Including Pixmap?!

BlitzMax Forums/BlitzMax Beginners Area/Including Pixmap?!

Kendrel(Posted 2005) [#1]
Ive recently played with the Bmax demo, and i was unable to include a pixmap into the .exe.

does incbin only work with loadimage (or even only with bmp)?!

Is there any way to include textures for opengl into the final executeable?! short snippet or help is welcome... thx


tonyg(Posted 2005) [#2]
Graphics 640,480
Incbin "max.png"
my_pixmap=LoadPixmap("incbin::max.png")
While Not KeyHit(key_escape)
  Cls
  DrawPixmap my_pixmap,0,0
  Flip
  FlushMem
Wend
End

This works OK for me.
What code are you using?
This works for textures...
Incbin "max.png"
Global tex=LoadTexture("incbin::max.png")

What code are you using?
Basically, incbin copies the image and doesn't worry whether it's to be used with loadimage, loadpixmap or loadtexture


Kendrel(Posted 2005) [#3]
I played around with NEHE Tut 18... snippet:
Incbin "data\Wall.bmp"
.
.

Function LoadGlTextures()
Local TextureImage:TPixmap
TextureImage:TPixmap=LoadPixmap("incbin::data\Wall.bmp")
.
.
.

thats the snippet only as you see, but incbin wont work... also it seems that i dont have a command like Loadtexture at all... or it it bcos i didnt include all mods? dont think so... weird


Kendrel(Posted 2005) [#4]
here is the complete code... incbin wont work:


Framework BRL.SYSTEM
Import BRL.BlitzGL
Import BRL.System
Import BRL.Pixmap
Import BRL.BMPLoader
Incbin "data\Wall.bmp"

Global ScreenWidth:Int=800
Global ScreenHeight:Int=600
Global ScreenDepth:Int=32

Global light:Byte ' Lighting ON/OFF

Global part1:Int ' Start Of Disc
Global part2:Int ' End Of Disc
Global p1:Int=0 ' Increase 1
Global p2:Int=1 ' Increase 2

Global xrot:Float ' X Rotation
Global yrot:Float ' Y Rotation
Global xspeed:Float=1 ' X Rotation Speed
Global yspeed:Float=1 ' Y Rotation Speed
Global z:Float=-5.0 ' Depth Into The Screen

Global quadratic:Int Ptr ' Storage For Our Quadratic Objects

Global LightAmbient:Float[]=[0.5, 0.5, 0.5, 1.0]
Global LightDiffuse:Float[]=[1.0, 1.0, 1.0, 1.0]
Global LightPosition:Float[]=[0.0, 0.0, 2.0, 1.0]

Global Texname:Int[3] ' Storage For 3 Textures
Global Filter:Int=0 ' Which Filter To Use
Global Objet:Int=0 ' Which Object To Draw

Global LighNotifi:String[]=["OFF","ON"]
Global TextureNotifi:String[]=["NEAREST","LINEAR","MIPMAP"]
Global FormNotifi:String[]=["Cube","Cylinder","Disk","sphere","Cone","Partial disk"]

result=1
Select result
Case -1
End
Case 0
bglCreateContext(ScreenWidth,ScreenHeight,ScreenDepth,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER)
Case 1
bglCreateContext(ScreenWidth,ScreenHeight,ScreenDepth,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER | BGL_FULLSCREEN)
End Select

bglSetSwapInterval(1)
InitGl()

While Not KeyHit( KEY_ESCAPE )
nehe18()
glDisable(GL_TEXTURE_2D)
glDisable(GL_DEPTH_TEST)
glDisable(GL_LIGHT1)
glDisable(GL_LIGHTING)
glColor3f(1.0,1.0,1.0)
'Framecounter--------------------------------------------
Framecounter_counter=Framecounter_counter+1
If Framecounter_time=0 Then Framecounter_time=MilliSecs()
If Framecounter_time+1001 <MilliSecs() Then
Framecounter_framerate=Framecounter_counter
Framecounter_counter=0
Framecounter_time=MilliSecs()
EndIf
bglDrawText("FPS : "+Framecounter_framerate,ScreenWidth-(8*12),ScreenHeight-16-8)
'--------------------------------------------------------
bglDrawText("NeHe & TipTup's Quadratics Tutorial (lesson 18)",10,24)

bglDrawText("'T' Texture filter : " + TextureNotifi[Filter],10,56)
bglDrawText("'L' Light : " + LighNotifi[light],10,72)
bglDrawText("'SPACE' Quadratic : " + FormNotifi[Objet],10,88)

glEnable(GL_LIGHTING)
glEnable(GL_LIGHT1)
glEnable(GL_DEPTH_TEST)
glEnable(GL_TEXTURE_2D)
FlushMem
bglSwapBuffers
Wend
End

Function InitGl()
LoadGlTextures()
glEnable(GL_TEXTURE_2D) ' Enable Texture Mapping
glShadeModel(GL_SMOOTH) ' Enable Smooth Shading
glClearColor(0.0, 0.0, 0.0, 0.5) ' Black Background
glClearDepth(1.0) ' Depth Buffer Setup
glEnable(GL_DEPTH_TEST) ' Enables Depth Testing
glDepthFunc(GL_LEQUAL) ' The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) ' Really Nice Perspective Calculations

glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient) ' Setup The Ambient Light
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse) ' Setup The Diffuse Light
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition) ' Position The Light
glEnable(GL_LIGHT1) ' Enable Light One

quadratic=Int Ptr gluNewQuadric() ' Create A Pointer To The Quadric Object (Return 0 If No Memory)
gluQuadricNormals(quadratic, GLU_SMOOTH) ' Create Smooth Normals
gluQuadricTexture(quadratic, GL_TRUE) ' Create Texture Coords

glViewport(0,0,ScreenWidth,ScreenHeight) ' Set viewport
glMatrixMode(GL_PROJECTION) ' Select The Projection Matrix
glLoadIdentity() ' Reset The Projection Matrix
gluPerspective(45.0,Float(ScreenWidth)/Float(ScreenHeight),0.1,100.0) ' Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW) ' Select The Modelview Matrix
glLoadIdentity()
End Function

Function LoadGlTextures()
Local TextureImage:TPixmap
TextureImage:TPixmap=LoadPixmap("incbin::data\Wall.bmp")

glGenTextures(3, Varptr Texname[0]) ' Create Three Textures
' Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, Texname[0])
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST)
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage.width, TextureImage.height, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.pixels)
' Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, Texname[1])
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage.width, TextureImage.height, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.pixels)
' Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, Texname[2])
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.width, TextureImage.height, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.pixels)
End Function

Function nehe18()
If KeyHit(KEY_L) Then
light=Not light
EndIf
If light=0 Then
glDisable(GL_LIGHTING)
Else
glEnable(GL_LIGHTING)
EndIf

If KeyHit(KEY_T)
Filter:+1
If Filter>2 Then Filter=0
EndIf

If KeyHit(KEY_SPACE)
Objet:+1
If Objet>5 Then Objet=0
EndIf

If KeyDown(KEY_PAGEUP) Then z:-0.02
If KeyDown(KEY_PAGEDOWN) Then z:+0.02
If KeyHit(KEY_UP) Then xspeed:-0.01
If KeyHit(KEY_DOWN) Then xspeed:+0.01
If KeyHit(KEY_RIGHT) Then yspeed:+0.01
If KeyHit(KEY_LEFT) Then yspeed:-0.01

glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ' Clear The Screen And The Depth Buffer
glLoadIdentity() ' Reset The Current Modelview Matrix
glTranslatef(0.0,0.0,z)
glRotatef(xrot,1.0,0.0,0.0)
glRotatef(yrot,0.0,1.0,0.0)
glBindTexture(GL_TEXTURE_2D, Texname[filter])

Select Objet
Case 0
glDrawCube()
Case 1
glTranslatef(0.0,0.0,-1.5) ' Center The Cylinder
gluCylinder(quadratic,1.0,1.0,3.0,32,32) ' A Cylinder With A Radius Of 0.5 And A Height Of 2
Case 2
gluDisk(quadratic,0.5,1.5,32,32) ' Draw A Disc (CD Shape) With An Inner Radius Of 0.5, And An Outer Radius Of 2. Plus A Lot Of Segments ;)
Case 3
gluSphere(quadratic,1.3,32,32) ' Draw A Sphere With A Radius Of 1 And 16 Longitude And 16 Latitude Segments
Case 4
glTranslatef(0.0,0.0,-1.5) ' Center The Cone
gluCylinder(quadratic,1.0,0.0,3.0,32,32) ' A Cone With A Bottom Radius Of .5 And A Height Of 2
Case 5
part1:+p1
part2:+p2
If(part1>359) Then ' 360 Degrees
p1=0
part1=0
p2=1
part2=0
EndIf
If(part2>359) Then ' 360 Degrees
p1=1
p2=0
EndIf
gluPartialDisk(quadratic,0.5,1.5,32,32,part1,part2-part1) ' A Disk Like The One Before
End Select

xrot:+xspeed
yrot:+yspeed
End Function

Function glDrawCube()
glBegin(GL_QUADS)
' Front Face
glNormal3f( 0.0, 0.0, 1.0)
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0)
' Back Face
glNormal3f( 0.0, 0.0,-1.0)
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0)
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, -1.0)
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, -1.0)
' Top Face
glNormal3f( 0.0, 1.0, 0.0)
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0)
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0)
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0)
' Bottom Face
glNormal3f( 0.0,-1.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, -1.0, -1.0)
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0)
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0)
' Right Face
glNormal3f( 1.0, 0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.0)
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, -1.0)
glTexCoord2f(0.0, 1.0); glVertex3f( 1.0, 1.0, 1.0)
glTexCoord2f(0.0, 0.0); glVertex3f( 1.0, -1.0, 1.0)
' Left Face
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0)
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0)
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0)
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0)
glEnd()
End Function


Damien Sturdy(Posted 2005) [#5]
i *think* you need the Ramstream module for IncBin to work :) Im not at my puter so i cant give you the correct full name.
Maybe "BRL.RamStream"
*copies*


Kendrel(Posted 2005) [#6]
Tried it without succes... even if i dont use specific modules, texturing wont work... ;(

i tried the sample from tony, and it works just fine... but if you wanna load the pixmap for opengl texturing - it wont


Kendrel(Posted 2005) [#7]
It will work if i use the complete framework... well... now i need to know what module i need to import...


Kendrel(Posted 2005) [#8]
Okay Sorry

Ramstream will do the job... i tried it a 2nd time (maybe i misspelled the first time), and it finally works... thx guys....


Damien Sturdy(Posted 2005) [#9]
I remember this problem from when i first started :) hehe.


Kendrel(Posted 2005) [#10]
How do i know what modules contain which stuff? i mean... its not in the docs (or maybe just not the demo docs?)

whatever... little bit confusing


Damien Sturdy(Posted 2005) [#11]
I was there for hours mate, until i guessed it right..

Head over to the Blitz Showcase though, theres a FrameWork Wizard there now :)


Damien Sturdy(Posted 2005) [#12]
I was there for hours mate, until i guessed it right..

Head over to the Blitz Showcase though, theres a FrameWork Wizard there now :)


Kendrel(Posted 2005) [#13]
cant find it ;(


Damien Sturdy(Posted 2005) [#14]
;( eh?

http://www.blitzbasic.com/Community/posts.php?topic=48160